rosa-build/spec/support/shared_examples/admin_examples.rb

23 lines
551 B
Ruby
Raw Normal View History

2014-04-11 21:29:43 +01:00
shared_examples_for 'an admin controller' do
it 'redirects to login when accessed unauthorised' do
get :index
2015-04-07 20:43:40 +01:00
expect(response).to redirect_to(new_user_session_path)
2014-04-11 21:29:43 +01:00
end
it 'raises a 404 for non-admin users' do
user = User.first || FactoryGirl.create(:user)
sign_in user
get :index
2015-04-07 20:43:40 +01:00
expect(response).to render_template(file: "#{Rails.root}/public/404.html")
2014-04-11 21:29:43 +01:00
end
it 'is successful for admin users' do
user = FactoryGirl.create(:admin)
2014-04-11 21:29:43 +01:00
sign_in user
get :index
2015-04-07 20:43:40 +01:00
expect(response).to be_success
2014-04-11 21:29:43 +01:00
end
2015-04-07 20:43:40 +01:00
end