refactor features/ability_spec and increase test coverage for organization
This commit is contained in:
parent
7d408ee33c
commit
21b2e5466f
2 changed files with 562 additions and 534 deletions
|
|
@ -1,18 +1,22 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'Has correct abilities' do
|
feature 'Has correct abilities' do
|
||||||
# It is necessary to use bang version of let to build roles before user
|
|
||||||
let(:conference1) { create(:full_conference) } # user is organizer
|
|
||||||
let(:conference2) { create(:full_conference) } # user is cfp
|
|
||||||
let(:conference3) { create(:full_conference) } # user is info_desk
|
|
||||||
let(:conference6) { create(:conference) } # user is organizer, venue is not set by default
|
|
||||||
|
|
||||||
|
let(: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_conf1) { Role.find_by(name: 'organizer', resource: conference1) }
|
||||||
let(:role_organizer_conf6) { Role.find_by(name: 'organizer', resource: conference6) }
|
let(:role_organizer_conf6) { Role.find_by(name: 'organizer', resource: conference6) }
|
||||||
let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference2) }
|
let(:role_cfp) { Role.find_by(name: 'cfp', resource: conference2) }
|
||||||
let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference3) }
|
let(:role_info_desk) { Role.find_by(name: 'info_desk', resource: conference3) }
|
||||||
|
|
||||||
let(:user) { create(:user) }
|
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_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_cfp) { create(:user, role_ids: [role_cfp.id]) }
|
||||||
let(:user_info_desk) { create(:user, role_ids: [role_info_desk.id]) }
|
let(:user_info_desk) { create(:user, role_ids: [role_info_desk.id]) }
|
||||||
|
|
@ -25,9 +29,8 @@ feature 'Has correct abilities' do
|
||||||
expect(flash).to eq 'You are not authorized to access this page.'
|
expect(flash).to eq 'You are not authorized to access this page.'
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'when user is organizer' do
|
shared_examples 'correct abilities for organizers and organization_admin' do
|
||||||
sign_in user_organizer
|
scenario 'for conference attributes' do
|
||||||
|
|
||||||
visit admin_conference_path(conference1.short_title)
|
visit admin_conference_path(conference1.short_title)
|
||||||
expect(current_path).to eq(admin_conference_path(conference1.short_title))
|
expect(current_path).to eq(admin_conference_path(conference1.short_title))
|
||||||
|
|
||||||
|
|
@ -244,10 +247,196 @@ feature 'Has correct abilities' do
|
||||||
visit admin_revision_history_path
|
visit admin_revision_history_path
|
||||||
expect(current_path).to eq(admin_revision_history_path)
|
expect(current_path).to eq(admin_revision_history_path)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'when user is cfp' do
|
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
|
sign_in user_cfp
|
||||||
|
@conference = conference2
|
||||||
|
end
|
||||||
|
scenario 'has correct abilities' do
|
||||||
visit admin_conference_path(conference2.short_title)
|
visit admin_conference_path(conference2.short_title)
|
||||||
expect(current_path).to eq(admin_conference_path(conference2.short_title))
|
expect(current_path).to eq(admin_conference_path(conference2.short_title))
|
||||||
|
|
||||||
|
|
@ -282,44 +471,12 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference2.short_title}/roles")
|
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")
|
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference2.short_title}/resources")
|
||||||
|
|
||||||
visit edit_admin_conference_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit edit_admin_conference_contact_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_commercials_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(admin_conference_commercials_path(conference2.short_title))
|
|
||||||
|
|
||||||
visit new_admin_conference_splashpage_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit edit_admin_conference_splashpage_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_venue_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
conference2.venue = create(:venue)
|
|
||||||
visit edit_admin_conference_venue_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_venue_rooms_path(conference2.short_title)
|
visit admin_conference_venue_rooms_path(conference2.short_title)
|
||||||
expect(current_path).to eq(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)
|
create(:room, venue: conference2.venue)
|
||||||
visit edit_admin_conference_venue_room_path(conference2.short_title, conference2.venue.rooms.first)
|
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))
|
expect(current_path).to eq(edit_admin_conference_venue_room_path(conference2.short_title, conference2.venue.rooms.first))
|
||||||
|
|
||||||
visit admin_conference_lodgings_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_lodging_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:lodging, conference: conference2)
|
|
||||||
visit edit_admin_conference_lodging_path(conference2.short_title, conference2.lodgings.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_program_path(conference2.short_title)
|
visit new_admin_conference_program_path(conference2.short_title)
|
||||||
expect(current_path).to eq(new_admin_conference_program_path(conference2.short_title))
|
expect(current_path).to eq(new_admin_conference_program_path(conference2.short_title))
|
||||||
|
|
||||||
|
|
@ -327,15 +484,10 @@ feature 'Has correct abilities' do
|
||||||
expect(current_path).to eq(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)
|
visit new_admin_conference_program_cfp_path(conference2.short_title)
|
||||||
expect(current_path).to eq root_path
|
expect(current_path).to eq(new_admin_conference_program_cfp_path(conference2.short_title))
|
||||||
|
|
||||||
conference2.program.cfp.destroy!
|
visit edit_admin_conference_program_cfp_path(conference2.short_title)
|
||||||
visit new_admin_conference_program_cfp_path(conference2.short_title)
|
expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference2.short_title))
|
||||||
expect(current_path).to eq new_admin_conference_program_cfp_path(conference2.short_title)
|
|
||||||
create(:cfp, program: conference2.program)
|
|
||||||
|
|
||||||
visit edit_admin_conference_program_cfp_path(conference2.short_title, conference2.program.cfp)
|
|
||||||
expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference2.short_title, conference2.program.cfp))
|
|
||||||
|
|
||||||
visit admin_conference_program_events_path(conference2.short_title)
|
visit admin_conference_program_events_path(conference2.short_title)
|
||||||
expect(current_path).to eq(admin_conference_program_events_path(conference2.short_title))
|
expect(current_path).to eq(admin_conference_program_events_path(conference2.short_title))
|
||||||
|
|
@ -389,56 +541,6 @@ feature 'Has correct abilities' do
|
||||||
visit admin_conference_questions_path(conference2.short_title)
|
visit admin_conference_questions_path(conference2.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_sponsorship_level_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:sponsorship_level, conference: conference2)
|
|
||||||
visit edit_admin_conference_sponsorship_level_path(conference2.short_title, conference2.sponsorship_levels.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_sponsors_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_sponsor_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:sponsor, conference: conference2, sponsorship_level: conference2.sponsorship_levels.first)
|
|
||||||
visit edit_admin_conference_sponsor_path(conference2.short_title, conference2.sponsors.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_tickets_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_ticket_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:ticket, conference: conference2)
|
|
||||||
visit edit_admin_conference_ticket_path(conference2.short_title, conference2.tickets.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_campaigns_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_campaign_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:campaign, conference: conference2)
|
|
||||||
visit edit_admin_conference_campaign_path(conference2.short_title, conference2.campaigns.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_targets_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_target_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:target, conference: conference2)
|
|
||||||
visit edit_admin_conference_target_path(conference2.short_title, conference2.targets.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_program_tracks_path(conference2.short_title)
|
visit admin_conference_program_tracks_path(conference2.short_title)
|
||||||
expect(current_path).to eq(admin_conference_program_tracks_path(conference2.short_title))
|
expect(current_path).to eq(admin_conference_program_tracks_path(conference2.short_title))
|
||||||
|
|
||||||
|
|
@ -447,38 +549,25 @@ feature 'Has correct abilities' do
|
||||||
|
|
||||||
visit admin_conference_emails_path(conference2.short_title)
|
visit admin_conference_emails_path(conference2.short_title)
|
||||||
expect(current_path).to eq(admin_conference_emails_path(conference2.short_title))
|
expect(current_path).to eq(admin_conference_emails_path(conference2.short_title))
|
||||||
|
|
||||||
visit admin_conference_resources_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(admin_conference_resources_path(conference2.short_title))
|
|
||||||
|
|
||||||
visit new_admin_conference_resource_path(conference2.short_title)
|
|
||||||
expect(current_path).to eq(new_admin_conference_resource_path(conference2.short_title))
|
|
||||||
|
|
||||||
create(:resource, conference: conference2)
|
|
||||||
visit edit_admin_conference_resource_path(conference2.short_title, conference2.resources.first)
|
|
||||||
expect(current_path).to eq(edit_admin_conference_resource_path(conference2.short_title, conference2.resources.first))
|
|
||||||
|
|
||||||
visit admin_revision_history_path
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'when user is info desk' do
|
it_behaves_like 'correct abilities for cfps and info_desk', 'cfp'
|
||||||
sign_in user_info_desk
|
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)
|
visit admin_conference_path(conference3.short_title)
|
||||||
expect(current_path).to eq(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 have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||||
expect(page).to_not have_link('Basics', href: "/admin/conferences/#{conference3.short_title}/edit")
|
|
||||||
expect(page).to have_text('Basics')
|
|
||||||
expect(page).to_not have_link('Contact', href: "/admin/conferences/#{conference3.short_title}/contact/edit")
|
|
||||||
expect(page).to have_link('Commercials', href: "/admin/conferences/#{conference3.short_title}/commercials")
|
|
||||||
expect(page).to_not have_link('Splashpage', href: "/admin/conferences/#{conference3.short_title}/splashpage")
|
|
||||||
expect(page).to_not have_link('Venue', href: "/admin/conferences/#{conference3.short_title}/venue")
|
expect(page).to_not have_link('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('Rooms', href: "/admin/conferences/#{conference3.short_title}/venue/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conferences/#{conference3.short_title}/lodgings")
|
|
||||||
expect(page).to_not have_link('Program', href: "/admin/conferences/#{conference3.short_title}/program")
|
expect(page).to_not have_link('Program', href: "/admin/conferences/#{conference3.short_title}/program")
|
||||||
expect(page).to_not have_link('Call for Papers', href: "/admin/conferences/#{conference2.short_title}/program/cfp")
|
expect(page).to_not have_link('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('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('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('Event Types', href: "/admin/conferences/#{conference3.short_title}/program/event_types")
|
||||||
|
|
@ -486,40 +575,8 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to_not have_link('Schedules', href: "/admin/conferences/#{conference3.short_title}/schedules")
|
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_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('Registrations', href: "/admin/conferences/#{conference3.short_title}/registrations")
|
||||||
expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference3.short_title}/registration_period")
|
|
||||||
expect(page).to have_link('Questions', href: "/admin/conferences/#{conference3.short_title}/questions")
|
expect(page).to have_link('Questions', href: "/admin/conferences/#{conference3.short_title}/questions")
|
||||||
expect(page).to_not have_text('Donations')
|
|
||||||
expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference3.short_title}/sponsorship_levels")
|
|
||||||
expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference3.short_title}/sponsors")
|
|
||||||
expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference3.short_title}/tickets")
|
|
||||||
expect(page).to_not have_text('Objectives')
|
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference3.short_title}/campaigns")
|
|
||||||
expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference3.short_title}/targets")
|
|
||||||
expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference3.short_title}/emails")
|
expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference3.short_title}/emails")
|
||||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference3.short_title}/roles")
|
|
||||||
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference3.short_title}/resources")
|
|
||||||
|
|
||||||
visit edit_admin_conference_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit edit_admin_conference_contact_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_commercials_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(admin_conference_commercials_path(conference3.short_title))
|
|
||||||
|
|
||||||
visit new_admin_conference_splashpage_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit edit_admin_conference_splashpage_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_venue_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
conference3.venue = create(:venue)
|
|
||||||
visit edit_admin_conference_venue_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_venue_rooms_path(conference3.short_title)
|
visit admin_conference_venue_rooms_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
@ -528,16 +585,6 @@ feature 'Has correct abilities' do
|
||||||
visit edit_admin_conference_venue_room_path(conference3.short_title, conference3.venue.rooms.first)
|
visit edit_admin_conference_venue_room_path(conference3.short_title, conference3.venue.rooms.first)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_lodgings_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_lodging_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:lodging, conference: conference3)
|
|
||||||
visit edit_admin_conference_lodging_path(conference3.short_title, conference3.lodgings.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_program_path(conference3.short_title)
|
visit new_admin_conference_program_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
|
|
@ -547,7 +594,7 @@ feature 'Has correct abilities' do
|
||||||
visit new_admin_conference_program_cfp_path(conference3.short_title)
|
visit new_admin_conference_program_cfp_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit edit_admin_conference_program_cfp_path(conference3.short_title, conference3.program.cfp)
|
visit edit_admin_conference_program_cfp_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_program_events_path(conference3.short_title)
|
visit admin_conference_program_events_path(conference3.short_title)
|
||||||
|
|
@ -592,86 +639,16 @@ feature 'Has correct abilities' do
|
||||||
visit edit_admin_conference_registration_path(conference3.short_title, conference3.registrations.first)
|
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))
|
expect(current_path).to eq(edit_admin_conference_registration_path(conference3.short_title, conference3.registrations.first))
|
||||||
|
|
||||||
visit new_admin_conference_registration_period_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:registration_period, conference: conference3)
|
|
||||||
visit edit_admin_conference_registration_period_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_questions_path(conference3.short_title)
|
visit admin_conference_questions_path(conference3.short_title)
|
||||||
expect(current_path).to eq(admin_conference_questions_path(conference3.short_title))
|
expect(current_path).to eq(admin_conference_questions_path(conference3.short_title))
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_sponsorship_level_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:sponsorship_level, conference: conference3)
|
|
||||||
visit edit_admin_conference_sponsorship_level_path(conference3.short_title, conference3.sponsorship_levels.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_sponsors_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_sponsor_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:sponsor, conference: conference3, sponsorship_level: conference3.sponsorship_levels.first)
|
|
||||||
visit edit_admin_conference_sponsor_path(conference3.short_title, conference3.sponsors.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_tickets_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_ticket_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:ticket, conference: conference3)
|
|
||||||
visit edit_admin_conference_ticket_path(conference3.short_title, conference3.tickets.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_campaigns_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_campaign_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:campaign, conference: conference3)
|
|
||||||
visit edit_admin_conference_campaign_path(conference3.short_title, conference3.campaigns.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_targets_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit new_admin_conference_target_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
create(:target, conference: conference3)
|
|
||||||
visit edit_admin_conference_target_path(conference3.short_title, conference3.targets.first)
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
|
|
||||||
visit admin_conference_program_tracks_path(conference3.short_title)
|
visit admin_conference_program_tracks_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_roles_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(admin_conference_roles_path(conference3.short_title))
|
|
||||||
|
|
||||||
visit admin_conference_emails_path(conference3.short_title)
|
visit admin_conference_emails_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
end
|
||||||
|
|
||||||
visit admin_conference_resources_path(conference3.short_title)
|
it_behaves_like 'correct abilities for cfps and info_desk', 'info_desk'
|
||||||
expect(current_path).to eq(admin_conference_resources_path(conference3.short_title))
|
|
||||||
|
|
||||||
visit new_admin_conference_resource_path(conference3.short_title)
|
|
||||||
expect(current_path).to eq(new_admin_conference_resource_path(conference3.short_title))
|
|
||||||
|
|
||||||
create(:resource, conference: conference3)
|
|
||||||
visit edit_admin_conference_resource_path(conference3.short_title, conference3.resources.first)
|
|
||||||
expect(current_path).to eq(edit_admin_conference_resource_path(conference3.short_title, conference3.resources.first))
|
|
||||||
|
|
||||||
visit admin_revision_history_path
|
|
||||||
expect(current_path).to eq(root_path)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
51
spec/features/organization_spec.rb
Normal file
51
spec/features/organization_spec.rb
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature Organization do
|
||||||
|
let!(:organization) { create(:organization) }
|
||||||
|
let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||||
|
let(:organization_admin) { create(:user, role_ids: [organization_admin_role.id]) }
|
||||||
|
let(:admin_user) { create(:admin) }
|
||||||
|
|
||||||
|
shared_examples 'successfully updates a organization' do
|
||||||
|
scenario 'updates a exsisting organization', feature: true, js: true do
|
||||||
|
visit edit_admin_organization_path(organization)
|
||||||
|
fill_in 'organization_name', with: 'changed name'
|
||||||
|
|
||||||
|
click_button 'Update Organization'
|
||||||
|
|
||||||
|
organization.reload
|
||||||
|
expect(flash).to eq('Organization successfully updated')
|
||||||
|
expect(organization.name).to eq('changed name')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'signed in as site admin' do
|
||||||
|
before do
|
||||||
|
sign_in admin_user
|
||||||
|
end
|
||||||
|
scenario 'creates a new organization', feature: true, js: true do
|
||||||
|
visit new_admin_organization_path
|
||||||
|
fill_in 'organization_name', with: 'Organization name'
|
||||||
|
|
||||||
|
click_button 'Create Organization'
|
||||||
|
|
||||||
|
expect(flash).to eq('Organization successfully created')
|
||||||
|
expect(Organization.last.name).to eq('Organization name')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'successfully updates a organization'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'signed in as organization admin' do
|
||||||
|
before do
|
||||||
|
sign_in organization_admin
|
||||||
|
end
|
||||||
|
scenario "can't create new organization", feature: true, js: true do
|
||||||
|
visit new_admin_organization_path
|
||||||
|
|
||||||
|
expect(flash).to eq('You are not authorized to access this page.')
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'successfully updates a organization'
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue