Redirect users after sign in to their desired page
This commit is contained in:
@ -30,11 +30,26 @@ RSpec.describe ApplicationController do
|
||||
describe '#render_not_authorized' do
|
||||
before do
|
||||
allow(controller).to receive(:welcome) { controller.send(:render_not_authorized) }
|
||||
login_user(user) if defined?(user)
|
||||
get :welcome
|
||||
end
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
expect_flash_message(:alert, I18n.t('application.not_signed_in'))
|
||||
expect_redirect(:sign_in)
|
||||
|
||||
context 'with an admin' do
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
end
|
||||
|
||||
context 'with a teacher' do
|
||||
let(:user) { create(:teacher) }
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#render_not_found' do
|
||||
@ -44,19 +59,21 @@ RSpec.describe ApplicationController do
|
||||
get :welcome
|
||||
end
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
expect_flash_message(:alert, I18n.t('application.not_signed_in'))
|
||||
expect_redirect(:sign_in)
|
||||
|
||||
context 'with an admin' do
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_found'))
|
||||
expect_redirect(:root)
|
||||
end
|
||||
|
||||
context 'with a teacher' do
|
||||
let(:user) { create(:teacher) }
|
||||
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user