Commit 6c671e1b authored by Zsolt Benke's avatar Zsolt Benke
Browse files

Redirect users visiting application#home by roles

parent 2457e5e7
Pipeline #21634 failed with stage
in 33 minutes and 29 seconds
......@@ -34,6 +34,9 @@ class ApplicationController < ActionController::Base
def home
authorize :application, :home?
redirect_to volunteers_path if superadmin? || department_manager?
redirect_to clients_path if social_worker?
redirect_to profile_path(current_user) if volunteer?
end
def t_model
......
require 'test_helper'
class ApplicationControllerTest < ActionDispatch::IntegrationTest
def setup
@superadmin = create :user
@department_manager = create :department_manager
@social_worker = create :social_worker
@volunteer = create(:volunteer).user
end
test 'redirect user by role on sign in' do
[@superadmin, @department_manager, @social_worker, @volunteer].each do |user|
login_as user
get root_path
if user.superadmin? || user.department_manager?
assert_redirected_to volunteers_path
elsif user.social_worker?
assert_redirected_to clients_path
elsif user.volunteer?
assert_redirected_to profile_path(user)
end
end
end
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment