split feature tests for abilities and suggested changes

This commit is contained in:
shlok007 2017-06-30 09:18:17 +05:30
parent 3daa12f83f
commit 651abcab87
8 changed files with 1059 additions and 721 deletions

View file

@ -154,10 +154,7 @@ class Ability
can :manage, Organization, id: org_ids_for_organization_admin
can :new, Conference
can :manage, Conference, organization_id: org_ids_for_organization_admin
conf_ids_for_organization_admin = []
org_ids_for_organization_admin.each do |org_id|
conf_ids_for_organization_admin += Organization.find(org_id).conferences.pluck(:id)
end
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
can [:index, :show], Role
can [:edit, :update], Role do |role|
role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id)
@ -168,44 +165,44 @@ class Ability
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_for_organization_admin_and_organizer = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
can :manage, Resource, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Conference, id: conf_ids_for_organization_admin_and_organizer
can :manage, Splashpage, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Contact, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, EmailSettings, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Campaign, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Target, conference_id: conf_ids_for_organization_admin_and_organizer
conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
can :manage, Resource, conference_id: conf_ids
can :manage, 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_for_organization_admin_and_organizer
can :manage, Registration, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, RegistrationPeriod, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Question, conference_id: conf_ids_for_organization_admin_and_organizer
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_for_organization_admin_and_organizer).empty?
!(question.conferences.pluck(:id) & conf_ids).empty?
end
can :manage, Vposition, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Vday, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Program, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Schedule, program: { conference_id: conf_ids_for_organization_admin_and_organizer }
can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids_for_organization_admin_and_organizer } }
can :manage, Cfp, program: { conference_id: conf_ids_for_organization_admin_and_organizer}
can :manage, Event, program: { conference_id: conf_ids_for_organization_admin_and_organizer}
can :manage, EventType, program: { conference_id: conf_ids_for_organization_admin_and_organizer}
can :manage, Track, program: { conference_id: conf_ids_for_organization_admin_and_organizer}
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_organization_admin_and_organizer}
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_organization_admin_and_organizer).pluck(:id)).pluck(:id)
can :manage, Venue, conference_id: conf_ids_for_organization_admin_and_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_organization_admin_and_organizer).pluck(:id)
can :manage, Lodging, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Room, venue: { conference_id: conf_ids_for_organization_admin_and_organizer}
can :manage, Sponsor, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organization_admin_and_organizer
can :manage, Ticket, conference_id: conf_ids_for_organization_admin_and_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_organization_admin_and_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 do |role|
@ -213,11 +210,11 @@ class Ability
end
can [:edit, :update, :toggle_user], Role do |role|
role.resource_type == 'Conference' && (conf_ids_for_organization_admin_and_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_organization_admin_and_organizer.include? version.conference_id)
version.item_type == 'User' || (conf_ids.include? version.conference_id)
end
end

View file

@ -1,661 +0,0 @@
require 'spec_helper'
feature 'Has correct abilities' do
let(:organization) { create(:organization) }
# It is necessary to use bang version of let to build roles before user
let(:conference1) { create(:full_conference, organization: organization) } # user is organizer
let(:conference2) { create(:full_conference, organization: organization) } # user is cfp
let(:conference3) { create(:full_conference, organization: organization) } # user is info_desk
let(:conference6) { create(:conference, organization: organization) } # user is organizer, venue is not set by default
let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) }
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_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) }
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 page.'
end
shared_examples 'correct abilities for organizers and organization_admin' do
scenario 'for conference attributes' do
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
end
context 'when user is organization_admin' do
before do
sign_in user_organization_admin
end
scenario 'can manage organization' 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
it_behaves_like 'correct abilities for organizers and organization_admin'
end
context 'when user is organizer' do
before do
sign_in user_organizer
end
scenario 'cannot manage organization' 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
it_behaves_like 'correct abilities for organizers and organization_admin'
end
shared_examples 'correct abilities for cfps and info_desk' do |role|
scenario 'correct ability' do
if role == 'cfp'
conference = conference2
elsif role == 'info_desk'
conference = conference3
end
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")
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
context 'when user is cfp' do
before do
sign_in user_cfp
@conference = conference2
end
scenario 'has correct abilities' do
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 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 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))
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_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))
end
it_behaves_like 'correct abilities for cfps and info_desk', 'cfp'
end
context 'when user is info desk' do
before do
sign_in user_info_desk
end
scenario 'has correct abilities' do
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('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('Program', href: "/admin/conferences/#{conference3.short_title}/program")
expect(page).to_not have_link('Call for Papers', href: "/admin/conferences/#{conference2.short_title}/program/cfps")
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 have_link('Questions', href: "/admin/conferences/#{conference3.short_title}/questions")
expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference3.short_title}/emails")
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 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
conference1.program.cfp.destroy!
visit new_admin_conference_program_cfp_path(conference3.short_title)
expect(current_path).to eq root_path
create(:cfp, program: conference1.program)
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 admin_conference_questions_path(conference3.short_title)
expect(current_path).to eq(admin_conference_questions_path(conference3.short_title))
visit admin_conference_program_tracks_path(conference3.short_title)
expect(current_path).to eq(root_path)
visit admin_conference_emails_path(conference3.short_title)
expect(current_path).to eq(root_path)
end
it_behaves_like 'correct abilities for cfps and info_desk', 'info_desk'
end
end

View file

@ -0,0 +1,250 @@
require 'spec_helper'
feature 'Has correct abilities' do
let(:organization) { create(:organization) }
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:full_conference, organization: organization) } # user is cfp
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

View file

@ -0,0 +1,246 @@
require 'spec_helper'
feature 'Has correct abilities' do
let(:organization) { create(:organization) }
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:full_conference, organization: organization) } # user is info_desk
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

View file

@ -0,0 +1,240 @@
require 'spec_helper'
feature 'Has correct abilities' do
let(:organization) { create(:organization) }
let(:conference) { create(:full_conference, organization: organization) } # user is organization_admin
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

View file

@ -0,0 +1,247 @@
require 'spec_helper'
feature 'Has correct abilities' do
let(:organization) { create(:organization) }
# It is necessary to use bang version of let to build roles before user
let(:conference) { create(:full_conference, organization: organization) } # user is organizer
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

View file

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

View file

@ -139,22 +139,20 @@ describe 'User' do
end
shared_examples 'user with any role' do
before do
@other_organization = create(:organization)
@other_conference = create(:conference, organization: @other_organization)
end
let!(:other_organization) { create(:organization) }
let!(:other_conference) { create(:conference, organization: other_organization) }
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)) }
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
%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|
@ -199,8 +197,8 @@ describe 'User' do
it{ should_not be_able_to(:new, Organization)}
it{ should_not be_able_to(:create, Organization)}
it{ should_not be_able_to(:new, Conference.new) }
it{ should_not be_able_to(:create, Conference.new) }
it{ should_not be_able_to(:new, Conference)}
it{ should_not be_able_to(:create, Conference) }
it{ should be_able_to(:manage, my_conference) }
it{ should_not be_able_to(:manage, conference_public) }
it{ should be_able_to(:manage, my_conference.splashpage) }
@ -269,8 +267,8 @@ describe 'User' do
let(:role) { Role.find_by(name: 'cfp', resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id]) }
it{ should_not be_able_to(:new, Conference.new) }
it{ should_not be_able_to(:create, Conference.new) }
it{ should_not be_able_to(:new, Conference) }
it{ should_not be_able_to(:create, Conference) }
it{ should_not be_able_to(:manage, my_conference) }
it{ should_not be_able_to(:manage, conference_public) }
it{ should_not be_able_to(:manage, my_conference.splashpage) }
@ -336,8 +334,8 @@ describe 'User' do
let(:role) { Role.find_by(name: 'info_desk', resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id]) }
it{ should_not be_able_to(:new, Conference.new) }
it{ should_not be_able_to(:create, Conference.new) }
it{ should_not be_able_to(:new, Conference) }
it{ should_not be_able_to(:create, Conference) }
it{ should_not be_able_to(:manage, my_conference) }
it{ should_not be_able_to(:manage, conference_public) }
it{ should_not be_able_to(:manage, my_conference.splashpage) }
@ -403,8 +401,8 @@ describe 'User' do
let(:role) { Role.find_by(name: 'volunteers_coordinator', resource: my_conference) }
let(:user) { create(:user, role_ids: [role.id]) }
it{ should_not be_able_to(:new, Conference.new) }
it{ should_not be_able_to(:create, Conference.new) }
it{ should_not be_able_to(:new, Conference) }
it{ should_not be_able_to(:create, Conference) }
it{ should_not be_able_to(:manage, my_conference) }
it{ should_not be_able_to(:manage, conference_public) }
it{ should_not be_able_to(:manage, my_conference.splashpage) }