Rooms belong to venue
This commit is contained in:
parent
feabbfbc99
commit
f840f2b3f0
31 changed files with 221 additions and 166 deletions
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -972,7 +972,6 @@ describe Conference do
|
|||
it 'calculates correct for new conference' do
|
||||
subject.program.cfp = nil
|
||||
subject.venue = nil
|
||||
subject.program.rooms = []
|
||||
subject.program.tracks = []
|
||||
subject.program.event_types = []
|
||||
subject.program.difficulty_levels = []
|
||||
|
|
@ -1005,7 +1004,6 @@ describe Conference do
|
|||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = nil
|
||||
subject.program.rooms = []
|
||||
subject.program.tracks = []
|
||||
subject.program.event_types = []
|
||||
subject.program.difficulty_levels = []
|
||||
|
|
@ -1023,8 +1021,8 @@ describe Conference do
|
|||
start_date: Date.today,
|
||||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = create(:venue)
|
||||
subject.program.rooms = []
|
||||
subject.venue = create(:venue, conference: subject)
|
||||
subject.venue.rooms = []
|
||||
subject.program.tracks = []
|
||||
subject.program.event_types = []
|
||||
subject.program.difficulty_levels = []
|
||||
|
|
@ -1039,12 +1037,12 @@ describe Conference do
|
|||
end
|
||||
|
||||
it 'calculates correct for conference with registration, cfp, venue, rooms' do
|
||||
subject.program.rooms = [create(:room)]
|
||||
subject.registration_period = create(:registration_period,
|
||||
start_date: Date.today,
|
||||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = create(:venue)
|
||||
subject.venue = create(:venue, conference: subject)
|
||||
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||
subject.program.tracks = []
|
||||
subject.program.event_types = []
|
||||
subject.program.difficulty_levels = []
|
||||
|
|
@ -1060,13 +1058,13 @@ describe Conference do
|
|||
end
|
||||
|
||||
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
|
||||
subject.program.rooms = [create(:room)]
|
||||
subject.venue = create(:venue, conference: subject)
|
||||
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||
subject.program.tracks = [create(:track)]
|
||||
subject.registration_period = create(:registration_period,
|
||||
start_date: Date.today,
|
||||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = create(:venue)
|
||||
subject.program.event_types = []
|
||||
subject.program.difficulty_levels = []
|
||||
subject.splashpage = create(:splashpage, public: false)
|
||||
|
|
@ -1083,14 +1081,14 @@ describe Conference do
|
|||
|
||||
it 'calculates correct for conference with registration, cfp,
|
||||
venue, rooms, tracks, event_types' do
|
||||
subject.program.rooms = [create(:room)]
|
||||
subject.program.tracks = [create(:track)]
|
||||
subject.program.event_types = [create(:event_type)]
|
||||
subject.registration_period = create(:registration_period,
|
||||
start_date: Date.today,
|
||||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = create(:venue)
|
||||
subject.venue = create(:venue, conference: subject)
|
||||
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||
subject.program.difficulty_levels = []
|
||||
subject.splashpage = create(:splashpage, public: false)
|
||||
|
||||
|
|
@ -1106,7 +1104,6 @@ describe Conference do
|
|||
end
|
||||
|
||||
it 'calculates correct for conference with all mandatory options' do
|
||||
subject.program.rooms = [create(:room)]
|
||||
subject.program.tracks = [create(:track)]
|
||||
subject.program.event_types = [create(:event_type)]
|
||||
subject.program.difficulty_levels = [create(:difficulty_level)]
|
||||
|
|
@ -1114,7 +1111,8 @@ describe Conference do
|
|||
start_date: Date.today,
|
||||
end_date: Date.today + 14)
|
||||
subject.program.cfp = create(:cfp)
|
||||
subject.venue = create(:venue)
|
||||
subject.venue = create(:venue, conference: subject)
|
||||
subject.venue.rooms = [create(:room, venue: subject.venue)]
|
||||
subject.splashpage = create(:splashpage, public: true)
|
||||
|
||||
expect(subject.get_status).to eq(@result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue