diff --git a/app/controllers/spree/users_controller.rb b/app/controllers/spree/users_controller.rb index 49900a9a462..dc5629612a2 100644 --- a/app/controllers/spree/users_controller.rb +++ b/app/controllers/spree/users_controller.rb @@ -78,7 +78,7 @@ def orders_collection 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 9e8f89b37a9..1d83fa20f1a 100644 --- a/spec/system/consumer/account_spec.rb +++ b/spec/system/consumer/account_spec.rb @@ -111,5 +111,16 @@ 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