Skip to content

Commit

Permalink
Update redirection logic after login to goto dashboard if they are ve…
Browse files Browse the repository at this point in the history
…rified staff (#193)
  • Loading branch information
edwinthinks authored Sep 27, 2023
1 parent 2f9f5b9 commit 0e0a6d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/controllers/concerns/organization_scopable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def set_tenant
end

def after_sign_in_path_for(resource_or_scope)
adoptable_pets_path
if resource_or_scope.staff_account&.verified
dashboard_index_path
else
adoptable_pets_path
end
end

def after_sign_out_path_for(resource_or_scope)
Expand Down
5 changes: 3 additions & 2 deletions test/system/login_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ class LoginTest < ApplicationSystemTestCase
setup do
@organization = create(:organization)
@user = create(:user, organization: @organization)
StaffAccount.create!(user: @user, organization: @organization, verified: true)
set_organization(@organization)
end

context "when logging in as a staff member" do
should "direct to the organization's adoptable pets page" do
should "direct to the organization's dashboard" do
visit root_url
click_on "Log In"

Expand All @@ -17,7 +18,7 @@ class LoginTest < ApplicationSystemTestCase
click_on "Log in"

assert current_path.include?(@user.organization.slug)
assert page.has_content?("Signed in successfully.")
assert current_path.has_content?("Dashboard")
end
end
end

0 comments on commit 0e0a6d1

Please sign in to comment.