minor refactoring of flash messages
This commit is contained in:
@@ -22,18 +22,13 @@ describe ApplicationController do
|
||||
end
|
||||
|
||||
describe '#render_not_authorized' do
|
||||
let(:render_not_authorized) { controller.send(:render_not_authorized) }
|
||||
|
||||
it 'displays a flash message' do
|
||||
expect(controller).to receive(:redirect_to)
|
||||
render_not_authorized
|
||||
expect(flash[:danger]).to eq(I18n.t('application.not_authorized'))
|
||||
before(:each) do
|
||||
expect(controller).to receive(:welcome) { controller.send(:render_not_authorized) }
|
||||
get :welcome
|
||||
end
|
||||
|
||||
it 'redirects to the root URL' do
|
||||
expect(controller).to receive(:redirect_to).with(:root)
|
||||
render_not_authorized
|
||||
end
|
||||
expect_flash_message(:alert, I18n.t('application.not_authorized'))
|
||||
expect_redirect(:root)
|
||||
end
|
||||
|
||||
describe '#set_locale' do
|
||||
|
@@ -118,10 +118,7 @@ describe ExecutionEnvironmentsController do
|
||||
end
|
||||
|
||||
expect_assigns(docker_images: Array)
|
||||
|
||||
it 'displays a flash message' do
|
||||
expect(flash[:warning]).to eq(error_message)
|
||||
end
|
||||
expect_flash_message(:warning, :error_message)
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -46,8 +46,7 @@ describe ExercisesController do
|
||||
end
|
||||
|
||||
expect_assigns(exercise: Exercise)
|
||||
|
||||
expect_flash_message(:danger)
|
||||
expect_flash_message(:danger, :'shared.message_failure')
|
||||
expect_redirect(:exercise)
|
||||
end
|
||||
end
|
||||
|
@@ -180,6 +180,7 @@ describe InternalUsersController do
|
||||
get :forgot_password
|
||||
end
|
||||
|
||||
expect_flash_message(:alert, :'shared.already_signed_in')
|
||||
expect_redirect(:root)
|
||||
end
|
||||
end
|
||||
|
@@ -103,25 +103,25 @@ describe SessionsController do
|
||||
end
|
||||
|
||||
context 'when LTI outcomes are supported' do
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_with_outcome', consumer: consumer) }
|
||||
|
||||
before(:each) do
|
||||
expect(controller).to receive(:lti_outcome_service?).and_return(true)
|
||||
request
|
||||
end
|
||||
|
||||
it 'displays a flash message' do
|
||||
expect(flash[:notice]).to eq(I18n.t('sessions.create_through_lti.session_with_outcome', consumer: consumer))
|
||||
end
|
||||
expect_flash_message(:notice, :message)
|
||||
end
|
||||
|
||||
context 'when LTI outcomes are not supported' do
|
||||
let(:message) { I18n.t('sessions.create_through_lti.session_without_outcome', consumer: consumer) }
|
||||
|
||||
before(:each) do
|
||||
expect(controller).to receive(:lti_outcome_service?).and_return(false)
|
||||
request
|
||||
end
|
||||
|
||||
it 'displays a flash message' do
|
||||
expect(flash[:notice]).to eq(I18n.t('sessions.create_through_lti.session_without_outcome', consumer: consumer))
|
||||
end
|
||||
expect_flash_message(:notice, :message)
|
||||
end
|
||||
|
||||
it 'redirects to the requested exercise' do
|
||||
@@ -206,6 +206,7 @@ describe SessionsController do
|
||||
get :new
|
||||
end
|
||||
|
||||
expect_flash_message(:alert, :'shared.already_signed_in')
|
||||
expect_redirect(:root)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user