Use controller method for 404 responses

This commit is contained in:
Sebastian Serth
2022-09-14 01:01:14 +02:00
parent 006c794f54
commit f1aa004284
4 changed files with 34 additions and 1 deletions

View File

@ -35,6 +35,27 @@ describe ApplicationController do
expect_redirect(:root)
end
describe '#render_not_found' do
before do
allow(controller).to receive(:welcome) { controller.send(:render_not_found) }
login_user(user) if defined?(user)
get :welcome
end
expect_flash_message(:alert, I18n.t('application.not_authorized'))
expect_redirect(:root)
context 'with an admin' do
let(:user) { create(:admin) }
expect_flash_message(:alert, I18n.t('application.not_found'))
end
context 'with a teacher' do
let(:user) { create(:teacher) }
expect_flash_message(:alert, I18n.t('application.not_authorized'))
end
end
describe '#switch_locale' do
let(:locale) { :de }