|
|
@ -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 |
|
|
|
|
|
|
|