Pull out shared setup to `before` block

Matt Jankowski 2024-11-14 11:40:47 -05:00
parent 766358e52b
commit 7508fc1c92
1 changed files with 2 additions and 4 deletions

View File

@ -10,8 +10,9 @@ RSpec.describe Admin::BaseController do
end end
end end
before { routes.draw { get 'success' => 'admin/base#success' } }
it 'requires administrator or moderator' do it 'requires administrator or moderator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user)) sign_in(Fabricate(:user))
get :success get :success
@ -19,7 +20,6 @@ RSpec.describe Admin::BaseController do
end end
it 'returns private cache control headers' do it 'returns private cache control headers' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator'))) sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
get :success get :success
@ -27,14 +27,12 @@ RSpec.describe Admin::BaseController do
end end
it 'renders admin layout as a moderator' do it 'renders admin layout as a moderator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator'))) sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
get :success get :success
expect(response).to render_template layout: 'admin' expect(response).to render_template layout: 'admin'
end end
it 'renders admin layout as an admin' do it 'renders admin layout as an admin' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin'))) sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin')))
get :success get :success
expect(response).to render_template layout: 'admin' expect(response).to render_template layout: 'admin'