This commit is contained in:
Aditya Chatterjee 2016-02-27 17:03:43 +05:30
parent 28e55f3f50
commit a5a2db4077
156 changed files with 3203 additions and 1206 deletions

View file

@ -10,8 +10,20 @@ describe 'User' do
subject(:ability){ Ability.new(user) }
let(:user){ nil }
let!(:my_conference) { create(:full_conference) }
let!(:my_cfp) { create(:cfp, program: my_conference.program) }
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
let(:my_registration) { create(:registration, conference: my_conference, user: first_user) }
let(:other_registration) { create(:registration, conference: conference_public) }
let(:my_event) { create(:event_full, program: my_conference.program) }
let(:my_room) { create(:room, venue: my_conference.venue) }
let!(:my_event_scheduled) { create(:event_full, program: my_conference.program, room_id: my_room.id) }
let(:other_event) { create(:event_full, program: conference_public.program) }
let(:conference_not_public) { create(:conference, splashpage: create(:splashpage, public: false)) }
let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true), call_for_paper: create(:call_for_paper, schedule_public: true)) }
let(:conference_public) { create(:full_conference, splashpage: create(:splashpage, public: true)) }
let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) }
let(:event_confirmed) { create(:event, state: 'confirmed') }
let(:event_unconfirmed) { create(:event) }
@ -28,7 +40,11 @@ describe 'User' do
it{ should be_able_to(:show, conference_public)}
it{ should_not be_able_to(:show, conference_not_public)}
it{ should be_able_to(:schedule, conference_public)}
it do
conference_public.program.schedule_public = true
conference_public.program.save
should be_able_to(:schedule, conference_public)
end
it{ should_not be_able_to(:schedule, conference_not_public)}
it{ should be_able_to(:show, event_confirmed)}
@ -57,10 +73,8 @@ describe 'User' do
let(:registration_public) { create(:registration, conference: conference_public, user: user) }
let(:registration_not_public) { create(:registration, conference: conference_not_public, user: user) }
let(:my_event) { create(:event, users: [user]) }
let(:commercial) { create(:commercial, commercialable: event_unconfirmed) }
let(:my_commercial) { create(:commercial, commercialable: my_event) }
let(:user_event) { create(:event, users: [user]) }
let(:user_commercial) { create(:commercial, commercialable: user_event) }
it{ should be_able_to(:manage, user) }
@ -74,27 +88,39 @@ describe 'User' do
it{ should be_able_to(:destroy, subscription) }
it{ should be_able_to(:create, Event) }
it{ should be_able_to(:manage, my_event) }
it{ should be_able_to(:manage, user_event) }
it{ should_not be_able_to(:manage, event_unconfirmed) }
it{ should be_able_to(:create, my_event.commercials.new) }
it{ should be_able_to(:manage, my_commercial) }
it{ should_not be_able_to(:manage, commercial) }
it{ should be_able_to(:create, user_event.commercials.new) }
it{ should be_able_to(:manage, user_commercial) }
it{ should_not be_able_to(:manage, commercial_event_unconfirmed) }
end
context 'user #is_admin?' do
let(:venue) { my_conference.venue }
let(:room) { create(:room, venue: venue) }
let!(:event) { create(:event_full, program: my_conference.program, room_id: room.id) }
let(:user) { create(:admin) }
it{ should be_able_to(:manage, :all) }
it{ should_not be_able_to(:destroy, my_conference.program) }
it{ should_not be_able_to(:destroy, my_venue) }
end
context 'when user has the role organizer' do
let!(:my_conference) { create(:full_conference) }
let(:role) { create(:organizer_role, resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
let(:registration) { create(:registration, conference: my_conference) }
let(:other_registration) { create(:registration, conference: conference_public) }
let(:event) { create(:event_full, conference: my_conference) }
let(:other_event) { create(:event_full, conference: conference_public) }
it{ should_not be_able_to(:destroy, my_conference.program) }
it 'when there is a room assigned to an event' do
should_not be_able_to(:destroy, my_venue)
end
it 'when there are no rooms used' do
my_event_scheduled.room_id = nil
my_event_scheduled.save!
my_event_scheduled.reload
should be_able_to(:destroy, my_venue)
end
it{ should be_able_to([:create, :new], Conference) }
it{ should be_able_to(:manage, my_conference) }
@ -115,8 +141,8 @@ describe 'User' do
it{ should_not be_able_to(:manage, conference_public.registration_period) }
it{ should be_able_to(:manage, my_conference.questions.first) }
it{ should_not be_able_to(:manage, conference_public.questions.first) }
it{ should be_able_to(:manage, my_conference.call_for_paper) }
it{ should_not be_able_to(:manage, conference_public.call_for_paper) }
it{ should be_able_to(:manage, my_conference.program.cfp) }
it{ should_not be_able_to(:manage, conference_public.program.cfp) }
it{ should be_able_to(:manage, my_conference.venue) }
it{ should_not be_able_to(:manage, conference_public.venue) }
it{ should be_able_to(:manage, my_conference.lodgings.first) }
@ -128,31 +154,26 @@ describe 'User' do
it{ should be_able_to(:manage, my_conference.tickets.first) }
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
it{ should be_able_to(:manage, registration) }
it{ should be_able_to(:manage, my_registration) }
it{ should_not be_able_to(:manage, other_registration) }
it{ should be_able_to(:manage, event) }
it{ should be_able_to(:manage, my_event) }
it{ should_not be_able_to(:manage, other_event) }
it{ should be_able_to(:manage, event.event_type) }
it{ should be_able_to(:manage, my_event.event_type) }
it{ should_not be_able_to(:manage, other_event.event_type) }
it{ should be_able_to(:manage, event.track) }
it{ should be_able_to(:manage, my_event.track) }
it{ should_not be_able_to(:manage, other_event.track) }
it{ should be_able_to(:manage, event.difficulty_level) }
it{ should be_able_to(:manage, my_event.difficulty_level) }
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should be_able_to(:manage, event.commercials.first) }
it{ should be_able_to(:manage, my_event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should be_able_to(:index, event.comment_threads.first) }
it{ should be_able_to(:index, my_event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role cfp' do
let!(:my_conference) { create(:full_conference) }
let(:role) { create(:cfp_role, resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
let(:registration) { create(:registration, conference: my_conference) }
let(:other_registration) { create(:registration, conference: conference_public) }
let(:event) { create(:event_full, conference: my_conference) }
let(:other_event) { create(:event_full, conference: conference_public) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -173,10 +194,10 @@ describe 'User' do
it{ should_not be_able_to(:manage, conference_public.registration_period) }
it{ should_not be_able_to(:manage, my_conference.questions.first) }
it{ should_not be_able_to(:manage, conference_public.questions.first) }
it{ should be_able_to(:manage, my_conference.call_for_paper) }
it{ should_not be_able_to(:manage, conference_public.call_for_paper) }
it{ should be_able_to(:manage, my_conference.program.cfp) }
it{ should_not be_able_to(:manage, conference_public.program.cfp) }
it{ should_not be_able_to(:manage, my_conference.venue) }
it{ should be_able_to(:index, my_conference.venue) }
it{ should be_able_to(:show, my_conference.venue) }
it{ should_not be_able_to(:manage, conference_public.venue) }
it{ should_not be_able_to(:manage, my_conference.lodgings.first) }
it{ should_not be_able_to(:manage, conference_public.lodgings.first) }
@ -187,31 +208,26 @@ describe 'User' do
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
it{ should_not be_able_to(:manage, registration) }
it{ should_not be_able_to(:manage, my_registration) }
it{ should_not be_able_to(:manage, other_registration) }
it{ should be_able_to(:manage, event) }
it{ should be_able_to(:manage, my_event) }
it{ should_not be_able_to(:manage, other_event) }
it{ should be_able_to(:manage, event.event_type) }
it{ should be_able_to(:manage, my_event.event_type) }
it{ should_not be_able_to(:manage, other_event.event_type) }
it{ should be_able_to(:manage, event.track) }
it{ should be_able_to(:manage, my_event.track) }
it{ should_not be_able_to(:manage, other_event.track) }
it{ should be_able_to(:manage, event.difficulty_level) }
it{ should be_able_to(:manage, my_event.difficulty_level) }
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should be_able_to(:manage, event.commercials.first) }
it{ should be_able_to(:manage, my_event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should be_able_to(:index, event.comment_threads.first) }
it{ should be_able_to(:index, my_event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role info_desk' do
let!(:my_conference) { create(:full_conference) }
let(:role) { create(:info_desk_role, resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
let(:registration) { create(:registration, conference: my_conference) }
let(:other_registration) { create(:registration, conference: conference_public) }
let(:event) { create(:event_full, conference: my_conference) }
let(:other_event) { create(:event_full, conference: conference_public) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -232,10 +248,10 @@ describe 'User' do
it{ should_not be_able_to(:manage, conference_public.registration_period) }
it{ should be_able_to(:manage, my_conference.questions.first) }
it{ should_not be_able_to(:manage, conference_public.questions.first) }
it{ should_not be_able_to(:manage, my_conference.call_for_paper) }
it{ should_not be_able_to(:manage, conference_public.call_for_paper) }
it{ should_not be_able_to(:manage, my_conference.program.cfp) }
it{ should_not be_able_to(:manage, conference_public.program.cfp) }
it{ should_not be_able_to(:manage, my_conference.venue) }
it{ should_not be_able_to(:index, my_conference.venue) }
it{ should_not be_able_to(:show, my_conference.venue) }
it{ should_not be_able_to(:manage, conference_public.venue) }
it{ should_not be_able_to(:manage, my_conference.lodgings.first) }
it{ should_not be_able_to(:manage, conference_public.lodgings.first) }
@ -246,31 +262,26 @@ describe 'User' do
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
it{ should be_able_to(:manage, registration) }
it{ should be_able_to(:manage, my_registration) }
it{ should_not be_able_to(:manage, other_registration) }
it{ should_not be_able_to(:manage, event) }
it{ should_not be_able_to(:manage, my_event) }
it{ should_not be_able_to(:manage, other_event) }
it{ should_not be_able_to(:manage, event.event_type) }
it{ should_not be_able_to(:manage, my_event.event_type) }
it{ should_not be_able_to(:manage, other_event.event_type) }
it{ should_not be_able_to(:manage, event.track) }
it{ should_not be_able_to(:manage, my_event.track) }
it{ should_not be_able_to(:manage, other_event.track) }
it{ should_not be_able_to(:manage, event.difficulty_level) }
it{ should_not be_able_to(:manage, my_event.difficulty_level) }
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should_not be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, my_event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should_not be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, my_event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role volunteers_coordinator' do
let!(:my_conference) { create(:full_conference) }
let(:role) { create(:volunteers_coordinator_role, resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id], is_admin: false) }
let(:registration) { create(:registration, conference: my_conference) }
let(:other_registration) { create(:registration, conference: conference_public) }
let(:event) { create(:event_full, conference: my_conference) }
let(:other_event) { create(:event_full, conference: conference_public) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -291,10 +302,10 @@ describe 'User' do
it{ should_not be_able_to(:manage, conference_public.registration_period) }
it{ should_not be_able_to(:manage, my_conference.questions.first) }
it{ should_not be_able_to(:manage, conference_public.questions.first) }
it{ should_not be_able_to(:manage, my_conference.call_for_paper) }
it{ should_not be_able_to(:manage, conference_public.call_for_paper) }
it{ should_not be_able_to(:manage, my_conference.program.cfp) }
it{ should_not be_able_to(:manage, conference_public.program.cfp) }
it{ should_not be_able_to(:manage, my_conference.venue) }
it{ should_not be_able_to(:index, my_conference.venue) }
it{ should_not be_able_to(:show, my_conference.venue) }
it{ should_not be_able_to(:manage, conference_public.venue) }
it{ should_not be_able_to(:manage, my_conference.lodgings.first) }
it{ should_not be_able_to(:manage, conference_public.lodgings.first) }
@ -308,17 +319,17 @@ describe 'User' do
it{ should_not be_able_to(:manage, registration) }
it{ should_not be_able_to(:manage, other_registration) }
it{ should_not be_able_to(:manage, event) }
it{ should_not be_able_to(:manage, my_event) }
it{ should_not be_able_to(:manage, other_event) }
it{ should_not be_able_to(:manage, event.event_type) }
it{ should_not be_able_to(:manage, my_event.event_type) }
it{ should_not be_able_to(:manage, other_event.event_type) }
it{ should_not be_able_to(:manage, event.track) }
it{ should_not be_able_to(:manage, my_event.track) }
it{ should_not be_able_to(:manage, other_event.track) }
it{ should_not be_able_to(:manage, event.difficulty_level) }
it{ should_not be_able_to(:manage, my_event.difficulty_level) }
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should_not be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, my_event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should_not be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, my_event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
it 'should be_able to :manage Vposition'
it 'should be_able to :manage Vday'