diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 638d2ab6..85dba43d 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -8,9 +8,9 @@ module Admin return false end unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) || - (current_user.has_role? :info_desk, :any) || + (current_user.has_role? :info_desk, :any) || (current_user.has_role? :organization_admin, :any) || (current_user.has_role? :volunteers_coordinator, :any) || current_user.is_admin - raise CanCan::AccessDenied.new('You are not authorized to access this area!') + raise CanCan::AccessDenied.new('You are not authorized to access this page.') end end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6fa8c12f..5001278a 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -29,6 +29,7 @@ class Ability # Abilities for not signed in users (guests) def not_signed_in + can [:index], Organization can [:index], Conference can [:show], Conference do |conference| conference.splashpage && conference.splashpage.public == true @@ -110,6 +111,7 @@ class Ability # Abilities from not_signed_in and signed_in are also inherited signed_in(user) + signed_in_with_organization_admin_role(user) if user.has_role? :organization_admin, :any signed_in_with_organizer_role(user) if user.has_role? :organizer, :any signed_in_with_cfp_role(user) if user.has_role? :cfp, :any signed_in_with_info_desk_role(user) if user.has_role? :info_desk, :any @@ -146,57 +148,73 @@ class Ability end end - def signed_in_with_organizer_role(user) - # ids of all the conferences for which the user has the 'organizer' role - conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id) + def signed_in_with_organization_admin_role(user) + org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id) + conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id) - can :manage, Resource, conference_id: conf_ids_for_organizer - can [:new, :create], Conference if user.has_role?(:organizer, :any) - can :manage, Conference, id: conf_ids_for_organizer - can :manage, Splashpage, conference_id: conf_ids_for_organizer - can :manage, Contact, conference_id: conf_ids_for_organizer - can :manage, EmailSettings, conference_id: conf_ids_for_organizer - can :manage, Campaign, conference_id: conf_ids_for_organizer - can :manage, Target, conference_id: conf_ids_for_organizer - can :manage, Commercial, commercialable_type: 'Conference', - commercialable_id: conf_ids_for_organizer - can :manage, Registration, conference_id: conf_ids_for_organizer - can :manage, RegistrationPeriod, conference_id: conf_ids_for_organizer - can :manage, Question, conference_id: conf_ids_for_organizer - can :manage, Question do |question| - !(question.conferences.pluck(:id) & conf_ids_for_organizer).empty? + can [:read, :update, :destroy], Organization, id: org_ids_for_organization_admin + can :new, Conference + can :manage, Conference, organization_id: org_ids_for_organization_admin + can [:index, :show], Role + can [:edit, :update], Role do |role| + role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id) end - can :manage, Vposition, conference_id: conf_ids_for_organizer - can :manage, Vday, conference_id: conf_ids_for_organizer - can :manage, Program, conference_id: conf_ids_for_organizer - can :manage, Schedule, program: { conference_id: conf_ids_for_organizer } - can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids_for_organizer } } - can :manage, Cfp, program: { conference_id: conf_ids_for_organizer } - can :manage, Event, program: { conference_id: conf_ids_for_organizer} - can :manage, EventType, program: { conference_id: conf_ids_for_organizer} - can :manage, Track, program: { conference_id: conf_ids_for_organizer} - can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_organizer} + signed_in_with_organizer_role(user, conf_ids_for_organization_admin) + end + + def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = []) + # ids of all the conferences for which the user has the 'organizer' role and + # conferences that belong to organizations for which user is 'organization_admin' + conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq + can :manage, Resource, conference_id: conf_ids + can [:read, :update, :destroy], Conference, id: conf_ids + can :manage, Splashpage, conference_id: conf_ids + can :manage, Contact, conference_id: conf_ids + can :manage, EmailSettings, conference_id: conf_ids + can :manage, Campaign, conference_id: conf_ids + can :manage, Target, conference_id: conf_ids + can :manage, Commercial, commercialable_type: 'Conference', + commercialable_id: conf_ids + can :manage, Registration, conference_id: conf_ids + can :manage, RegistrationPeriod, conference_id: conf_ids + can :manage, Question, conference_id: conf_ids + can :manage, Question do |question| + !(question.conferences.pluck(:id) & conf_ids).empty? + end + can :manage, Vposition, conference_id: conf_ids + can :manage, Vday, conference_id: conf_ids + can :manage, Program, conference_id: conf_ids + can :manage, Schedule, program: { conference_id: conf_ids } + can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids } } + can :manage, Cfp, program: { conference_id: conf_ids} + can :manage, Event, program: { conference_id: conf_ids} + can :manage, EventType, program: { conference_id: conf_ids} + can :manage, Track, program: { conference_id: conf_ids} + can :manage, DifficultyLevel, program: { conference_id: conf_ids} can :manage, Commercial, commercialable_type: 'Event', - commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) - can :manage, Venue, conference_id: conf_ids_for_organizer + commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id) + can :manage, Venue, conference_id: conf_ids can :manage, Commercial, commercialable_type: 'Venue', - commercialable_id: Venue.where(conference_id: conf_ids_for_organizer).pluck(:id) - can :manage, Lodging, conference_id: conf_ids_for_organizer - can :manage, Room, venue: { conference_id: conf_ids_for_organizer} - can :manage, Sponsor, conference_id: conf_ids_for_organizer - can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer - can :manage, Ticket, conference_id: conf_ids_for_organizer + commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id) + can :manage, Lodging, conference_id: conf_ids + can :manage, Room, venue: { conference_id: conf_ids} + can :manage, Sponsor, conference_id: conf_ids + can :manage, SponsorshipLevel, conference_id: conf_ids + can :manage, Ticket, conference_id: conf_ids can :index, Comment, commentable_type: 'Event', - commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) + commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id) # Abilities for Role (Conference resource) - can [:index, :show], Role + can [:index, :show], Role do |role| + role.resource_type == 'Conference' + end + can [:edit, :update, :toggle_user], Role do |role| - role.resource_type == 'Conference' && (conf_ids_for_organizer.include? role.resource_id) + role.resource_type == 'Conference' && (conf_ids.include? role.resource_id) end can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version| - version.item_type == 'User' || (conf_ids_for_organizer.include? version.conference_id) + version.item_type == 'User' || (conf_ids.include? version.conference_id) end end @@ -222,8 +240,9 @@ class Ability commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) # Abilities for Role (Conference resource) - can [:index, :show], Role - + can [:index, :show], Role do |role| + role.resource_type == 'Conference' + end # Can add or remove users from role, when user has that same role for the conference # Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP') can :toggle_user, Role do |role| @@ -251,8 +270,9 @@ class Ability end # Abilities for Role (Conference resource) - can [:index, :show], Role - + can [:index, :show], Role do |role| + role.resource_type == 'Conference' + end # Can add or remove users from role, when user has that same role for the conference # Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP') can :toggle_user, Role do |role| @@ -270,8 +290,9 @@ class Ability can :manage, Vday, conference_id: conf_ids_for_volunteers_coordinator # Abilities for Role (Conference resource) - can [:index, :show], Role - + can [:index, :show], Role do |role| + role.resource_type == 'Conference' + end # Can add or remove users from role, when user has that same role for the conference # Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP') can :toggle_user, Role do |role| diff --git a/app/models/organization.rb b/app/models/organization.rb index 60a83fef..de3d4f94 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,7 +1,17 @@ class Organization < ActiveRecord::Base + resourcify :roles, dependent: :delete_all + has_many :conferences, dependent: :destroy + after_create :create_roles + validates :name, presence: true mount_uploader :picture, PictureUploader, mount_on: :picture + + private + + def create_roles + roles.where(name: 'organization_admin').first_or_create(description: 'For the administrators of an organization and its conferences') + end end diff --git a/app/views/admin/registration_periods/show.html.haml b/app/views/admin/registration_periods/show.html.haml index 9ef02e37..057a7a37 100644 --- a/app/views/admin/registration_periods/show.html.haml +++ b/app/views/admin/registration_periods/show.html.haml @@ -25,5 +25,5 @@ = link_to 'Delete', admin_conference_registration_period_path, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' - else - - if can? :create, @conference + - if can? :create, @conference.build_registration_period = link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary' diff --git a/app/views/admin/splashpages/show.html.haml b/app/views/admin/splashpages/show.html.haml index 0c6be8a8..b4e5f24c 100644 --- a/app/views/admin/splashpages/show.html.haml +++ b/app/views/admin/splashpages/show.html.haml @@ -90,5 +90,5 @@ - else .row .col-md-12.text-right - - if can? :create, @conference + - if can? :create, @conference.build_splashpage = link_to 'Create Splashpage', new_admin_conference_splashpage_path, class: 'btn btn-primary' diff --git a/lib/tasks/roles.rake b/lib/tasks/roles.rake index 8c817db0..c29d0e24 100644 --- a/lib/tasks/roles.rake +++ b/lib/tasks/roles.rake @@ -2,6 +2,10 @@ namespace :roles do desc 'Adds back deleted roles to all conferences' task add: :environment do + Organization.all.each do |org| + Role.where(name: 'organization_admin', resource: org).first_or_create(description: 'For the administrators of an organization and its conferences') + end + Conference.all.each do |c| Role.where(name: 'organizer', resource: c).first_or_create(description: 'For the organizers of the conference (who shall have full access)') Role.where(name: 'cfp', resource: c).first_or_create(description: 'For the members of the CfP team') diff --git a/spec/controllers/admin/comments_controller_spec.rb b/spec/controllers/admin/comments_controller_spec.rb index 5429dabd..23b6b88a 100644 --- a/spec/controllers/admin/comments_controller_spec.rb +++ b/spec/controllers/admin/comments_controller_spec.rb @@ -51,7 +51,7 @@ describe Admin::CommentsController, type: :controller do comment get :index expect(response).to redirect_to(root_path) - expect(flash[:alert]).to match('You are not authorized to access this area!') + expect(flash[:alert]).to match('You are not authorized to access this page.') end end end diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 74acbb3f..009e40ba 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -3,19 +3,18 @@ require 'spec_helper' describe Admin::ConferencesController do # It is necessary to use bang version of let to build roles before user - let(:conference) { create(:conference, end_date: Date.new(2014, 05, 26) + 15) } + let!(:organization) { create(:organization, name: 'organization') } + let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) } let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) } - + let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } + let(:organization_admin) { create(:user, role_ids: organization_admin_role.id) } let(:organizer) { create(:user, role_ids: organizer_role.id) } let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) } let(:participant) { create(:user) } - shared_examples 'access as organizer' do - + shared_examples 'access as organizer or organization_admin' do describe 'PATCH #update' do - context 'valid attributes' do - it 'locates the requested conference' do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con') expect(assigns(:conference)).to eq(conference) @@ -25,7 +24,6 @@ describe Admin::ConferencesController do patch :update, id: conference.short_title, conference: attributes_for(:conference, title: 'Example Con', short_title: 'ExCon') - conference.reload expect(conference.title).to eq('Example Con') expect(conference.short_title).to eq('ExCon') @@ -75,72 +73,6 @@ describe Admin::ConferencesController do end end - describe 'POST #create' do - context 'with valid attributes' do - it 'saves the conference to the database' do - expected = expect do - post :create, conference: - attributes_for(:conference, short_title: 'dps15') - end - expected.to change { Conference.count }.by 1 - end - - it 'redirects to conference#show' do - post :create, conference: - attributes_for(:conference, short_title: 'dps15') - - expect(response).to redirect_to admin_conference_path( - assigns[:conference].short_title) - end - - it 'creates roles for the conference' do - cfp_role = Role.find_by(name: 'cfp', resource: conference) - info_desk_role = Role.find_by(name: 'info_desk', resource: conference) - volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference) - - post :create, conference: - attributes_for(:conference, short_title: 'dps15') - - expect(conference.roles.count).to eq 4 - - expect(conference.roles).to eq [organizer_role, cfp_role, info_desk_role, volunteers_coordinator_role] - end - end - - context 'with invalid attributes' do - it 'does not save the conference to the database' do - expected = expect do - post :create, conference: - attributes_for(:conference, short_title: nil) - end - expected.to_not change { Conference.count } - end - - it 're-renders the new template' do - post :create, conference: - attributes_for(:conference, short_title: nil) - expect(response).to be_success - end - end - - context 'with duplicate conference short title' do - it 'does not save the conference to the database' do - conference - expected = expect do - post :create, conference: - attributes_for(:conference, short_title: conference.short_title) - end - expected.to_not change { Conference.count } - end - - it 're-renders the new template' do - conference - post :create, conference: attributes_for(:conference, short_title: conference.short_title) - expect(response).to be_success - end - end - end - describe 'GET #edit' do it 'assigns the requested conference to conference' do get :edit, id: conference.short_title @@ -203,6 +135,74 @@ describe Admin::ConferencesController do end end end + end + + shared_examples 'access as organization_admin' do + describe 'POST #create' do + context 'with valid attributes' do + it 'saves the conference to the database' do + expected = expect do + post :create, conference: + attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) + end + expected.to change { Conference.count }.by 1 + end + + it 'redirects to conference#show' do + post :create, conference: + attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) + + expect(response).to redirect_to admin_conference_path( + assigns[:conference].short_title) + end + + it 'creates roles for the conference' do + cfp_role = Role.find_by(name: 'cfp', resource: conference) + info_desk_role = Role.find_by(name: 'info_desk', resource: conference) + volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference) + + post :create, conference: + attributes_for(:conference, short_title: 'dps15') + + expect(conference.roles.count).to eq 4 + + expect(conference.roles).to eq [organizer_role, cfp_role, info_desk_role, volunteers_coordinator_role] + end + end + + context 'with invalid attributes' do + it 'does not save the conference to the database' do + expected = expect do + post :create, conference: + attributes_for(:conference, short_title: nil, organization_id: organization.id) + end + expected.to_not change { Conference.count } + end + + it 're-renders the new template' do + post :create, conference: + attributes_for(:conference, short_title: nil, organization_id: organization.id) + expect(response).to be_success + end + end + + context 'with duplicate conference short title' do + it 'does not save the conference to the database' do + conference + expected = expect do + post :create, conference: + attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) + end + expected.to_not change { Conference.count } + end + + it 're-renders the new template' do + conference + post :create, conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) + expect(response).to be_success + end + end + end describe 'GET #new' do it 'assigns a new conference to conference' do @@ -217,14 +217,45 @@ describe Admin::ConferencesController do end end - describe 'organizer access' do + describe 'organization admin access' do + before do + sign_in(organization_admin) + end + it_behaves_like 'access as organizer or organization_admin' + it_behaves_like 'access as organization_admin' + end + + shared_examples 'access as organizer, participant or guest' do |path, message| + describe 'GET #new' do + it 'requires organizer privileges' do + get :new + expect(response).to redirect_to(send(path)) + if message + expect(flash[:alert]).to match(/#{message}/) + end + end + end + + describe 'POST #create' do + it 'requires organizer privileges' do + post :create, conference: attributes_for(:conference, + short_title: 'ExCon', organization_id: organization.id) + expect(response).to redirect_to(send(path)) + if message + expect(flash[:alert]).to match(/#{message}/) + end + end + end + end + + describe 'organizer access' do before do sign_in(organizer) end - it_behaves_like 'access as organizer' - + it_behaves_like 'access as organizer or organization_admin' + it_behaves_like 'access as organizer, participant or guest', :root_path, 'You are not authorized to access this page.' end shared_examples 'access as participant or guest' do |path, message| @@ -248,27 +279,6 @@ describe Admin::ConferencesController do end end - describe 'GET #new' do - it 'requires organizer privileges' do - get :new - expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end - end - end - - describe 'POST #create' do - it 'requires organizer privileges' do - post :create, conference: attributes_for(:conference, - short_title: 'ExCon') - expect(response).to redirect_to(send(path)) - if message - expect(flash[:alert]).to match(/#{message}/) - end - end - end - describe 'PATCH #update' do it 'requires organizer privileges' do patch :update, id: conference.short_title, @@ -287,13 +297,13 @@ describe Admin::ConferencesController do sign_in(participant) end - it_behaves_like 'access as participant or guest', :root_path, 'You are not authorized to access this area!' - + it_behaves_like 'access as participant or guest', :root_path, 'You are not authorized to access this page.' + it_behaves_like 'access as organizer, participant or guest', :root_path, 'You are not authorized to access this page.' end describe 'guest access' do it_behaves_like 'access as participant or guest', :new_user_session_path - + it_behaves_like 'access as organizer, participant or guest', :new_user_session_path end end diff --git a/spec/controllers/admin/organizations_controller_spec.rb b/spec/controllers/admin/organizations_controller_spec.rb index a4afc994..abe5005b 100644 --- a/spec/controllers/admin/organizations_controller_spec.rb +++ b/spec/controllers/admin/organizations_controller_spec.rb @@ -16,7 +16,7 @@ describe Admin::OrganizationsController do end it 'redirects to root' do - expect(flash[:alert]).to eq('You are not authorized to access this area!') + expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end end @@ -27,7 +27,7 @@ describe Admin::OrganizationsController do end it 'redirects to root' do - expect(flash[:alert]).to eq('You are not authorized to access this area!') + expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end end @@ -43,7 +43,7 @@ describe Admin::OrganizationsController do it 'redirects to root' do post :create, organization: attributes_for(:organization) - expect(flash[:alert]).to eq('You are not authorized to access this area!') + expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end end @@ -55,7 +55,7 @@ describe Admin::OrganizationsController do organization.reload expect(organization.name).to eq(old_name) - expect(flash[:alert]).to eq('You are not authorized to access this area!') + expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end end @@ -72,7 +72,7 @@ describe Admin::OrganizationsController do it 'redirects to root' do delete :destroy, id: organization.id - expect(flash[:alert]).to eq('You are not authorized to access this area!') + expect(flash[:alert]).to eq('You are not authorized to access this page.') expect(response).to redirect_to(root_path) end end diff --git a/spec/features/ability_spec.rb b/spec/features/ability_spec.rb deleted file mode 100644 index fe3a3c36..00000000 --- a/spec/features/ability_spec.rb +++ /dev/null @@ -1,677 +0,0 @@ -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(:full_conference) } # user is organizer - let(:conference2) { create(:full_conference) } # user is cfp - let(:conference3) { create(:full_conference) } # user is info_desk - let(:conference6) { create(:conference) } # user is organizer, venue is not set by default - - let(:role_organizer_conf1) { Role.find_by(name: 'organizer', resource: conference1) } - let(:role_organizer_conf6) { Role.find_by(name: 'organizer', resource: conference6) } - let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference2) } - let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference3) } - - let(:user) { create(:user) } - let(:user_organizer) { create(:user, role_ids: [role_organizer_conf1.id, role_organizer_conf6.id]) } - let(:user_cfp) { create(:user, role_ids: [role_cfp.id]) } - let(:user_info_desk) { create(:user, role_ids: [role_info_desk.id]) } - - scenario 'when user has no role' do - sign_in user - - visit admin_conference_path(conference1.short_title) - expect(current_path).to eq root_path - expect(flash).to eq 'You are not authorized to access this area!' - end - - scenario 'when user is organizer' do - sign_in user_organizer - - visit admin_conference_path(conference1.short_title) - expect(current_path).to eq(admin_conference_path(conference1.short_title)) - - expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') - expect(page).to have_link('Basics', href: "/admin/conferences/#{conference1.short_title}/edit") - expect(page).to have_link('Contact', href: "/admin/conferences/#{conference1.short_title}/contact/edit") - expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference1.short_title}/commercials") - expect(page).to have_link('Splashpage', href: "/admin/conferences/#{conference1.short_title}/splashpage") - expect(page).to have_link('Venue', href: "/admin/conferences/#{conference1.short_title}/venue") - expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference1.short_title}/venue/rooms") - expect(page).to have_link('Lodgings', href: "/admin/conferences/#{conference1.short_title}/lodgings") - expect(page).to have_link('Program', href: "/admin/conferences/#{conference1.short_title}/program") - expect(page).to have_link('Call for Papers', href: "/admin/conferences/#{conference1.short_title}/program/cfps") - expect(page).to have_link('Events', href: "/admin/conferences/#{conference1.short_title}/program/events") - expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference1.short_title}/program/tracks") - expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference1.short_title}/program/event_types") - expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference1.short_title}/program/difficulty_levels") - expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference1.short_title}/schedules") - expect(page).to have_link('Reports', href: "/admin/conferences/#{conference1.short_title}/program/reports") - expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference1.short_title}/registrations") - expect(page).to have_link('Registration Period', href: "/admin/conferences/#{conference1.short_title}/registration_period") - expect(page).to have_link('Questions', href: "/admin/conferences/#{conference1.short_title}/questions") - expect(page).to have_text('Donations') - expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference1.short_title}/sponsorship_levels") - expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference1.short_title}/sponsors") - expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference1.short_title}/tickets") - expect(page).to have_text('Objectives') - expect(page).to have_link('Campaigns', href: "/admin/conferences/#{conference1.short_title}/campaigns") - expect(page).to have_link('Goals', href: "/admin/conferences/#{conference1.short_title}/targets") - expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference1.short_title}/emails") - expect(page).to have_link('Roles', href: "/admin/conferences/#{conference1.short_title}/roles") - expect(page).to have_link('Resources', href: "/admin/conferences/#{conference1.short_title}/resources") - - visit admin_conference_path(conference6.short_title) - expect(page).to have_link('Add venue', href: "/admin/conferences/#{conference6.short_title}/venue/new") - - visit edit_admin_conference_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_path(conference1.short_title)) - - visit edit_admin_conference_contact_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_contact_path(conference1.short_title)) - - visit admin_conference_commercials_path(conference1.short_title) - expect(current_path).to eq(admin_conference_commercials_path(conference1.short_title)) - - visit new_admin_conference_splashpage_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_splashpage_path(conference1.short_title)) - - visit edit_admin_conference_splashpage_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_splashpage_path(conference1.short_title)) - - visit new_admin_conference_venue_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_venue_path(conference1.short_title)) - - conference1.venue = create(:venue) - visit edit_admin_conference_venue_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_venue_path(conference1.short_title)) - - visit admin_conference_venue_rooms_path(conference1.short_title) - expect(current_path).to eq(admin_conference_venue_rooms_path(conference1.short_title)) - - create(:room, venue: conference1.venue) - visit edit_admin_conference_venue_room_path(conference1.short_title, conference1.venue.rooms.first) - expect(current_path).to eq(edit_admin_conference_venue_room_path(conference1.short_title, conference1.venue.rooms.first)) - - visit admin_conference_lodgings_path(conference1.short_title) - expect(current_path).to eq(admin_conference_lodgings_path(conference1.short_title)) - - visit new_admin_conference_lodging_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_lodging_path(conference1.short_title)) - - create(:lodging, conference: conference1) - visit edit_admin_conference_lodging_path(conference1.short_title, conference1.lodgings.first) - expect(current_path).to eq(edit_admin_conference_lodging_path(conference1.short_title, conference1.lodgings.first)) - - visit new_admin_conference_program_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_program_path(conference1.short_title)) - - visit edit_admin_conference_program_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_program_path(conference1.short_title)) - - visit new_admin_conference_program_cfp_path(conference1.short_title) - expect(current_path).to eq root_path - - conference1.program.cfp.destroy! - visit new_admin_conference_program_cfp_path(conference1.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference1.short_title) - create(:cfp, program: conference1.program) - - visit edit_admin_conference_program_cfp_path(conference1.short_title, conference1.program.cfp) - expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference1.short_title, conference1.program.cfp)) - - visit admin_conference_program_events_path(conference1.short_title) - expect(current_path).to eq(admin_conference_program_events_path(conference1.short_title)) - - create(:event, program: conference1.program) - visit edit_admin_conference_program_event_path(conference1.short_title, conference1.program.events.first) - expect(current_path).to eq(edit_admin_conference_program_event_path(conference1.short_title, conference1.program.events.first)) - - visit admin_conference_program_event_types_path(conference1.short_title) - expect(current_path).to eq(admin_conference_program_event_types_path(conference1.short_title)) - - visit new_admin_conference_program_event_type_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_program_event_type_path(conference1.short_title)) - - visit edit_admin_conference_program_event_type_path(conference1.short_title, conference1.program.event_types.first) - expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference1.short_title, conference1.program.event_types.first)) - - visit admin_conference_program_difficulty_levels_path(conference1.short_title) - expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference1.short_title)) - - visit new_admin_conference_program_difficulty_level_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference1.short_title)) - - visit edit_admin_conference_program_difficulty_level_path(conference1.short_title, conference1.program.difficulty_levels.first) - expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference1.short_title, conference1.program.difficulty_levels.first)) - - visit admin_conference_schedules_path(conference1.short_title) - expect(current_path).to eq(admin_conference_schedules_path(conference1.short_title)) - - create(:schedule, program: conference1.program) - visit admin_conference_schedule_path(conference1.short_title, conference1.program.schedules.first) - expect(current_path).to eq(admin_conference_schedule_path(conference1.short_title, conference1.program.schedules.first)) - - visit admin_conference_program_reports_path(conference1.short_title) - expect(current_path).to eq(admin_conference_program_reports_path(conference1.short_title)) - - visit admin_conference_registrations_path(conference1.short_title) - expect(current_path).to eq(admin_conference_registrations_path(conference1.short_title)) - - create(:registration, user: create(:user), conference: conference1) - visit edit_admin_conference_registration_path(conference1.short_title, conference1.registrations.first) - expect(current_path).to eq(edit_admin_conference_registration_path(conference1.short_title, conference1.registrations.first)) - - visit new_admin_conference_registration_period_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_registration_period_path(conference1.short_title)) - - create(:registration_period, conference: conference1) - visit edit_admin_conference_registration_period_path(conference1.short_title) - expect(current_path).to eq(edit_admin_conference_registration_period_path(conference1.short_title)) - - visit admin_conference_questions_path(conference1.short_title) - expect(current_path).to eq(admin_conference_questions_path(conference1.short_title)) - - visit admin_conference_sponsorship_levels_path(conference1.short_title) - expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference1.short_title)) - - visit new_admin_conference_sponsorship_level_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_sponsorship_level_path(conference1.short_title)) - - create(:sponsorship_level, conference: conference1) - visit edit_admin_conference_sponsorship_level_path(conference1.short_title, conference1.sponsorship_levels.first) - expect(current_path).to eq(edit_admin_conference_sponsorship_level_path(conference1.short_title, conference1.sponsorship_levels.first)) - - visit admin_conference_sponsors_path(conference1.short_title) - expect(current_path).to eq(admin_conference_sponsors_path(conference1.short_title)) - - visit new_admin_conference_sponsor_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_sponsor_path(conference1.short_title)) - - create(:sponsor, conference: conference1, sponsorship_level: conference1.sponsorship_levels.first) - visit edit_admin_conference_sponsor_path(conference1.short_title, conference1.sponsors.first) - expect(current_path).to eq(edit_admin_conference_sponsor_path(conference1.short_title, conference1.sponsors.first)) - - visit admin_conference_tickets_path(conference1.short_title) - expect(current_path).to eq(admin_conference_tickets_path(conference1.short_title)) - - visit new_admin_conference_ticket_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_ticket_path(conference1.short_title)) - - create(:ticket, conference: conference1) - visit edit_admin_conference_ticket_path(conference1.short_title, conference1.tickets.first) - expect(current_path).to eq(edit_admin_conference_ticket_path(conference1.short_title, conference1.tickets.first)) - - visit admin_conference_campaigns_path(conference1.short_title) - expect(current_path).to eq(admin_conference_campaigns_path(conference1.short_title)) - - visit new_admin_conference_campaign_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_campaign_path(conference1.short_title)) - - create(:campaign, conference: conference1) - visit edit_admin_conference_campaign_path(conference1.short_title, conference1.campaigns.first) - expect(current_path).to eq(edit_admin_conference_campaign_path(conference1.short_title, conference1.campaigns.first)) - - visit admin_conference_targets_path(conference1.short_title) - expect(current_path).to eq(admin_conference_targets_path(conference1.short_title)) - - visit new_admin_conference_target_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_target_path(conference1.short_title)) - - create(:target, conference: conference1) - visit edit_admin_conference_target_path(conference1.short_title, conference1.targets.first) - expect(current_path).to eq(edit_admin_conference_target_path(conference1.short_title, conference1.targets.first)) - - visit admin_conference_program_tracks_path(conference1.short_title) - expect(current_path).to eq(admin_conference_program_tracks_path(conference1.short_title)) - - visit admin_conference_roles_path(conference1.short_title) - expect(current_path).to eq(admin_conference_roles_path(conference1.short_title)) - - visit admin_conference_emails_path(conference1.short_title) - expect(current_path).to eq(admin_conference_emails_path(conference1.short_title)) - - visit admin_conference_resources_path(conference1.short_title) - expect(current_path).to eq(admin_conference_resources_path(conference1.short_title)) - - visit new_admin_conference_resource_path(conference1.short_title) - expect(current_path).to eq(new_admin_conference_resource_path(conference1.short_title)) - - create(:resource, conference: conference1) - visit edit_admin_conference_resource_path(conference1.short_title, conference1.resources.first) - expect(current_path).to eq(edit_admin_conference_resource_path(conference1.short_title, conference1.resources.first)) - - visit admin_revision_history_path - expect(current_path).to eq(admin_revision_history_path) - end - - scenario 'when user is cfp' do - sign_in user_cfp - - visit admin_conference_path(conference2.short_title) - expect(current_path).to eq(admin_conference_path(conference2.short_title)) - - expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') - expect(page).to_not have_link('Basics', href: "/admin/conferences/#{conference2.short_title}/edit") - expect(page).to have_text('Basics') - expect(page).to_not have_link('Contact', href: "/admin/conferences/#{conference2.short_title}/contact/edit") - expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference2.short_title}/commercials") - expect(page).to_not have_link('Splashpage', href: "/admin/conferences/#{conference2.short_title}/splashpage") - expect(page).to have_link('Venue', href: "/admin/conferences/#{conference2.short_title}/venue") - expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference2.short_title}/venue/rooms") - expect(page).to_not have_link('Lodgings', href: "/admin/conferences/#{conference2.short_title}/lodgings") - expect(page).to have_link('Program', href: "/admin/conferences/#{conference2.short_title}/program") - expect(page).to have_link('Call for Papers', href: "/admin/conferences/#{conference2.short_title}/program/cfps") - expect(page).to have_link('Events', href: "/admin/conferences/#{conference2.short_title}/program/events") - expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference2.short_title}/program/tracks") - expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference2.short_title}/program/event_types") - expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference2.short_title}/program/difficulty_levels") - expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference2.short_title}/schedules") - expect(page).to have_link('Reports', href: "/admin/conferences/#{conference2.short_title}/program/reports") - expect(page).to_not have_link('Registrations', href: "/admin/conferences/#{conference2.short_title}/registrations") - expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference2.short_title}/registration_period") - expect(page).to_not have_link('Questions', href: "/admin/conferences/#{conference2.short_title}/questions") - expect(page).to_not have_text('Donations') - expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference2.short_title}/supporter_levels") - expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference2.short_title}/sponsors") - expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference2.short_title}/tickets") - expect(page).to_not have_text('Objectives') - expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference2.short_title}/campaigns") - expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference2.short_title}/targets") - expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference2.short_title}/emails") - expect(page).to have_link('Roles', href: "/admin/conferences/#{conference2.short_title}/roles") - expect(page).to have_link('Resources', href: "/admin/conferences/#{conference2.short_title}/resources") - - visit edit_admin_conference_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_contact_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_commercials_path(conference2.short_title) - expect(current_path).to eq(admin_conference_commercials_path(conference2.short_title)) - - visit new_admin_conference_splashpage_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_splashpage_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_venue_path(conference2.short_title) - expect(current_path).to eq(root_path) - - conference2.venue = create(:venue) - visit edit_admin_conference_venue_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_venue_rooms_path(conference2.short_title) - expect(current_path).to eq(admin_conference_venue_rooms_path(conference2.short_title)) - create(:room, venue: conference2.venue) - visit edit_admin_conference_venue_room_path(conference2.short_title, conference2.venue.rooms.first) - expect(current_path).to eq(edit_admin_conference_venue_room_path(conference2.short_title, conference2.venue.rooms.first)) - - visit admin_conference_lodgings_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_lodging_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:lodging, conference: conference2) - visit edit_admin_conference_lodging_path(conference2.short_title, conference2.lodgings.first) - expect(current_path).to eq(root_path) - - visit new_admin_conference_program_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_program_path(conference2.short_title)) - - visit edit_admin_conference_program_path(conference2.short_title) - expect(current_path).to eq(edit_admin_conference_program_path(conference2.short_title)) - - visit new_admin_conference_program_cfp_path(conference2.short_title) - expect(current_path).to eq root_path - - conference2.program.cfp.destroy! - visit new_admin_conference_program_cfp_path(conference2.short_title) - expect(current_path).to eq new_admin_conference_program_cfp_path(conference2.short_title) - create(:cfp, program: conference2.program) - - visit edit_admin_conference_program_cfp_path(conference2.short_title, conference2.program.cfp) - expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference2.short_title, conference2.program.cfp)) - - visit admin_conference_program_events_path(conference2.short_title) - expect(current_path).to eq(admin_conference_program_events_path(conference2.short_title)) - - create(:event, program: conference2.program) - visit edit_admin_conference_program_event_path(conference2.short_title, conference2.program.events.first) - expect(current_path).to eq(edit_admin_conference_program_event_path(conference2.short_title, conference2.program.events.first)) - - visit admin_conference_program_event_types_path(conference2.short_title) - expect(current_path).to eq(admin_conference_program_event_types_path(conference2.short_title)) - - visit new_admin_conference_program_event_type_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_program_event_type_path(conference2.short_title)) - - visit edit_admin_conference_program_event_type_path(conference2.short_title, conference2.program.event_types.first) - expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference2.short_title, conference2.program.event_types.first)) - - visit admin_conference_program_difficulty_levels_path(conference2.short_title) - expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference2.short_title)) - - visit new_admin_conference_program_difficulty_level_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference2.short_title)) - - visit edit_admin_conference_program_difficulty_level_path(conference2.short_title, conference2.program.difficulty_levels.first) - expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference2.short_title, conference2.program.difficulty_levels.first)) - - visit admin_conference_schedules_path(conference2.short_title) - expect(current_path).to eq(admin_conference_schedules_path(conference2.short_title)) - - create(:schedule, program: conference2.program) - visit admin_conference_schedule_path(conference2.short_title, conference2.program.schedules.first) - expect(current_path).to eq(admin_conference_schedule_path(conference2.short_title, conference2.program.schedules.first)) - - visit admin_conference_program_reports_path(conference2.short_title) - expect(current_path).to eq(admin_conference_program_reports_path(conference2.short_title)) - - visit admin_conference_registrations_path(conference2.short_title) - expect(current_path).to eq(admin_conference_registrations_path(conference2.short_title)) - - create(:registration, user: create(:user), conference: conference2) - visit edit_admin_conference_registration_path(conference2.short_title, conference2.registrations.first) - expect(current_path).to eq(root_path) - - visit new_admin_conference_registration_period_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:registration_period, conference: conference2) - visit edit_admin_conference_registration_period_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_questions_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_sponsorship_levels_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_sponsorship_level_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:sponsorship_level, conference: conference2) - visit edit_admin_conference_sponsorship_level_path(conference2.short_title, conference2.sponsorship_levels.first) - expect(current_path).to eq(root_path) - - visit admin_conference_sponsors_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_sponsor_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:sponsor, conference: conference2, sponsorship_level: conference2.sponsorship_levels.first) - visit edit_admin_conference_sponsor_path(conference2.short_title, conference2.sponsors.first) - expect(current_path).to eq(root_path) - - visit admin_conference_tickets_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_ticket_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:ticket, conference: conference2) - visit edit_admin_conference_ticket_path(conference2.short_title, conference2.tickets.first) - expect(current_path).to eq(root_path) - - visit admin_conference_campaigns_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_campaign_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:campaign, conference: conference2) - visit edit_admin_conference_campaign_path(conference2.short_title, conference2.campaigns.first) - expect(current_path).to eq(root_path) - - visit admin_conference_targets_path(conference2.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_target_path(conference2.short_title) - expect(current_path).to eq(root_path) - - create(:target, conference: conference2) - visit edit_admin_conference_target_path(conference2.short_title, conference2.targets.first) - expect(current_path).to eq(root_path) - - visit admin_conference_program_tracks_path(conference2.short_title) - expect(current_path).to eq(admin_conference_program_tracks_path(conference2.short_title)) - - visit admin_conference_roles_path(conference2.short_title) - expect(current_path).to eq(admin_conference_roles_path(conference2.short_title)) - - visit admin_conference_emails_path(conference2.short_title) - expect(current_path).to eq(admin_conference_emails_path(conference2.short_title)) - - visit admin_conference_resources_path(conference2.short_title) - expect(current_path).to eq(admin_conference_resources_path(conference2.short_title)) - - visit new_admin_conference_resource_path(conference2.short_title) - expect(current_path).to eq(new_admin_conference_resource_path(conference2.short_title)) - - create(:resource, conference: conference2) - visit edit_admin_conference_resource_path(conference2.short_title, conference2.resources.first) - expect(current_path).to eq(edit_admin_conference_resource_path(conference2.short_title, conference2.resources.first)) - - visit admin_revision_history_path - expect(current_path).to eq(root_path) - end - - scenario 'when user is info desk' do - sign_in user_info_desk - - visit admin_conference_path(conference3.short_title) - expect(current_path).to eq(admin_conference_path(conference3.short_title)) - - expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') - expect(page).to_not have_link('Basics', href: "/admin/conferences/#{conference3.short_title}/edit") - expect(page).to have_text('Basics') - expect(page).to_not have_link('Contact', href: "/admin/conferences/#{conference3.short_title}/contact/edit") - expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference3.short_title}/commercials") - expect(page).to_not have_link('Splashpage', href: "/admin/conferences/#{conference3.short_title}/splashpage") - expect(page).to_not have_link('Venue', href: "/admin/conferences/#{conference3.short_title}/venue") - expect(page).to_not have_link('Rooms', href: "/admin/conferences/#{conference3.short_title}/venue/rooms") - expect(page).to_not have_link('Lodgings', href: "/admin/conferences/#{conference3.short_title}/lodgings") - expect(page).to_not have_link('Program', href: "/admin/conferences/#{conference3.short_title}/program") - expect(page).to_not have_link('Call for Papers', href: "/admin/conferences/#{conference2.short_title}/program/cfp") - expect(page).to_not have_link('Events', href: "/admin/conferences/#{conference3.short_title}/program/events") - expect(page).to_not have_link('Tracks', href: "/admin/conferences/#{conference3.short_title}/program/tracks") - expect(page).to_not have_link('Event Types', href: "/admin/conferences/#{conference3.short_title}/program/event_types") - expect(page).to_not have_link('Difficulty Levels', href: "/admin/conferences/#{conference3.short_title}/program/difficulty_levels") - expect(page).to_not have_link('Schedules', href: "/admin/conferences/#{conference3.short_title}/schedules") - expect(page).to_not have_link('Reports', href: "/admin/conferences/#{conference3.short_title}/program/reports") - expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference3.short_title}/registrations") - expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference3.short_title}/registration_period") - expect(page).to have_link('Questions', href: "/admin/conferences/#{conference3.short_title}/questions") - expect(page).to_not have_text('Donations') - expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference3.short_title}/sponsorship_levels") - expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference3.short_title}/sponsors") - expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference3.short_title}/tickets") - expect(page).to_not have_text('Objectives') - expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference3.short_title}/campaigns") - expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference3.short_title}/targets") - expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference3.short_title}/emails") - expect(page).to have_link('Roles', href: "/admin/conferences/#{conference3.short_title}/roles") - expect(page).to have_link('Resources', href: "/admin/conferences/#{conference3.short_title}/resources") - - visit edit_admin_conference_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_contact_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_commercials_path(conference3.short_title) - expect(current_path).to eq(admin_conference_commercials_path(conference3.short_title)) - - visit new_admin_conference_splashpage_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_splashpage_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_venue_path(conference3.short_title) - expect(current_path).to eq(root_path) - - conference3.venue = create(:venue) - visit edit_admin_conference_venue_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_venue_rooms_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:room, venue: conference3.venue) - visit edit_admin_conference_venue_room_path(conference3.short_title, conference3.venue.rooms.first) - expect(current_path).to eq(root_path) - - visit admin_conference_lodgings_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_lodging_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:lodging, conference: conference3) - visit edit_admin_conference_lodging_path(conference3.short_title, conference3.lodgings.first) - expect(current_path).to eq(root_path) - - visit new_admin_conference_program_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_program_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_program_cfp_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_program_cfp_path(conference3.short_title, conference3.program.cfp) - expect(current_path).to eq(root_path) - - visit admin_conference_program_events_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:event, program: conference3.program) - visit edit_admin_conference_program_event_path(conference3.short_title, conference3.program.events.first) - expect(current_path).to eq(root_path) - - visit admin_conference_program_event_types_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_program_event_type_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_program_event_type_path(conference3.short_title, conference3.program.event_types.first) - expect(current_path).to eq(root_path) - - visit admin_conference_program_difficulty_levels_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_program_difficulty_level_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit edit_admin_conference_program_difficulty_level_path(conference3.short_title, conference3.program.difficulty_levels.first) - expect(current_path).to eq(root_path) - - visit admin_conference_schedules_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:schedule, program: conference3.program) - visit admin_conference_schedule_path(conference3.short_title, conference3.program.schedules.first) - expect(current_path).to eq(root_path) - - visit admin_conference_program_reports_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_registrations_path(conference3.short_title) - expect(current_path).to eq(admin_conference_registrations_path(conference3.short_title)) - - create(:registration, user: create(:user), conference: conference3) - visit edit_admin_conference_registration_path(conference3.short_title, conference3.registrations.first) - expect(current_path).to eq(edit_admin_conference_registration_path(conference3.short_title, conference3.registrations.first)) - - visit new_admin_conference_registration_period_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:registration_period, conference: conference3) - visit edit_admin_conference_registration_period_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_questions_path(conference3.short_title) - expect(current_path).to eq(admin_conference_questions_path(conference3.short_title)) - - visit admin_conference_sponsorship_levels_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_sponsorship_level_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:sponsorship_level, conference: conference3) - visit edit_admin_conference_sponsorship_level_path(conference3.short_title, conference3.sponsorship_levels.first) - expect(current_path).to eq(root_path) - - visit admin_conference_sponsors_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_sponsor_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:sponsor, conference: conference3, sponsorship_level: conference3.sponsorship_levels.first) - visit edit_admin_conference_sponsor_path(conference3.short_title, conference3.sponsors.first) - expect(current_path).to eq(root_path) - - visit admin_conference_tickets_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_ticket_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:ticket, conference: conference3) - visit edit_admin_conference_ticket_path(conference3.short_title, conference3.tickets.first) - expect(current_path).to eq(root_path) - - visit admin_conference_campaigns_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_campaign_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:campaign, conference: conference3) - visit edit_admin_conference_campaign_path(conference3.short_title, conference3.campaigns.first) - expect(current_path).to eq(root_path) - - visit admin_conference_targets_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit new_admin_conference_target_path(conference3.short_title) - expect(current_path).to eq(root_path) - - create(:target, conference: conference3) - visit edit_admin_conference_target_path(conference3.short_title, conference3.targets.first) - expect(current_path).to eq(root_path) - - visit admin_conference_program_tracks_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_roles_path(conference3.short_title) - expect(current_path).to eq(admin_conference_roles_path(conference3.short_title)) - - visit admin_conference_emails_path(conference3.short_title) - expect(current_path).to eq(root_path) - - visit admin_conference_resources_path(conference3.short_title) - expect(current_path).to eq(admin_conference_resources_path(conference3.short_title)) - - visit new_admin_conference_resource_path(conference3.short_title) - expect(current_path).to eq(new_admin_conference_resource_path(conference3.short_title)) - - create(:resource, conference: conference3) - visit edit_admin_conference_resource_path(conference3.short_title, conference3.resources.first) - expect(current_path).to eq(edit_admin_conference_resource_path(conference3.short_title, conference3.resources.first)) - - visit admin_revision_history_path - expect(current_path).to eq(root_path) - end -end diff --git a/spec/features/base_controller_spec.rb b/spec/features/base_controller_spec.rb index be52c3a9..1f75f81b 100644 --- a/spec/features/base_controller_spec.rb +++ b/spec/features/base_controller_spec.rb @@ -25,7 +25,7 @@ feature 'BaseController' do it 'not an admin it redirects to root_path' do visit admin_conferences_path expect(current_path).to eq root_path - expect(flash).to eq 'You are not authorized to access this area!' + expect(flash).to eq 'You are not authorized to access this page.' end it 'an admin he can access the admin area' do diff --git a/spec/features/cfp_ability_spec.rb b/spec/features/cfp_ability_spec.rb new file mode 100644 index 00000000..235dedea --- /dev/null +++ b/spec/features/cfp_ability_spec.rb @@ -0,0 +1,249 @@ +require 'spec_helper' + +feature 'Has correct abilities' do + + let(:organization) { create(:organization) } + let(:conference) { create(:full_conference, organization: organization) } + let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference) } + let(:user_cfp) { create(:user, role_ids: [role_cfp.id]) } + + context 'when user is cfp' do + before do + sign_in user_cfp + end + + scenario 'for organization and conference attributes' do + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to_not have_link('Basics', href: "/admin/conferences/#{conference.short_title}/edit") + expect(page).to have_text('Basics') + expect(page).to_not have_link('Contact', href: "/admin/conferences/#{conference.short_title}/contact/edit") + expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference.short_title}/commercials") + expect(page).to_not have_link('Splashpage', href: "/admin/conferences/#{conference.short_title}/splashpage") + expect(page).to have_link('Venue', href: "/admin/conferences/#{conference.short_title}/venue") + expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference.short_title}/venue/rooms") + expect(page).to have_link('Program', href: "/admin/conferences/#{conference.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conferences/#{conference.short_title}/program/cfps") + expect(page).to have_link('Events', href: "/admin/conferences/#{conference.short_title}/program/events") + expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference.short_title}/program/difficulty_levels") + expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference.short_title}/schedules") + expect(page).to have_link('Reports', href: "/admin/conferences/#{conference.short_title}/program/reports") + expect(page).to_not have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations") + expect(page).to_not have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions") + expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") + expect(page).to_not have_link('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings") + expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period") + expect(page).to_not have_text('Donations') + expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels") + expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors") + expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets") + expect(page).to_not have_text('Objectives') + expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns") + expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets") + expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles") + expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources") + + visit admin_conference_venue_rooms_path(conference.short_title) + expect(current_path).to eq(admin_conference_venue_rooms_path(conference.short_title)) + create(:room, venue: conference.venue) + visit edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first) + expect(current_path).to eq(edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first)) + + visit new_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_path(conference.short_title)) + + visit edit_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_program_path(conference.short_title)) + + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq root_path + + conference.program.cfp.destroy! + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) + create(:cfp, program: conference.program) + + visit edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) + expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)) + + create(:event, program: conference.program) + visit edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first) + expect(current_path).to eq(edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first)) + + visit admin_conference_program_event_types_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_event_types_path(conference.short_title)) + + visit new_admin_conference_program_event_type_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_event_type_path(conference.short_title)) + + visit edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first) + expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first)) + + visit admin_conference_program_difficulty_levels_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference.short_title)) + + visit new_admin_conference_program_difficulty_level_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference.short_title)) + + visit edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first) + expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first)) + + visit admin_conference_schedules_path(conference.short_title) + expect(current_path).to eq(admin_conference_schedules_path(conference.short_title)) + + create(:schedule, program: conference.program) + visit admin_conference_schedule_path(conference.short_title, conference.program.schedules.first) + expect(current_path).to eq(admin_conference_schedule_path(conference.short_title, conference.program.schedules.first)) + + visit admin_conference_program_reports_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_reports_path(conference.short_title)) + + visit admin_conference_registrations_path(conference.short_title) + expect(current_path).to eq(admin_conference_registrations_path(conference.short_title)) + + create(:registration, user: create(:user), conference: conference) + visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first) + expect(current_path).to eq(root_path) + + visit new_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:registration_period, conference: conference) + visit edit_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_questions_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_program_tracks_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_tracks_path(conference.short_title)) + + visit admin_conference_roles_path(conference.short_title) + expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) + + visit admin_conference_emails_path(conference.short_title) + expect(current_path).to eq(admin_conference_emails_path(conference.short_title)) + + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + visit admin_organizations_path + expect(current_path).to eq(admin_organizations_path) + + visit edit_admin_organization_path(organization) + expect(current_path).to eq(root_path) + + visit new_admin_organization_path + expect(current_path).to eq(root_path) + + visit edit_admin_conference_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_contact_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_commercials_path(conference.short_title) + expect(current_path).to eq(admin_conference_commercials_path(conference.short_title)) + + visit new_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(root_path) + + conference.venue = create(:venue) + visit edit_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_lodgings_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_lodging_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:lodging, conference: conference) + visit edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first) + expect(current_path).to eq(root_path) + + visit new_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:registration_period, conference: conference) + visit edit_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_sponsorship_levels_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_sponsorship_level_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:sponsorship_level, conference: conference) + visit edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first) + expect(current_path).to eq(root_path) + + visit admin_conference_sponsors_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_sponsor_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:sponsor, conference: conference, sponsorship_level: conference.sponsorship_levels.first) + visit edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first) + expect(current_path).to eq(root_path) + + visit admin_conference_tickets_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_ticket_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:ticket, conference: conference) + visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first) + expect(current_path).to eq(root_path) + + visit admin_conference_campaigns_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_campaign_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:campaign, conference: conference) + visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first) + expect(current_path).to eq(root_path) + + visit admin_conference_targets_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_target_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:target, conference: conference) + visit edit_admin_conference_target_path(conference.short_title, conference.targets.first) + expect(current_path).to eq(root_path) + + visit admin_conference_roles_path(conference.short_title) + expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) + + visit admin_conference_resources_path(conference.short_title) + expect(current_path).to eq(admin_conference_resources_path(conference.short_title)) + + visit new_admin_conference_resource_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_resource_path(conference.short_title)) + + create(:resource, conference: conference) + visit edit_admin_conference_resource_path(conference.short_title, conference.resources.first) + expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first)) + + visit admin_revision_history_path + expect(current_path).to eq(root_path) + end + end +end diff --git a/spec/features/info_desk_ability_spec.rb b/spec/features/info_desk_ability_spec.rb new file mode 100644 index 00000000..7d0039fe --- /dev/null +++ b/spec/features/info_desk_ability_spec.rb @@ -0,0 +1,243 @@ +require 'spec_helper' + +feature 'Has correct abilities' do + + let(:organization) { create(:organization) } + let(:conference) { create(:full_conference, organization: organization) } + let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference) } + let(:user_info_desk) { create(:user, role_ids: [role_info_desk.id]) } + + context 'when user is info desk' do + before do + sign_in user_info_desk + end + + scenario 'for organization and conference attributes' do + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + expect(page).to_not have_link('Basics', href: "/admin/conferences/#{conference.short_title}/edit") + expect(page).to have_text('Basics') + expect(page).to_not have_link('Contact', href: "/admin/conferences/#{conference.short_title}/contact/edit") + expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference.short_title}/commercials") + expect(page).to_not have_link('Splashpage', href: "/admin/conferences/#{conference.short_title}/splashpage") + expect(page).to_not have_link('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings") + expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period") + expect(page).to_not have_text('Donations') + expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels") + expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors") + expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets") + expect(page).to_not have_text('Objectives') + expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns") + expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets") + expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles") + expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources") + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to_not have_link('Venue', href: "/admin/conferences/#{conference.short_title}/venue") + expect(page).to_not have_link('Rooms', href: "/admin/conferences/#{conference.short_title}/venue/rooms") + expect(page).to_not have_link('Program', href: "/admin/conferences/#{conference.short_title}/program") + expect(page).to_not have_link('Call for Papers', href: "/admin/conferences/#{conference.short_title}/program/cfps") + expect(page).to_not have_link('Events', href: "/admin/conferences/#{conference.short_title}/program/events") + expect(page).to_not have_link('Tracks', href: "/admin/conferences/#{conference.short_title}/program/tracks") + expect(page).to_not have_link('Event Types', href: "/admin/conferences/#{conference.short_title}/program/event_types") + expect(page).to_not have_link('Difficulty Levels', href: "/admin/conferences/#{conference.short_title}/program/difficulty_levels") + expect(page).to_not have_link('Schedules', href: "/admin/conferences/#{conference.short_title}/schedules") + expect(page).to_not have_link('Reports', href: "/admin/conferences/#{conference.short_title}/program/reports") + expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations") + expect(page).to have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions") + expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") + + visit admin_organizations_path + expect(current_path).to eq(admin_organizations_path) + + visit edit_admin_organization_path(organization) + expect(current_path).to eq(root_path) + + visit new_admin_organization_path + expect(current_path).to eq(root_path) + + visit edit_admin_conference_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_contact_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_commercials_path(conference.short_title) + expect(current_path).to eq(admin_conference_commercials_path(conference.short_title)) + + visit new_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(root_path) + + conference.venue = create(:venue) + visit edit_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_lodgings_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_lodging_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:lodging, conference: conference) + visit edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first) + expect(current_path).to eq(root_path) + + visit new_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:registration_period, conference: conference) + visit edit_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_sponsorship_levels_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_sponsorship_level_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:sponsorship_level, conference: conference) + visit edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first) + expect(current_path).to eq(root_path) + + visit admin_conference_sponsors_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_sponsor_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:sponsor, conference: conference, sponsorship_level: conference.sponsorship_levels.first) + visit edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first) + expect(current_path).to eq(root_path) + + visit admin_conference_tickets_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_ticket_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:ticket, conference: conference) + visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first) + expect(current_path).to eq(root_path) + + visit admin_conference_campaigns_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_campaign_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:campaign, conference: conference) + visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first) + expect(current_path).to eq(root_path) + + visit admin_conference_targets_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_target_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:target, conference: conference) + visit edit_admin_conference_target_path(conference.short_title, conference.targets.first) + expect(current_path).to eq(root_path) + + visit admin_conference_roles_path(conference.short_title) + expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) + + visit admin_conference_resources_path(conference.short_title) + expect(current_path).to eq(admin_conference_resources_path(conference.short_title)) + + visit new_admin_conference_resource_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_resource_path(conference.short_title)) + + create(:resource, conference: conference) + visit edit_admin_conference_resource_path(conference.short_title, conference.resources.first) + expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first)) + + visit admin_revision_history_path + expect(current_path).to eq(root_path) + + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + visit admin_conference_venue_rooms_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:room, venue: conference.venue) + visit edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first) + expect(current_path).to eq(root_path) + + visit new_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq root_path + + conference.program.cfp.destroy! + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq root_path + create(:cfp, program: conference.program) + + visit edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) + expect(current_path).to eq(root_path) + + visit admin_conference_program_events_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:event, program: conference.program) + visit edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first) + expect(current_path).to eq(root_path) + + visit admin_conference_program_event_types_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_program_event_type_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first) + expect(current_path).to eq(root_path) + + visit admin_conference_program_difficulty_levels_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit new_admin_conference_program_difficulty_level_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first) + expect(current_path).to eq(root_path) + + visit admin_conference_schedules_path(conference.short_title) + expect(current_path).to eq(root_path) + + create(:schedule, program: conference.program) + visit admin_conference_schedule_path(conference.short_title, conference.program.schedules.first) + expect(current_path).to eq(root_path) + + visit admin_conference_program_reports_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_registrations_path(conference.short_title) + expect(current_path).to eq(admin_conference_registrations_path(conference.short_title)) + + create(:registration, user: create(:user), conference: conference) + visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first) + expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)) + + visit admin_conference_questions_path(conference.short_title) + expect(current_path).to eq(admin_conference_questions_path(conference.short_title)) + + visit admin_conference_program_tracks_path(conference.short_title) + expect(current_path).to eq(root_path) + + visit admin_conference_emails_path(conference.short_title) + expect(current_path).to eq(root_path) + end + end +end diff --git a/spec/features/organization_admin_ability_spec.rb b/spec/features/organization_admin_ability_spec.rb new file mode 100644 index 00000000..3a5ffcd3 --- /dev/null +++ b/spec/features/organization_admin_ability_spec.rb @@ -0,0 +1,240 @@ +require 'spec_helper' + +feature 'Has correct abilities' do + let(:organization) { create(:organization) } + let(:conference) { create(:full_conference, organization: organization) } + let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) } + let(:user_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) } + + context 'when user is organization_admin' do + before do + sign_in user_organization_admin + end + + scenario 'for organization attributes' do + visit admin_organizations_path + expect(current_path).to eq(admin_organizations_path) + + visit edit_admin_organization_path(organization) + expect(current_path).to eq(edit_admin_organization_path(organization)) + + visit new_admin_organization_path + expect(current_path).to eq(root_path) + end + + scenario 'for conference attributes' do + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to have_link('Basics', href: "/admin/conferences/#{conference.short_title}/edit") + expect(page).to have_link('Contact', href: "/admin/conferences/#{conference.short_title}/contact/edit") + expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference.short_title}/commercials") + expect(page).to have_link('Splashpage', href: "/admin/conferences/#{conference.short_title}/splashpage") + expect(page).to have_link('Venue', href: "/admin/conferences/#{conference.short_title}/venue") + expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference.short_title}/venue/rooms") + expect(page).to have_link('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings") + expect(page).to have_link('Program', href: "/admin/conferences/#{conference.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conferences/#{conference.short_title}/program/cfps") + expect(page).to have_link('Events', href: "/admin/conferences/#{conference.short_title}/program/events") + expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference.short_title}/program/difficulty_levels") + expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference.short_title}/schedules") + expect(page).to have_link('Reports', href: "/admin/conferences/#{conference.short_title}/program/reports") + expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations") + expect(page).to have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period") + expect(page).to have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions") + expect(page).to have_text('Donations') + expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels") + expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors") + expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets") + expect(page).to have_text('Objectives') + expect(page).to have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns") + expect(page).to have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets") + expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") + expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles") + expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources") + + visit edit_admin_conference_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_path(conference.short_title)) + + visit edit_admin_conference_contact_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_contact_path(conference.short_title)) + + visit admin_conference_commercials_path(conference.short_title) + expect(current_path).to eq(admin_conference_commercials_path(conference.short_title)) + + visit new_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_splashpage_path(conference.short_title)) + + visit edit_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_splashpage_path(conference.short_title)) + + visit new_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_venue_path(conference.short_title)) + + conference.venue = create(:venue) + visit edit_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_venue_path(conference.short_title)) + + visit admin_conference_venue_rooms_path(conference.short_title) + expect(current_path).to eq(admin_conference_venue_rooms_path(conference.short_title)) + + create(:room, venue: conference.venue) + visit edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first) + expect(current_path).to eq(edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first)) + + visit admin_conference_lodgings_path(conference.short_title) + expect(current_path).to eq(admin_conference_lodgings_path(conference.short_title)) + + visit new_admin_conference_lodging_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_lodging_path(conference.short_title)) + + create(:lodging, conference: conference) + visit edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first) + expect(current_path).to eq(edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first)) + + visit new_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_path(conference.short_title)) + + visit edit_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_program_path(conference.short_title)) + + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq root_path + + conference.program.cfp.destroy! + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) + create(:cfp, program: conference.program) + + visit edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) + expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)) + + visit admin_conference_program_events_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_events_path(conference.short_title)) + + create(:event, program: conference.program) + visit edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first) + expect(current_path).to eq(edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first)) + + visit admin_conference_program_event_types_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_event_types_path(conference.short_title)) + + visit new_admin_conference_program_event_type_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_event_type_path(conference.short_title)) + + visit edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first) + expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first)) + + visit admin_conference_program_difficulty_levels_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference.short_title)) + + visit new_admin_conference_program_difficulty_level_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference.short_title)) + + visit edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first) + expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first)) + + visit admin_conference_schedules_path(conference.short_title) + expect(current_path).to eq(admin_conference_schedules_path(conference.short_title)) + + create(:schedule, program: conference.program) + visit admin_conference_schedule_path(conference.short_title, conference.program.schedules.first) + expect(current_path).to eq(admin_conference_schedule_path(conference.short_title, conference.program.schedules.first)) + + visit admin_conference_program_reports_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_reports_path(conference.short_title)) + + visit admin_conference_registrations_path(conference.short_title) + expect(current_path).to eq(admin_conference_registrations_path(conference.short_title)) + + create(:registration, user: create(:user), conference: conference) + visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first) + expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)) + + visit new_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_registration_period_path(conference.short_title)) + + create(:registration_period, conference: conference) + visit edit_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_registration_period_path(conference.short_title)) + + visit admin_conference_questions_path(conference.short_title) + expect(current_path).to eq(admin_conference_questions_path(conference.short_title)) + + visit admin_conference_sponsorship_levels_path(conference.short_title) + expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference.short_title)) + + visit new_admin_conference_sponsorship_level_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_sponsorship_level_path(conference.short_title)) + + create(:sponsorship_level, conference: conference) + visit edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first) + expect(current_path).to eq(edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first)) + + visit admin_conference_sponsors_path(conference.short_title) + expect(current_path).to eq(admin_conference_sponsors_path(conference.short_title)) + + visit new_admin_conference_sponsor_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_sponsor_path(conference.short_title)) + + create(:sponsor, conference: conference, sponsorship_level: conference.sponsorship_levels.first) + visit edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first) + expect(current_path).to eq(edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first)) + + visit admin_conference_tickets_path(conference.short_title) + expect(current_path).to eq(admin_conference_tickets_path(conference.short_title)) + + visit new_admin_conference_ticket_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_ticket_path(conference.short_title)) + + create(:ticket, conference: conference) + visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first) + expect(current_path).to eq(edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)) + + visit admin_conference_campaigns_path(conference.short_title) + expect(current_path).to eq(admin_conference_campaigns_path(conference.short_title)) + + visit new_admin_conference_campaign_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_campaign_path(conference.short_title)) + + create(:campaign, conference: conference) + visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first) + expect(current_path).to eq(edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)) + + visit admin_conference_targets_path(conference.short_title) + expect(current_path).to eq(admin_conference_targets_path(conference.short_title)) + + visit new_admin_conference_target_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_target_path(conference.short_title)) + + create(:target, conference: conference) + visit edit_admin_conference_target_path(conference.short_title, conference.targets.first) + expect(current_path).to eq(edit_admin_conference_target_path(conference.short_title, conference.targets.first)) + + visit admin_conference_program_tracks_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_tracks_path(conference.short_title)) + + visit admin_conference_roles_path(conference.short_title) + expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) + + visit admin_conference_emails_path(conference.short_title) + expect(current_path).to eq(admin_conference_emails_path(conference.short_title)) + + visit admin_conference_resources_path(conference.short_title) + expect(current_path).to eq(admin_conference_resources_path(conference.short_title)) + + visit new_admin_conference_resource_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_resource_path(conference.short_title)) + + create(:resource, conference: conference) + visit edit_admin_conference_resource_path(conference.short_title, conference.resources.first) + expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first)) + + visit admin_revision_history_path + expect(current_path).to eq(admin_revision_history_path) + end + end +end diff --git a/spec/features/organization_spec.rb b/spec/features/organization_spec.rb new file mode 100644 index 00000000..6fcf590b --- /dev/null +++ b/spec/features/organization_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +feature Organization do + let!(:organization) { create(:organization) } + let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } + let(:organization_admin) { create(:user, role_ids: [organization_admin_role.id]) } + let(:admin_user) { create(:admin) } + + shared_examples 'successfully updates an organization' do + scenario 'updates a exsisting organization', feature: true, js: true do + visit edit_admin_organization_path(organization) + fill_in 'organization_name', with: 'changed name' + + click_button 'Update Organization' + + organization.reload + expect(flash).to eq('Organization successfully updated') + expect(organization.name).to eq('changed name') + end + end + + context 'signed in as site admin' do + before do + sign_in admin_user + end + scenario 'creates a new organization', feature: true, js: true do + visit new_admin_organization_path + fill_in 'organization_name', with: 'Organization name' + + click_button 'Create Organization' + + expect(flash).to eq('Organization successfully created') + expect(Organization.last.name).to eq('Organization name') + end + + it_behaves_like 'successfully updates an organization' + end + + context 'signed in as organization admin' do + before do + sign_in organization_admin + end + scenario "can't create new organization", feature: true, js: true do + visit new_admin_organization_path + + expect(flash).to eq('You are not authorized to access this page.') + end + + it_behaves_like 'successfully updates an organization' + end +end diff --git a/spec/features/organizer_ability_spec.rb b/spec/features/organizer_ability_spec.rb new file mode 100644 index 00000000..7617bc0a --- /dev/null +++ b/spec/features/organizer_ability_spec.rb @@ -0,0 +1,246 @@ +require 'spec_helper' + +feature 'Has correct abilities' do + + let(:organization) { create(:organization) } + let(:conference) { create(:full_conference, organization: organization) } + let(:other_conference) { create(:conference, organization: organization) } # user is organizer, venue is not set by default + let(:role_organizer_conf) { Role.find_by(name: 'organizer', resource: conference) } + let(:role_organizer_other_conf) { Role.find_by(name: 'organizer', resource: other_conference) } + let(:user_organizer) { create(:user, role_ids: [role_organizer_conf.id, role_organizer_other_conf.id]) } + + context 'when user is organizer' do + before do + sign_in user_organizer + end + + scenario 'for organization attributes' do + visit admin_organizations_path + expect(current_path).to eq(admin_organizations_path) + + visit edit_admin_organization_path(organization) + expect(current_path).to eq(root_path) + + visit new_admin_organization_path + expect(current_path).to eq(root_path) + end + + scenario 'for conference attributes' do + visit admin_conference_path(conference.short_title) + expect(current_path).to eq(admin_conference_path(conference.short_title)) + + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to have_link('Basics', href: "/admin/conferences/#{conference.short_title}/edit") + expect(page).to have_link('Contact', href: "/admin/conferences/#{conference.short_title}/contact/edit") + expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference.short_title}/commercials") + expect(page).to have_link('Splashpage', href: "/admin/conferences/#{conference.short_title}/splashpage") + expect(page).to have_link('Venue', href: "/admin/conferences/#{conference.short_title}/venue") + expect(page).to have_link('Rooms', href: "/admin/conferences/#{conference.short_title}/venue/rooms") + expect(page).to have_link('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings") + expect(page).to have_link('Program', href: "/admin/conferences/#{conference.short_title}/program") + expect(page).to have_link('Call for Papers', href: "/admin/conferences/#{conference.short_title}/program/cfps") + expect(page).to have_link('Events', href: "/admin/conferences/#{conference.short_title}/program/events") + expect(page).to have_link('Tracks', href: "/admin/conferences/#{conference.short_title}/program/tracks") + expect(page).to have_link('Event Types', href: "/admin/conferences/#{conference.short_title}/program/event_types") + expect(page).to have_link('Difficulty Levels', href: "/admin/conferences/#{conference.short_title}/program/difficulty_levels") + expect(page).to have_link('Schedules', href: "/admin/conferences/#{conference.short_title}/schedules") + expect(page).to have_link('Reports', href: "/admin/conferences/#{conference.short_title}/program/reports") + expect(page).to have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations") + expect(page).to have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period") + expect(page).to have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions") + expect(page).to have_text('Donations') + expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels") + expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors") + expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets") + expect(page).to have_text('Objectives') + expect(page).to have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns") + expect(page).to have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets") + expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails") + expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles") + expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources") + + visit admin_conference_path(other_conference.short_title) + expect(page).to have_link('Add venue', href: "/admin/conferences/#{other_conference.short_title}/venue/new") + + visit edit_admin_conference_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_path(conference.short_title)) + + visit edit_admin_conference_contact_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_contact_path(conference.short_title)) + + visit admin_conference_commercials_path(conference.short_title) + expect(current_path).to eq(admin_conference_commercials_path(conference.short_title)) + + visit new_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_splashpage_path(conference.short_title)) + + visit edit_admin_conference_splashpage_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_splashpage_path(conference.short_title)) + + visit new_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_venue_path(conference.short_title)) + + conference.venue = create(:venue) + visit edit_admin_conference_venue_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_venue_path(conference.short_title)) + + visit admin_conference_venue_rooms_path(conference.short_title) + expect(current_path).to eq(admin_conference_venue_rooms_path(conference.short_title)) + + create(:room, venue: conference.venue) + visit edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first) + expect(current_path).to eq(edit_admin_conference_venue_room_path(conference.short_title, conference.venue.rooms.first)) + + visit admin_conference_lodgings_path(conference.short_title) + expect(current_path).to eq(admin_conference_lodgings_path(conference.short_title)) + + visit new_admin_conference_lodging_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_lodging_path(conference.short_title)) + + create(:lodging, conference: conference) + visit edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first) + expect(current_path).to eq(edit_admin_conference_lodging_path(conference.short_title, conference.lodgings.first)) + + visit new_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_path(conference.short_title)) + + visit edit_admin_conference_program_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_program_path(conference.short_title)) + + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq root_path + + conference.program.cfp.destroy! + visit new_admin_conference_program_cfp_path(conference.short_title) + expect(current_path).to eq new_admin_conference_program_cfp_path(conference.short_title) + create(:cfp, program: conference.program) + + visit edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp) + expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference.short_title, conference.program.cfp)) + + visit admin_conference_program_events_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_events_path(conference.short_title)) + + create(:event, program: conference.program) + visit edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first) + expect(current_path).to eq(edit_admin_conference_program_event_path(conference.short_title, conference.program.events.first)) + + visit admin_conference_program_event_types_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_event_types_path(conference.short_title)) + + visit new_admin_conference_program_event_type_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_event_type_path(conference.short_title)) + + visit edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first) + expect(current_path).to eq(edit_admin_conference_program_event_type_path(conference.short_title, conference.program.event_types.first)) + + visit admin_conference_program_difficulty_levels_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_difficulty_levels_path(conference.short_title)) + + visit new_admin_conference_program_difficulty_level_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_program_difficulty_level_path(conference.short_title)) + + visit edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first) + expect(current_path).to eq(edit_admin_conference_program_difficulty_level_path(conference.short_title, conference.program.difficulty_levels.first)) + + visit admin_conference_schedules_path(conference.short_title) + expect(current_path).to eq(admin_conference_schedules_path(conference.short_title)) + + create(:schedule, program: conference.program) + visit admin_conference_schedule_path(conference.short_title, conference.program.schedules.first) + expect(current_path).to eq(admin_conference_schedule_path(conference.short_title, conference.program.schedules.first)) + + visit admin_conference_program_reports_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_reports_path(conference.short_title)) + + visit admin_conference_registrations_path(conference.short_title) + expect(current_path).to eq(admin_conference_registrations_path(conference.short_title)) + + create(:registration, user: create(:user), conference: conference) + visit edit_admin_conference_registration_path(conference.short_title, conference.registrations.first) + expect(current_path).to eq(edit_admin_conference_registration_path(conference.short_title, conference.registrations.first)) + + visit new_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_registration_period_path(conference.short_title)) + + create(:registration_period, conference: conference) + visit edit_admin_conference_registration_period_path(conference.short_title) + expect(current_path).to eq(edit_admin_conference_registration_period_path(conference.short_title)) + + visit admin_conference_questions_path(conference.short_title) + expect(current_path).to eq(admin_conference_questions_path(conference.short_title)) + + visit admin_conference_sponsorship_levels_path(conference.short_title) + expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference.short_title)) + + visit new_admin_conference_sponsorship_level_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_sponsorship_level_path(conference.short_title)) + + create(:sponsorship_level, conference: conference) + visit edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first) + expect(current_path).to eq(edit_admin_conference_sponsorship_level_path(conference.short_title, conference.sponsorship_levels.first)) + + visit admin_conference_sponsors_path(conference.short_title) + expect(current_path).to eq(admin_conference_sponsors_path(conference.short_title)) + + visit new_admin_conference_sponsor_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_sponsor_path(conference.short_title)) + + create(:sponsor, conference: conference, sponsorship_level: conference.sponsorship_levels.first) + visit edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first) + expect(current_path).to eq(edit_admin_conference_sponsor_path(conference.short_title, conference.sponsors.first)) + + visit admin_conference_tickets_path(conference.short_title) + expect(current_path).to eq(admin_conference_tickets_path(conference.short_title)) + + visit new_admin_conference_ticket_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_ticket_path(conference.short_title)) + + create(:ticket, conference: conference) + visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first) + expect(current_path).to eq(edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)) + + visit admin_conference_campaigns_path(conference.short_title) + expect(current_path).to eq(admin_conference_campaigns_path(conference.short_title)) + + visit new_admin_conference_campaign_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_campaign_path(conference.short_title)) + + create(:campaign, conference: conference) + visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first) + expect(current_path).to eq(edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)) + + visit admin_conference_targets_path(conference.short_title) + expect(current_path).to eq(admin_conference_targets_path(conference.short_title)) + + visit new_admin_conference_target_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_target_path(conference.short_title)) + + create(:target, conference: conference) + visit edit_admin_conference_target_path(conference.short_title, conference.targets.first) + expect(current_path).to eq(edit_admin_conference_target_path(conference.short_title, conference.targets.first)) + + visit admin_conference_program_tracks_path(conference.short_title) + expect(current_path).to eq(admin_conference_program_tracks_path(conference.short_title)) + + visit admin_conference_roles_path(conference.short_title) + expect(current_path).to eq(admin_conference_roles_path(conference.short_title)) + + visit admin_conference_emails_path(conference.short_title) + expect(current_path).to eq(admin_conference_emails_path(conference.short_title)) + + visit admin_conference_resources_path(conference.short_title) + expect(current_path).to eq(admin_conference_resources_path(conference.short_title)) + + visit new_admin_conference_resource_path(conference.short_title) + expect(current_path).to eq(new_admin_conference_resource_path(conference.short_title)) + + create(:resource, conference: conference) + visit edit_admin_conference_resource_path(conference.short_title, conference.resources.first) + expect(current_path).to eq(edit_admin_conference_resource_path(conference.short_title, conference.resources.first)) + + visit admin_revision_history_path + expect(current_path).to eq(admin_revision_history_path) + end + end +end diff --git a/spec/features/user_ability_spec.rb b/spec/features/user_ability_spec.rb new file mode 100644 index 00000000..d56e7441 --- /dev/null +++ b/spec/features/user_ability_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +feature 'Has correct abilities' do + + let(:organization) { create(:organization) } + let(:conference) { create(:full_conference, organization: organization) } # user is cfp + let(:user) { create(:user) } + + context 'when user has no role' do + before do + sign_in user + end + + scenario 'for administration views' do + visit admin_conference_path(conference.short_title) + + expect(current_path).to eq root_path + expect(flash).to eq 'You are not authorized to access this page.' + end + end +end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 001c7365..02aa4882 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -9,7 +9,8 @@ describe 'User' do subject(:ability){ Ability.new(user) } let(:user){ nil } - let!(:my_conference) { create(:full_conference) } + let!(:organization) { create(:organization) } + let!(:my_conference) { create(:full_conference, organization: organization) } let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) } let(:my_registration) { create(:registration, conference: my_conference, user: admin) } @@ -44,6 +45,7 @@ describe 'User' do let!(:other_event_schedule) { create(:event_schedule, schedule: other_schedule) } # Test abilities for not signed in users context 'when user is not signed in' do + it{ should be_able_to(:index, Organization)} it{ should be_able_to(:index, Conference)} it{ should be_able_to(:show, conference_public)} @@ -137,17 +139,20 @@ describe 'User' do end shared_examples 'user with any role' do - before do - @other_conference = create(:conference) - end + let!(:other_organization) { create(:organization) } + let!(:other_conference) { create(:conference, organization: other_organization) } - %w(organizer cfp info_desk volunteers_coordinator).each do |role| - it{ should_not be_able_to(:toggle_user, Role.find_by(name: role, resource: @other_conference)) } - it{ should_not be_able_to(:update, Role.find_by(name: role, resource: @other_conference)) } - it{ should_not be_able_to(:edit, Role.find_by(name: role, resource: @other_conference)) } - it{ should be_able_to(:show, Role.find_by(name: role, resource: @other_conference)) } - it{ should be_able_to(:index, Role.find_by(name: role, resource: @other_conference)) } - end + it{ should_not be_able_to(:update, Role.find_by(name: 'organization_admin', resource: other_organization)) } + it{ should_not be_able_to(:edit, Role.find_by(name: 'organization_admin', resource: other_organization)) } + it{ should_not be_able_to(:show, Role.find_by(name: 'organization_admin', resource: other_organization)) } + + %w(organizer cfp info_desk volunteers_coordinator).each do |role| + it{ should_not be_able_to(:toggle_user, Role.find_by(name: role, resource: other_conference)) } + it{ should_not be_able_to(:update, Role.find_by(name: role, resource: other_conference)) } + it{ should_not be_able_to(:edit, Role.find_by(name: role, resource: other_conference)) } + it{ should be_able_to(:show, Role.find_by(name: role, resource: other_conference)) } + it{ should be_able_to(:index, Role.find_by(name: role, resource: other_conference)) } + end end shared_examples 'user with non-organizer role' do |role_name| @@ -164,6 +169,24 @@ describe 'User' do end end + context 'when user has the role organization_admin' do + let(:role) { Role.find_by(name: 'organization_admin', resource: organization) } + let(:user) { create(:user, role_ids: [role.id]) } + let(:other_organization) { create(:organization) } + let(:other_conference) { create(:conference, organization: other_organization) } + + it{ should be_able_to(:manage, my_conference) } + it{ should be_able_to(:read, organization) } + it{ should be_able_to(:update, organization) } + it{ should be_able_to(:destroy, organization) } + it{ should be_able_to(:new, Conference.new) } + it{ should be_able_to(:create, Conference.new(organization_id: organization.id)) } + it{ should_not be_able_to(:manage, other_conference) } + it{ should_not be_able_to(:create, Conference.new(organization_id: other_organization.id)) } + it{ should_not be_able_to(:new, Organization.new) } + it{ should_not be_able_to(:create, Organization.new) } + end + context 'when user has the role organizer' do let(:role) { Role.find_by(name: 'organizer', resource: my_conference) } let(:user) { create(:user, role_ids: [role.id]) } @@ -180,9 +203,13 @@ describe 'User' do should be_able_to(:destroy, my_venue) end - it{ should be_able_to(:new, Conference) } - it{ should be_able_to(:create, Conference) } - it{ should be_able_to(:manage, my_conference) } + it{ should_not be_able_to(:new, Organization.new)} + it{ should_not be_able_to(:create, Organization.new)} + it{ should_not be_able_to(:new, Conference.new)} + it{ should_not be_able_to(:create, Conference.new) } + it{ should be_able_to(:read, my_conference) } + it{ should be_able_to(:update, my_conference) } + it{ should be_able_to(:destroy, my_conference) } it{ should_not be_able_to(:manage, conference_public) } it{ should be_able_to(:manage, my_conference.splashpage) } it{ should_not be_able_to(:manage, conference_public.splashpage) }