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

@ -7,22 +7,21 @@ FactoryGirl.define do
timezone 'Amsterdam'
start_date { Date.today }
end_date { 6.days.from_now }
program
factory :full_conference do
venue
splashpage
registration_period
after(:build) do |conference|
conference.commercials << build(:conference_commercial, commercialable: conference)
conference.campaigns << build(:campaign, conference: conference)
conference.targets << build(:target, conference: conference)
conference.questions << build(:question, conference_id: conference.id)
conference.lodgings << build(:lodging, conference: conference)
conference.sponsors << build(:sponsor, conference: conference)
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
conference.tickets << build(:ticket, conference: conference)
after :create do |conference|
create(:venue, conference_id: conference.id)
conference.commercials << create(:conference_commercial, commercialable: conference)
conference.campaigns << create(:campaign, conference: conference)
conference.targets << create(:target, conference: conference)
conference.questions << create(:question, conference_id: conference.id)
conference.lodgings << create(:lodging, conference: conference)
conference.sponsors << create(:sponsor, conference: conference)
conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
conference.tickets << create(:ticket, conference: conference)
end
end
end

View file

@ -46,7 +46,10 @@ FactoryGirl.define do
event.commercials << build(:event_commercial, commercialable: event)
event.difficulty_level = build(:difficulty_level, program: event.program)
event.track = build(:track, program: event.program)
event.room = build(:room, program: event.program)
unless (venue = event.program.conference.venue)
venue = create(:venue, conference: event.program.conference)
end
event.room = build(:room, venue: venue)
event.comment_threads << build(:comment, commentable: event)
end
end

View file

@ -4,6 +4,6 @@ FactoryGirl.define do
factory :program do
schedule_public false
schedule_fluid false
# conference
conference
end
end

View file

@ -3,7 +3,7 @@ FactoryGirl.define do
factory :room do
name 'Example Room'
size 4
program
venue
factory :room_for_100 do
name 'Room for 100'

View file

@ -8,5 +8,6 @@ FactoryGirl.define do
country 'DE'
website 'www.opensuse.org'
description 'Lorem Ipsum Dolor'
conference
end
end

View file

@ -2,11 +2,11 @@ require 'spec_helper'
feature 'Has correct abilities' do
# It is necessary to use bang version of let to build roles before user
let(:conference1) { create(:conference) } # user is organizer
let(:conference2) { create(:conference) } # user is cfp
let(:conference3) { create(:conference) } # user is info_desk
let(:conference4) { create(:conference) } # user is volunteer coordinator
let(:conference5) { create(:conference) } # user has no role
let(:conference1) { create(:full_conference) } # user is organizer
let(:conference2) { create(:full_conference) } # user is cfp
let(:conference3) { create(:full_conference) } # user is info_desk
let(:conference4) { create(:full_conference) } # user is volunteer coordinator
let(:conference5) { create(:full_conference) } # user has no role
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
@ -43,7 +43,7 @@ feature 'Has correct abilities' do
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
expect(page).to have_link('Goals', href: "/admin/conference/#{conference1.short_title}/targets")
expect(page).to have_link('Venue', href: "/admin/conference/#{conference1.short_title}/venue")
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/program/rooms")
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/venue/rooms")
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels")
expect(page).to have_link('Sponsors', href: "/admin/conference/#{conference1.short_title}/sponsors")
@ -120,7 +120,7 @@ feature 'Has correct abilities' do
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference2.short_title}/targets")
expect(page).to have_link('Venue', href: "/admin/conference/#{conference2.short_title}/venue")
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/program/rooms")
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/venue/rooms")
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings")
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference2.short_title}/sponsorship_levels")
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference2.short_title}/sponsors")
@ -193,7 +193,7 @@ feature 'Has correct abilities' do
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns")
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference3.short_title}/targets")
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference3.short_title}/venue")
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/program/rooms")
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/venue/rooms")
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings")
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference3.short_title}/sponsorship_levels")
expect(page).to_not have_link('Sponsors', href: "/admin/conference/#{conference3.short_title}/sponsors")

View file

@ -2,13 +2,14 @@ require 'spec_helper'
feature Room do
let!(:conference) { create(:conference) }
let!(:venue) { create(:venue, conference: conference) }
let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'rooms' do
scenario 'adds a room', feature: true, js: true do
sign_in organizer
visit admin_conference_program_rooms_path(
visit admin_conference_venue_rooms_path(
conference_id: conference.short_title)
expect(page.has_no_table?('#rooms')).to be true
@ -30,9 +31,9 @@ feature Room do
end
scenario 'updates a room', feature: true, js: true do
room = create(:room, program_id: conference.program.id)
room = create(:room, venue: venue)
sign_in organizer
visit edit_admin_conference_program_room_path(
visit edit_admin_conference_venue_room_path(
conference_id: conference.short_title, id: room.id)
fill_in 'room_name', with: 'Auditorium'

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'

View file

@ -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)

View file

@ -4,8 +4,10 @@ describe 'admin/rooms/index' do
it 'renders rooms list' do
conference = create(:conference)
create(:room, name: 'Example Room', size: 4, program: conference.program)
venue = create(:venue, conference: conference)
room = create(:room, name: 'Example Room', size: 4, venue: venue)
assign :conference, conference
assign :rooms, [room]
render
expect(rendered).to include('Example Room')
expect(rendered).to include('4')