mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
Adapt specs to new rspec syntax without xhr
This commit is contained in:
@@ -82,7 +82,7 @@ describe CartController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns the variant override stock levels of the variant in the order" do
|
||||
spree_post :populate, params: { variants: { variant_in_the_order.id => 1 } }
|
||||
spree_post :populate, variants: { variant_in_the_order.id => 1 }
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
expect(data['stock_levels'][variant_in_the_order.id.to_s]["on_hand"]).to eq 20
|
||||
@@ -93,7 +93,7 @@ describe CartController, type: :controller do
|
||||
# If the variant was not added to the order, VariantsStockLevels alternative calculation would fail
|
||||
# See #3222 for more details
|
||||
# This indicates that the VariantsStockLevels alternative calculation is never reached
|
||||
spree_post :populate, params: { variants: { variant_not_in_the_order.id => 1 } }
|
||||
spree_post :populate, variants: { variant_not_in_the_order.id => 1 }
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
expect(data['stock_levels'][variant_not_in_the_order.id.to_s]["on_hand"]).to eq 7
|
||||
@@ -114,7 +114,7 @@ describe CartController, type: :controller do
|
||||
allow(controller).to receive(:current_order).and_return(order)
|
||||
|
||||
expect do
|
||||
spree_post :populate, params: { variants: { variant.id => 1 }, variant_attributes: { variant.id => { max_quantity: "3" } } }
|
||||
spree_post :populate, variants: { variant.id => 1 }, variant_attributes: { variant.id => { max_quantity: "3" } }
|
||||
end.to change(Spree::LineItem, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,13 +49,13 @@ describe UserPasswordsController, type: :controller do
|
||||
|
||||
describe "via ajax" do
|
||||
it "returns error when email not found" do
|
||||
xhr :post, :create, spree_user: {}, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: {}, use_route: :spree }
|
||||
expect(response.status).to eq 404
|
||||
expect(json_response).to eq 'error' => I18n.t('email_not_found')
|
||||
end
|
||||
|
||||
it "returns error when user is unconfirmed" do
|
||||
xhr :post, :create, spree_user: { email: unconfirmed_user.email }, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: { email: unconfirmed_user.email }, use_route: :spree }
|
||||
expect(response.status).to eq 401
|
||||
expect(json_response).to eq 'error' => I18n.t('email_unconfirmed')
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ describe UserRegistrationsController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns validation errors" do
|
||||
xhr :post, :create, spree_user: {}, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: {}, use_route: :spree }
|
||||
expect(response.status).to eq(401)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json).to eq("email" => ["can't be blank"], "password" => ["can't be blank"])
|
||||
@@ -35,7 +35,7 @@ describe UserRegistrationsController, type: :controller do
|
||||
allow(Spree::UserMailer).to receive(:confirmation_instructions).and_raise("Some error")
|
||||
expect(OpenFoodNetwork::ErrorLogger).to receive(:notify)
|
||||
|
||||
xhr :post, :create, spree_user: user_params, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
|
||||
|
||||
expect(response.status).to eq(401)
|
||||
json = JSON.parse(response.body)
|
||||
@@ -43,7 +43,7 @@ describe UserRegistrationsController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns 200 when registration succeeds" do
|
||||
xhr :post, :create, spree_user: user_params, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json).to eq("email" => "test@test.com")
|
||||
@@ -55,7 +55,7 @@ describe UserRegistrationsController, type: :controller do
|
||||
original_locale_cookie = cookies[:locale]
|
||||
|
||||
cookies[:locale] = "pt"
|
||||
xhr :post, :create, spree_user: user_params, use_route: :spree
|
||||
post :create, xhr: true, params: { spree_user: user_params, use_route: :spree }
|
||||
expect(assigns[:user].locale).to eq("pt")
|
||||
|
||||
I18n.locale = original_i18n_locale
|
||||
|
||||
@@ -37,7 +37,7 @@ describe ShopController, type: :controller, performance: true do
|
||||
|
||||
it "returns products via json" do
|
||||
results = multi_benchmark(3, cache_key_patterns: cache_key_patterns) do
|
||||
xhr :get, :products
|
||||
get :products, xhr: true
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user