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
|
2015-02-02 20:28:22 +00:00
|
|
|
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
|