Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled_at logic: redirect to login path if user is disabled #9341

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/spree/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def orders_collection

def load_object
@user ||= spree_current_user
if @user
if @user && [email protected]
authorize! params[:action].to_sym, @user
else
redirect_to main_app.login_path
Expand Down
11 changes: 11 additions & 0 deletions spec/system/consumer/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I just learned that we don't have to persist the user. Warden::Test::Helpers#login_as sets the user object in memory and unless we are doing other queries that need the database, we can use an in-memory user for authentication in specs!

That line here doesn't save to the database but we don't need to in this spec.

end

it "redirects to the login page" do
visit "/account"
expect(page).to have_current_path("/")
end
end
end
end