Browse Source

Fixed weird spec sign_in issues, and render json

denney-fix-saving-dates
Jason Denney 11 years ago
parent
commit
1f9322ff3d
  1. 10
      spec/controllers/api/bikes_controller_spec.rb

10
spec/controllers/api/bikes_controller_spec.rb

@ -42,7 +42,7 @@ describe Api::V1::BikesController do
context "with valid bike in json data" do context "with valid bike in json data" do
before(:each) do before(:each) do
@submit_json = { bikes: [{ bike_data = { bikes: [{
serial_number: "XKCD", serial_number: "XKCD",
bike_brand_id: 1, bike_brand_id: 1,
shop_id: 1, shop_id: 1,
@ -53,6 +53,10 @@ describe Api::V1::BikesController do
bike_purpose_id: 1, bike_purpose_id: 1,
bike_wheel_size_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 end
it "returns 200" do it "returns 200" do
@ -63,8 +67,8 @@ describe Api::V1::BikesController do
it "returns the created bike json" do it "returns the created bike json" do
post :create, @submit_json post :create, @submit_json
json = JSON.parse(@response.body) json = JSON.parse(@response.body)
expect(json).to have_key("bike") expect(json).to have_key("bikes")
expect(json.to_s).to include(@submit_json[:bike][:serial_number]) expect(json.to_s).to include(@submit_json[:bikes].first[:serial_number])
end end
end end

Loading…
Cancel
Save