2015-04-13 16:47:07 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature 'BaseController' do
|
|
|
|
|
let(:conference) { create(:conference) }
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
2015-01-12 23:13:10 +02:00
|
|
|
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
|
|
|
|
let!(:volunteers_coordinator_role) { Role.find_by(name: 'volunteers_coordinator', resource: conference) }
|
|
|
|
|
let!(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
|
|
|
|
let!(:info_desk_role) { Role.find_by(name: 'info_desk', resource: conference) }
|
2015-04-13 16:47:07 +02:00
|
|
|
|
|
|
|
|
describe 'GET #verify_user_admin' do
|
|
|
|
|
context 'when user is a guest' do
|
|
|
|
|
it 'redirects to sign in page' do
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
expect(current_path).to eq new_user_session_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when user is ' do
|
|
|
|
|
before(:each) do
|
|
|
|
|
sign_in(user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'not an admin it redirects to root_path' do
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
expect(current_path).to eq root_path
|
2017-06-14 20:42:50 +05:30
|
|
|
expect(flash).to eq 'You are not authorized to access this page.'
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'an admin he can access the admin area' do
|
|
|
|
|
user.is_admin = true
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
|
|
|
|
expect(current_path).to eq admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'an organizer he can access the admin area' do
|
|
|
|
|
user.role_ids = organizer_role.id
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
|
|
|
|
expect(current_path).to eq admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'a volunteers_coordinator he can access the admin area' do
|
|
|
|
|
user.role_ids = volunteers_coordinator_role.id
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
|
|
|
|
expect(current_path).to eq admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'a cfp he can access the admin area' do
|
|
|
|
|
user.role_ids = cfp_role.id
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
|
|
|
|
expect(current_path).to eq admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'an info_desk he can access the admin area' do
|
|
|
|
|
user.role_ids = info_desk_role.id
|
2016-09-14 22:42:04 -04:00
|
|
|
visit admin_conferences_path
|
|
|
|
|
expect(current_path).to eq admin_conferences_path
|
2015-04-13 16:47:07 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|