Implement track requests and add the track organizer role
About track requests: Create migration that adds the fields submitter_id, state, and cfp_active to Tracks Add validations and the self_organized? method to the Track model Create a new TracksController outide of the admin namespace Create the relevant views for index, show, new and edit Modify the admin views for tracks to include extra info for self-organized tracks About track organizers: Create the role when a self-organized track is created Define track organizer abilities Modify the roles views and controller to handle the new role The route for Roles#edit needs to have higher priority than the nested routes for track roles, otherwise, the word edit in the url is matched as a track with short_name edit
This commit is contained in:
parent
98fc1137e1
commit
68fc750e9f
26 changed files with 766 additions and 27 deletions
|
|
@ -5,5 +5,11 @@ FactoryGirl.define do
|
|||
color { Faker::Color.hex_color }
|
||||
short_name { SecureRandom.urlsafe_base64(5) }
|
||||
program
|
||||
|
||||
trait :self_organized do
|
||||
association :submitter, factory: :user
|
||||
state 'new'
|
||||
cfp_active false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
244
spec/features/track_organizer_ability_spec.rb
Normal file
244
spec/features/track_organizer_ability_spec.rb
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Has correct abilities' do
|
||||
|
||||
let(:organization) { create(:organization) }
|
||||
let(:conference) { create(:full_conference, organization: organization) }
|
||||
let(:self_organized_track) { create(:track, :self_organized, program: conference.program) }
|
||||
let(:role_track_organizer) { Role.find_by(name: 'track_organizer', resource: self_organized_track) }
|
||||
let(:user_track_organizer) { create(:user, role_ids: [role_track_organizer.id]) }
|
||||
|
||||
context 'when user is info desk' do
|
||||
before do
|
||||
sign_in user_track_organizer
|
||||
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_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('Lodgings', href: "/admin/conferences/#{conference.short_title}/lodgings")
|
||||
expect(page).to 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 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_not have_link('Registrations', href: "/admin/conferences/#{conference.short_title}/registrations")
|
||||
expect(page).to_not have_link('Registration Period', href: "/admin/conferences/#{conference.short_title}/registration_period")
|
||||
expect(page).to_not have_link('Questions', href: "/admin/conferences/#{conference.short_title}/questions")
|
||||
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_not 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_not have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
expect(page).to_not have_link('New Conference', href: '/admin/conferences/new')
|
||||
|
||||
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_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 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_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
|
||||
|
||||
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 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 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 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_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_program_tracks_path(conference.short_title)
|
||||
expect(current_path).to eq admin_conference_program_tracks_path(conference.short_title)
|
||||
|
||||
visit new_admin_conference_program_track_path(conference.short_title)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
other_track = create(:track, program: conference.program)
|
||||
visit admin_conference_program_track_path(conference.short_title, other_track.short_name)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit edit_admin_conference_program_track_path(conference.short_title, other_track.short_name)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit admin_conference_program_track_path(conference.short_title, self_organized_track.short_name)
|
||||
expect(current_path).to eq admin_conference_program_track_path(conference.short_title, self_organized_track.short_name)
|
||||
|
||||
visit edit_admin_conference_program_track_path(conference.short_title, self_organized_track.short_name)
|
||||
expect(current_path).to eq edit_admin_conference_program_track_path(conference.short_title, self_organized_track.short_name)
|
||||
|
||||
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 root_path
|
||||
|
||||
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 root_path
|
||||
|
||||
visit admin_revision_history_path
|
||||
expect(current_path).to eq root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -44,6 +44,8 @@ describe 'User with admin role' do
|
|||
let!(:my_event_schedule) { create(:event_schedule, schedule: my_schedule) }
|
||||
let!(:other_event_schedule) { create(:event_schedule, schedule: other_schedule) }
|
||||
|
||||
let!(:my_self_organized_track) { create(:track, :self_organized, program: my_conference.program) }
|
||||
|
||||
context 'user #is_admin?' do
|
||||
let(:venue) { my_conference.venue }
|
||||
let(:room) { create(:room, venue: venue) }
|
||||
|
|
@ -69,6 +71,19 @@ describe 'User with admin role' do
|
|||
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
|
||||
|
||||
context 'accesses track organizers' do
|
||||
before :each do
|
||||
other_self_organized_track = create(:track, :self_organized)
|
||||
@other_track_organizer_role = Role.find_by(name: 'track_organizer', resource: other_self_organized_track)
|
||||
end
|
||||
|
||||
it{ should_not be_able_to(:toggle_user, @other_track_organizer_role) }
|
||||
it{ should_not be_able_to(:update, @other_track_organizer_role) }
|
||||
it{ should_not be_able_to(:edit, @other_track_organizer_role) }
|
||||
it{ should be_able_to(:show, @other_track_organizer_role) }
|
||||
it{ should be_able_to(:index, @other_track_organizer_role) }
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'user with non-organizer role' do |role_name|
|
||||
|
|
@ -83,6 +98,22 @@ describe 'User with admin role' do
|
|||
it{ should be_able_to(:show, Role.find_by(name: role, resource: my_conference)) }
|
||||
it{ should be_able_to(:index, Role.find_by(name: role, resource: my_conference)) }
|
||||
end
|
||||
|
||||
context 'accesses track organizers' do
|
||||
before :each do
|
||||
@track_organizer_role = Role.find_by(name: 'track_organizer', resource: my_self_organized_track)
|
||||
end
|
||||
|
||||
if role_name == 'track_organizer'
|
||||
it{ should be_able_to(:toggle_user, @track_organizer_role) }
|
||||
else
|
||||
it{ should_not be_able_to(:toggle_user, @track_organizer_role) }
|
||||
end
|
||||
it{ should_not be_able_to(:update, @track_organizer_role) }
|
||||
it{ should_not be_able_to(:edit, @track_organizer_role) }
|
||||
it{ should be_able_to(:show, @track_organizer_role) }
|
||||
it{ should be_able_to(:index, @track_organizer_role) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has the role organization_admin' do
|
||||
|
|
@ -186,6 +217,18 @@ describe 'User with admin role' do
|
|||
it{ should be_able_to(:index, Role.find_by(name: role, resource: my_conference)) }
|
||||
end
|
||||
|
||||
context 'can manage track organizers' do
|
||||
before :each do
|
||||
@track_organizer_role = Role.find_by(name: 'track_organizer', resource: my_self_organized_track)
|
||||
end
|
||||
|
||||
it{ should be_able_to(:toggle_user, @track_organizer_role) }
|
||||
it{ should be_able_to(:edit, @track_organizer_role) }
|
||||
it{ should be_able_to(:update, @track_organizer_role) }
|
||||
it{ should be_able_to(:show, @track_organizer_role) }
|
||||
it{ should be_able_to(:index, @track_organizer_role) }
|
||||
end
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
end
|
||||
|
||||
|
|
@ -392,5 +435,74 @@ describe 'User with admin role' do
|
|||
it_behaves_like 'user with any role'
|
||||
it_behaves_like 'user with non-organizer role', 'volunteers_coordinator'
|
||||
end
|
||||
|
||||
context 'when user has the role track_organizer' do
|
||||
let(:role) { Role.find_by(name: 'track_organizer', resource: my_self_organized_track) }
|
||||
let(:user) { create(:user, role_ids: [role.id]) }
|
||||
let(:new_track) { build(:track, program: my_conference.program) }
|
||||
|
||||
it{ should_not be_able_to(:new, Conference.new) }
|
||||
it{ should_not be_able_to(:create, Conference.new) }
|
||||
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) }
|
||||
it{ should_not be_able_to(:manage, conference_public.splashpage) }
|
||||
it{ should_not be_able_to(:manage, my_conference.contact) }
|
||||
it{ should_not be_able_to(:manage, conference_public.contact) }
|
||||
it{ should_not be_able_to(:manage, my_conference.email_settings) }
|
||||
it{ should_not be_able_to(:manage, conference_public.email_settings) }
|
||||
it{ should_not be_able_to(:manage, my_conference.campaigns.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.campaigns.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.targets.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.targets.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.commercials.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.commercials.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.registration_period) }
|
||||
it{ should_not be_able_to(:manage, conference_public.registration_period) }
|
||||
it{ should_not be_able_to(:manage, my_conference.questions.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.questions.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.program.cfp) }
|
||||
it{ should_not be_able_to(:manage, conference_public.program.cfp) }
|
||||
it{ should_not be_able_to(:manage, my_schedule) }
|
||||
it{ should_not be_able_to(:manage, other_schedule) }
|
||||
it{ should_not be_able_to(:manage, my_event_schedule) }
|
||||
it{ should_not be_able_to(:manage, other_event_schedule) }
|
||||
it{ should_not be_able_to(:manage, my_conference.venue) }
|
||||
it{ should_not be_able_to(:show, my_conference.venue) }
|
||||
it{ should_not be_able_to(:manage, conference_public.venue) }
|
||||
it{ should_not be_able_to(:manage, my_conference.lodgings.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.lodgings.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.sponsors.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.sponsors.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.sponsorship_levels.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.sponsorship_levels.first) }
|
||||
it{ should_not be_able_to(:manage, my_conference.tickets.first) }
|
||||
it{ should_not be_able_to(:manage, conference_public.tickets.first) }
|
||||
|
||||
it{ should_not be_able_to(:manage, registration) }
|
||||
it{ should_not be_able_to(:manage, other_registration) }
|
||||
|
||||
it{ should_not be_able_to(:manage, my_event) }
|
||||
it{ should_not be_able_to(:manage, other_event) }
|
||||
it{ should_not be_able_to(:manage, my_event.event_type) }
|
||||
it{ should_not be_able_to(:manage, other_event.event_type) }
|
||||
it{ should_not be_able_to(:manage, my_event.track) }
|
||||
it{ should_not be_able_to(:manage, other_event.track) }
|
||||
it{ should_not be_able_to(:manage, my_event.difficulty_level) }
|
||||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||
it{ should_not be_able_to(:manage, my_event.commercials.first) }
|
||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||
it{ should_not be_able_to(:index, my_event.comment_threads.first) }
|
||||
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
|
||||
|
||||
it{ should_not be_able_to(:manage, resource) }
|
||||
|
||||
it{ should be_able_to(:show, my_conference.program) }
|
||||
it{ should be_able_to(:update, new_track) }
|
||||
it{ should be_able_to(:manage, my_self_organized_track) }
|
||||
|
||||
it_behaves_like 'user with any role'
|
||||
it_behaves_like 'user with non-organizer role', 'track_organizer'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
57
spec/models/track_spec.rb
Normal file
57
spec/models/track_spec.rb
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Track do
|
||||
subject { create(:track) }
|
||||
let(:track) { create(:track) }
|
||||
let(:self_organized_track) { create(:track, :self_organized) }
|
||||
|
||||
describe 'association' do
|
||||
it { is_expected.to belong_to(:program) }
|
||||
it { is_expected.to belong_to(:submitter).class_name('User') }
|
||||
it { is_expected.to have_many(:events) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
it 'has a valid factory' do
|
||||
expect(build(:track)).to be_valid
|
||||
end
|
||||
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
it { is_expected.to allow_value('#ABCDEF').for(:color) }
|
||||
it { is_expected.to allow_value('#124689').for(:color) }
|
||||
it { is_expected.to validate_presence_of(:short_name) }
|
||||
it { is_expected.to allow_value('My_track_name').for(:short_name) }
|
||||
it { is_expected.to_not allow_value('My track name').for(:short_name) }
|
||||
it { is_expected.to validate_uniqueness_of(:short_name).scoped_to(:program_id) }
|
||||
|
||||
context 'when self-organized' do
|
||||
before :each do
|
||||
allow(subject).to receive(:self_organized?).and_return(true)
|
||||
end
|
||||
|
||||
it { is_expected.to validate_presence_of(:state) }
|
||||
it { is_expected.to validate_inclusion_of(:cfp_active).in_array([true, false]) }
|
||||
end
|
||||
|
||||
context 'when regular' do
|
||||
before :each do
|
||||
allow(subject).to receive(:self_organized?).and_return(false)
|
||||
end
|
||||
|
||||
it { is_expected.to_not validate_presence_of(:state) }
|
||||
it { is_expected.to_not validate_inclusion_of(:cfp_active) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#self_organized?' do
|
||||
it 'returns true when it has a submitter' do
|
||||
expect(self_organized_track.submitter).to be_a User
|
||||
expect(self_organized_track.self_organized?).to eq true
|
||||
end
|
||||
|
||||
it 'returns false when it doesn\'t have a submitter' do
|
||||
expect(track.submitter).to eq nil
|
||||
expect(track.self_organized?).to eq false
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue