mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
Fixes RSpec Rails HaveHttpStatus cop in controllers
This commit is contained in:
@@ -221,26 +221,12 @@ Metrics/PerceivedComplexity:
|
||||
- 'app/models/spree/ability.rb'
|
||||
- 'app/models/spree/order/checkout.rb'
|
||||
|
||||
# Offense count: 69
|
||||
# Offense count: 39
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: ResponseMethods.
|
||||
# ResponseMethods: response, last_response
|
||||
RSpecRails/HaveHttpStatus:
|
||||
Exclude:
|
||||
- 'spec/controllers/cart_controller_spec.rb'
|
||||
- 'spec/controllers/checkout_controller_spec.rb'
|
||||
- 'spec/controllers/enterprises_controller_spec.rb'
|
||||
- 'spec/controllers/line_items_controller_spec.rb'
|
||||
- 'spec/controllers/shop_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/orders_controller_spec.rb'
|
||||
- 'spec/controllers/spree/admin/products_controller_spec.rb'
|
||||
- 'spec/controllers/spree/credit_cards_controller_spec.rb'
|
||||
- 'spec/controllers/spree/orders_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/callbacks_controller_spec.rb'
|
||||
- 'spec/controllers/stripe/webhooks_controller_spec.rb'
|
||||
- 'spec/controllers/user_passwords_controller_spec.rb'
|
||||
- 'spec/controllers/user_registrations_controller_spec.rb'
|
||||
- 'spec/requests/api/routes_spec.rb'
|
||||
- 'spec/requests/checkout/stripe_sca_spec.rb'
|
||||
- 'spec/requests/home_controller_spec.rb'
|
||||
|
||||
@@ -17,7 +17,7 @@ RSpec.describe CartController, type: :controller do
|
||||
allow(cart_service).to receive(:populate) { true }
|
||||
allow(cart_service).to receive(:valid?) { true }
|
||||
post :populate, xhr: true, params: { use_route: :spree }, as: :json
|
||||
expect(response.status).to eq(200)
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
it "returns failure when unsuccessful" do
|
||||
@@ -26,7 +26,7 @@ RSpec.describe CartController, type: :controller do
|
||||
allow(cart_service).to receive(:errors) { errors }
|
||||
allow(errors).to receive(:full_messages).and_return(["Error: foo"])
|
||||
post :populate, xhr: true, params: { use_route: :spree }, as: :json
|
||||
expect(response.status).to eq(412)
|
||||
expect(response).to have_http_status(:precondition_failed)
|
||||
end
|
||||
|
||||
it "returns stock levels as JSON on success" do
|
||||
|
||||
@@ -21,7 +21,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
describe "#edit" do
|
||||
it "renders the checkout" do
|
||||
get :edit, params: { step: "details" }
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
|
||||
it "redirects to current step if no step is given" do
|
||||
@@ -74,7 +74,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "updates the order state to payment" do
|
||||
get :edit, params: { step: "payment" }
|
||||
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(order.reload.state).to eq("payment")
|
||||
end
|
||||
end
|
||||
@@ -83,7 +83,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "updates the order state to address" do
|
||||
get :edit, params: { step: "details" }
|
||||
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(order.reload.state).to eq("address")
|
||||
end
|
||||
end
|
||||
@@ -98,7 +98,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "updates the order state to address" do
|
||||
get :edit, params: { step: "details" }
|
||||
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(order.reload.state).to eq("address")
|
||||
end
|
||||
end
|
||||
@@ -119,7 +119,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "returns 422 and some feedback" do
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "Saving failed, please update the highlighted fields."
|
||||
expect(order.reload.state).to eq "cart"
|
||||
end
|
||||
@@ -276,7 +276,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "returns 422 and some feedback" do
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "Saving failed, please update the highlighted fields."
|
||||
expect(order.reload.state).to eq "payment"
|
||||
end
|
||||
@@ -405,7 +405,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "updates and redirects to summary step" do
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to be 302
|
||||
expect(response).to have_http_status :found
|
||||
expect(response).to redirect_to checkout_step_path(:summary)
|
||||
expect(order.reload.state).to eq "confirmation"
|
||||
end
|
||||
@@ -420,7 +420,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
|
||||
it "updates and redirects to summary step" do
|
||||
put(:update, params:)
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "Saving failed, please update the highlighted fields."
|
||||
expect(order.reload.state).to eq "payment"
|
||||
end
|
||||
@@ -557,7 +557,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
it "returns 422 and some feedback" do
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "Saving failed, please update the highlighted fields."
|
||||
expect(order.reload.state).to eq "confirmation"
|
||||
end
|
||||
@@ -607,7 +607,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "Redeeming the voucher failed"
|
||||
end
|
||||
end
|
||||
@@ -621,7 +621,7 @@ RSpec.describe CheckoutController, type: :controller do
|
||||
|
||||
put(:update, params:)
|
||||
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(flash[:error]).to match "There was an error while trying to redeem your voucher"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,16 +162,16 @@ RSpec.describe EnterprisesController, type: :controller do
|
||||
|
||||
it "responds with status of 200 when the route does not exist" do
|
||||
get :check_permalink, xhr: true, params: { permalink: 'some_nonexistent_route' }, as: :js
|
||||
expect(response.status).to be 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
|
||||
it "responds with status of 409 when the permalink matches an existing route" do
|
||||
# get :check_permalink, { permalink: 'enterprise_permalink', format: :js }
|
||||
# expect(response.status).to be 409
|
||||
get :check_permalink, xhr: true, params: { permalink: 'map' }, as: :js
|
||||
expect(response.status).to be 409
|
||||
expect(response).to have_http_status :conflict
|
||||
get :check_permalink, xhr: true, params: { permalink: '' }, as: :js
|
||||
expect(response.status).to be 409
|
||||
expect(response).to have_http_status :conflict
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
|
||||
it "lists items bought by the user from the same shop in the same order_cycle" do
|
||||
get :bought, format: :json
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
json_response = response.parsed_body
|
||||
expect(json_response.length).to eq completed_order.line_items.reload.count
|
||||
expect(json_response[0]['id']).to eq completed_order.line_items.first.id
|
||||
@@ -53,7 +53,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
context "where the item's order is not associated with the user" do
|
||||
it "denies deletion" do
|
||||
delete(:destroy, params:)
|
||||
expect(response.status).to eq 403
|
||||
expect(response).to have_http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
context "without an order cycle or distributor" do
|
||||
it "denies deletion" do
|
||||
delete(:destroy, params:)
|
||||
expect(response.status).to eq 403
|
||||
expect(response).to have_http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
context "where changes are not allowed" do
|
||||
it "denies deletion" do
|
||||
delete(:destroy, params:)
|
||||
expect(response.status).to eq 403
|
||||
expect(response).to have_http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,7 +85,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
|
||||
it "deletes the line item" do
|
||||
delete(:destroy, params:)
|
||||
expect(response.status).to eq 204
|
||||
expect(response).to have_http_status :no_content
|
||||
expect { item.reload }.to raise_error ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
@@ -144,7 +144,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
item = order.line_items.first
|
||||
allow(controller).to receive_messages spree_current_user: order.user
|
||||
delete :destroy, format: :json, params: { id: item }
|
||||
expect(response.status).to eq 204
|
||||
expect(response).to have_http_status :no_content
|
||||
|
||||
# Check the fees again
|
||||
order.reload
|
||||
@@ -188,7 +188,7 @@ RSpec.describe LineItemsController, type: :controller do
|
||||
|
||||
allow(controller).to receive_messages spree_current_user: user
|
||||
delete(:destroy, params:)
|
||||
expect(response.status).to eq 204
|
||||
expect(response).to have_http_status :no_content
|
||||
|
||||
expect(order.reload.adjustment_total).to eq calculator.preferred_normal_amount
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ RSpec.describe ShopController, type: :controller do
|
||||
oc2 = create(:simple_order_cycle, distributors: [distributor])
|
||||
|
||||
spree_post :order_cycle, order_cycle_id: oc2.id
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(controller.current_order_cycle).to eq(oc2)
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ RSpec.describe ShopController, type: :controller do
|
||||
oc2 = create(:simple_order_cycle, distributors: [distributor])
|
||||
|
||||
spree_post :order_cycle, order_cycle_id: oc2.id
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response.body).to have_content oc2.id
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ RSpec.describe ShopController, type: :controller do
|
||||
|
||||
it "returns the new order cycle details" do
|
||||
spree_post :order_cycle, order_cycle_id: oc2.id
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response.body).to have_content oc2.id
|
||||
end
|
||||
end
|
||||
@@ -82,7 +82,7 @@ RSpec.describe ShopController, type: :controller do
|
||||
oc3 = create(:simple_order_cycle, distributors: [create(:distributor_enterprise)])
|
||||
|
||||
spree_post :order_cycle, order_cycle_id: oc3.id
|
||||
expect(response.status).to eq(404)
|
||||
expect(response).to have_http_status(:not_found)
|
||||
expect(controller.current_order_cycle).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -133,7 +133,7 @@ RSpec.describe Spree::Admin::PaymentsController, type: :controller do
|
||||
end
|
||||
|
||||
def expect_redirect_to(path)
|
||||
expect(response.status).to eq 302
|
||||
expect(response).to have_http_status :found
|
||||
expect(response.location).to eq path
|
||||
end
|
||||
end
|
||||
@@ -280,7 +280,7 @@ RSpec.describe Spree::Admin::PaymentsController, type: :controller do
|
||||
|
||||
it "renders the payments tab" do
|
||||
spree_get :index, order_id: order.number
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
|
||||
context "order is then resumed" do
|
||||
@@ -290,7 +290,7 @@ RSpec.describe Spree::Admin::PaymentsController, type: :controller do
|
||||
|
||||
it "still renders the payments tab" do
|
||||
spree_get :index, order_id: order.number
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -304,7 +304,7 @@ RSpec.describe Spree::Admin::PaymentsController, type: :controller do
|
||||
|
||||
it "redirects to the order details page" do
|
||||
spree_get :index, order_id: order.number
|
||||
expect(response.status).to eq 302
|
||||
expect(response).to have_http_status :found
|
||||
expect(response.location).to eq spree.edit_admin_order_url(order)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ RSpec.describe Spree::Admin::OrdersController, type: :controller do
|
||||
|
||||
spree_put :update, params
|
||||
|
||||
expect(response.status).to eq 302
|
||||
expect(response).to have_http_status :found
|
||||
end
|
||||
|
||||
context "recalculating fees and taxes" do
|
||||
@@ -290,7 +290,7 @@ RSpec.describe Spree::Admin::OrdersController, type: :controller do
|
||||
before { allow(controller).to receive(:spree_current_user) { order.distributor.owner } }
|
||||
|
||||
it "should allow access" do
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -169,7 +169,7 @@ RSpec.describe Spree::Admin::ProductsController, type: :controller do
|
||||
|
||||
spree_put :create, product: product_attrs_with_image
|
||||
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status 200
|
||||
end
|
||||
end
|
||||
|
||||
@@ -179,7 +179,7 @@ RSpec.describe Spree::Admin::ProductsController, type: :controller do
|
||||
{ supplier_id: nil, primary_taxon_id: nil }
|
||||
),
|
||||
button: 'create'
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status 200
|
||||
expect(response).to render_template('spree/admin/products/new')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -172,7 +172,7 @@ RSpec.describe Spree::CreditCardsController, type: :controller do
|
||||
expect(controller).not_to receive(:destroy_at_stripe)
|
||||
spree_delete :destroy, params
|
||||
expect(flash[:error]).to eq 'Sorry, the card could not be removed'
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -204,7 +204,7 @@ RSpec.describe Spree::CreditCardsController, type: :controller do
|
||||
it "doesn't delete the card" do
|
||||
expect{ spree_delete :destroy, params }.not_to change { Spree::CreditCard.count }
|
||||
expect(flash[:error]).to eq 'Sorry, the card could not be removed'
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
@@ -218,7 +218,7 @@ RSpec.describe Spree::CreditCardsController, type: :controller do
|
||||
expect{ spree_delete :destroy, params }.to change { Spree::CreditCard.count }.by(-1)
|
||||
expect(flash[:success])
|
||||
.to eq "Your card has been removed (number: %s)" % "x-#{card.last_digits}"
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
|
||||
context "card is the default card and there are existing authorizations for the user" do
|
||||
|
||||
@@ -26,7 +26,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "loads page" do
|
||||
get :show, params: { id: order.number, order_token: order.token }
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
|
||||
it "stores order token in session as 'access_token'" do
|
||||
@@ -45,7 +45,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "loads page" do
|
||||
get :show, params: { id: order.number }
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "loads page" do
|
||||
get :show, params: { id: order.number }
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -162,7 +162,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "displays a flash message when we view the cart" do
|
||||
get :edit
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(flash[:error]).to eq 'An item in your cart has become unavailable. ' \
|
||||
'Please update the selected quantities.'
|
||||
end
|
||||
@@ -175,7 +175,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
|
||||
it "displays a flash message when we view the cart" do
|
||||
get :edit
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(flash[:error]).to eq 'An item in your cart has become unavailable. ' \
|
||||
'Please update the selected quantities.'
|
||||
end
|
||||
@@ -192,7 +192,7 @@ RSpec.describe Spree::OrdersController, type: :controller do
|
||||
"0" => { quantity: "0", id: "9999" },
|
||||
"1" => { quantity: "99", id: li.id }
|
||||
} } }
|
||||
expect(response.status).to eq(302)
|
||||
expect(response).to have_http_status(:found)
|
||||
expect(li.reload.quantity).to eq(99)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ RSpec.describe Stripe::CallbacksController, type: :controller do
|
||||
|
||||
it "returns a 500 error" do
|
||||
spree_get :index, params
|
||||
expect(response.status).to be 500
|
||||
expect(response).to have_http_status :internal_server_error
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
|
||||
it "responds with a 400" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 400
|
||||
expect(response).to have_http_status :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
|
||||
it "responds with a 401" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 401
|
||||
expect(response).to have_http_status :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
|
||||
it "falls back to 200" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
|
||||
it "responds with 202" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 202
|
||||
expect(response).to have_http_status :accepted
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -78,7 +78,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
context "when the stripe_account id on the event does not match any known accounts" do
|
||||
it "doesn't delete any Stripe accounts, responds with 204" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 204
|
||||
expect(response).to have_http_status :no_content
|
||||
expect(StripeAccount.all).to include stripe_account
|
||||
end
|
||||
end
|
||||
@@ -88,7 +88,7 @@ RSpec.describe Stripe::WebhooksController, type: :controller do
|
||||
|
||||
it "deletes Stripe accounts in response to a webhook" do
|
||||
post('create', params:)
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(StripeAccount.all).not_to include stripe_account
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,20 +15,20 @@ RSpec.describe UserPasswordsController, type: :controller do
|
||||
describe "create" do
|
||||
it "returns 404 if user is not found" do
|
||||
spree_post :create, spree_user: { email: "xxxxxxxxxx@example.com" }
|
||||
expect(response.status).to eq 404
|
||||
expect(response).to have_http_status :not_found
|
||||
expect(response.body).to match 'Email address not found'
|
||||
end
|
||||
|
||||
it "returns 422 if user is registered but not confirmed" do
|
||||
spree_post :create, spree_user: { email: unconfirmed_user.email }
|
||||
expect(response.status).to eq 422
|
||||
expect(response).to have_http_status :unprocessable_entity
|
||||
expect(response.body).to match "You must confirm your email \
|
||||
address before you can reset your password."
|
||||
end
|
||||
|
||||
it "returns 200 when password reset was successful" do
|
||||
spree_post :create, spree_user: { email: user.email }
|
||||
expect(response.status).to eq 200
|
||||
expect(response).to have_http_status :ok
|
||||
expect(response.body).to match "An email with instructions on resetting \
|
||||
your password has been sent!"
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ RSpec.describe UserRegistrationsController, type: :controller do
|
||||
|
||||
it "returns validation errors" do
|
||||
post :create, params: { spree_user: {}, use_route: :spree }, as: :json
|
||||
expect(response.status).to eq(401)
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
json = response.parsed_body
|
||||
expect(json).to eq("email" => ["can't be blank"], "password" => ["can't be blank"])
|
||||
end
|
||||
@@ -31,7 +31,7 @@ RSpec.describe UserRegistrationsController, type: :controller do
|
||||
|
||||
post :create, params: { spree_user: user_params, use_route: :spree }, as: :json
|
||||
|
||||
expect(response.status).to eq(401)
|
||||
expect(response).to have_http_status(:unauthorized)
|
||||
json = response.parsed_body
|
||||
expect(json).to eq(
|
||||
"message" =>
|
||||
@@ -41,7 +41,7 @@ RSpec.describe UserRegistrationsController, type: :controller do
|
||||
|
||||
it "returns 200 when registration succeeds" do
|
||||
post :create, params: { spree_user: user_params, use_route: :spree }, as: :json
|
||||
expect(response.status).to eq(200)
|
||||
expect(response).to have_http_status(:ok)
|
||||
json = response.parsed_body
|
||||
expect(json).to eq("email" => "test@test.com")
|
||||
expect(controller.spree_current_user).to be_nil
|
||||
|
||||
Reference in New Issue
Block a user