From 4007b17b1e62870caa091dc88b89aafaff8bf41e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Wed, 22 Jun 2022 15:25:37 +0200 Subject: [PATCH] Redirect to login path also if user is disabled + update spec as well --- app/controllers/spree/users_controller.rb | 2 +- spec/system/consumer/account_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/spree/users_controller.rb b/app/controllers/spree/users_controller.rb index 49900a9a46..dc5629612a 100644 --- a/app/controllers/spree/users_controller.rb +++ b/app/controllers/spree/users_controller.rb @@ -78,7 +78,7 @@ module Spree def load_object @user ||= spree_current_user - if @user + if @user && !@user.disabled authorize! params[:action].to_sym, @user else redirect_to main_app.login_path diff --git a/spec/system/consumer/account_spec.rb b/spec/system/consumer/account_spec.rb index f108006c6f..12739bfc55 100644 --- a/spec/system/consumer/account_spec.rb +++ b/spec/system/consumer/account_spec.rb @@ -111,5 +111,16 @@ describe ' expect(page).to have_content I18n.t(:you_have_no_orders_yet) end end + + context "as a disabled user" do + before do + user.disabled = '1' + end + + it "redirects to the login page" do + visit "/account" + expect(page).to have_current_path("/") + end + end end end