Rooms belong to venue

This commit is contained in:
Stella Rouzi 2015-11-07 11:43:36 +02:00 committed by Henne Vogelsang
parent feabbfbc99
commit f840f2b3f0
31 changed files with 221 additions and 166 deletions

View file

@ -10,6 +10,17 @@ 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)) }
let!(:conference_public_cfp) { create(:cfp, program: conference_public.program) }
@ -62,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) }
@ -79,28 +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!(:my_cfp) { create(:cfp, program: my_conference.program) }
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, program: my_conference.program) }
let(:other_event) { create(:event_full, program: conference_public.program) }
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) }
@ -134,32 +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!(:my_cfp) { create(:cfp, program: my_conference.program) }
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, program: my_conference.program) }
let(:other_event) { create(:event_full, program: conference_public.program) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -194,32 +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!(:my_cfp) { create(:cfp, program: my_conference.program) }
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, program: my_conference.program) }
let(:other_event) { create(:event_full, program: conference_public.program) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -254,32 +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!(:my_cfp) { create(:cfp, program: my_conference.program) }
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, program: my_conference.program) }
let(:other_event) { create(:event_full, program: conference_public.program) }
it{ should_not be_able_to([:create, :new], Conference.new) }
it{ should_not be_able_to(:manage, my_conference) }
@ -317,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'