1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 08:43:23 -05:00

Fixed weird spec sign_in issues, and render json

This commit is contained in:
Jason Denney 2014-03-09 22:49:30 -04:00
parent b1ddcfb867
commit 1f9322ff3d

View File

@ -42,7 +42,7 @@ describe Api::V1::BikesController do
context "with valid bike in json data" do
before(:each) do
@submit_json = { bikes: [{
bike_data = { bikes: [{
serial_number: "XKCD",
bike_brand_id: 1,
shop_id: 1,
@ -53,6 +53,10 @@ describe Api::V1::BikesController do
bike_purpose_id: 1,
bike_wheel_size_id: 1,
}]}
#this is necessary because render_views does not work with sign_in devise helper
@submit_json = api_submit_json(@user, bike_data)
#not sure why format: :json not working
request.accept = 'application/json'
end
it "returns 200" do
@ -63,8 +67,8 @@ describe Api::V1::BikesController do
it "returns the created bike json" do
post :create, @submit_json
json = JSON.parse(@response.body)
expect(json).to have_key("bike")
expect(json.to_s).to include(@submit_json[:bike][:serial_number])
expect(json).to have_key("bikes")
expect(json.to_s).to include(@submit_json[:bikes].first[:serial_number])
end
end