Rework cfp abilities
This commit is contained in:
parent
5f3b48c9f7
commit
f37d3095e1
4 changed files with 20 additions and 4 deletions
|
|
@ -29,3 +29,4 @@ Metrics/ClassLength:
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'spec/models/conference_spec.rb'
|
- 'spec/models/conference_spec.rb'
|
||||||
|
- 'spec/features/ability_spec.rb'
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,11 @@ class Ability
|
||||||
cannot :destroy, Venue do |venue|
|
cannot :destroy, Venue do |venue|
|
||||||
venue.conference.program.events.where.not(room_id: nil).any?
|
venue.conference.program.events.where.not(room_id: nil).any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Can't create cfp if there are no available cfp types
|
||||||
|
cannot [:new, :create], Cfp do |cfp|
|
||||||
|
cfp.program.remaining_cfp_types.empty?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def signed_in_with_organizer_role(user)
|
def signed_in_with_organizer_role(user)
|
||||||
|
|
@ -166,7 +171,7 @@ class Ability
|
||||||
can :manage, Program, conference_id: conf_ids_for_organizer
|
can :manage, Program, conference_id: conf_ids_for_organizer
|
||||||
can :manage, Schedule, program: { conference_id: conf_ids_for_organizer }
|
can :manage, Schedule, program: { conference_id: conf_ids_for_organizer }
|
||||||
can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids_for_organizer } }
|
can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids_for_organizer } }
|
||||||
can :manage, Cfp, program: { conference_id: conf_ids_for_organizer}
|
can :manage, Cfp, program: { conference_id: conf_ids_for_organizer }
|
||||||
can :manage, Event, program: { conference_id: conf_ids_for_organizer}
|
can :manage, Event, program: { conference_id: conf_ids_for_organizer}
|
||||||
can :manage, EventType, program: { conference_id: conf_ids_for_organizer}
|
can :manage, EventType, program: { conference_id: conf_ids_for_organizer}
|
||||||
can :manage, Track, program: { conference_id: conf_ids_for_organizer}
|
can :manage, Track, program: { conference_id: conf_ids_for_organizer}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
.btn-group
|
.btn-group
|
||||||
= link_to 'Edit', edit_admin_conference_program_cfp_path(@conference.short_title, cfp.id), method: :get, class: 'btn btn-primary'
|
= link_to 'Edit', edit_admin_conference_program_cfp_path(@conference.short_title, cfp.id), method: :get, class: 'btn btn-primary'
|
||||||
= link_to 'Delete', admin_conference_program_cfp_path(@conference.short_title, cfp.id), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete the CfP?' }
|
= link_to 'Delete', admin_conference_program_cfp_path(@conference.short_title, cfp.id), method: 'delete', class: 'btn btn-danger', data: { confirm: 'Are you sure you want to delete the CfP?' }
|
||||||
- if @program.remaining_cfp_types.length > 0
|
- if can? :new, @program.cfps.new
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
= link_to 'Create Call for Papers', new_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary'
|
= link_to 'Create Call for Papers', new_admin_conference_program_cfp_path(@conference.short_title), class: 'btn btn-primary'
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,12 @@ feature 'Has correct abilities' do
|
||||||
expect(current_path).to eq(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)
|
visit new_admin_conference_program_cfp_path(conference1.short_title)
|
||||||
expect(current_path).to eq(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)
|
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))
|
expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference1.short_title, conference1.program.cfp))
|
||||||
|
|
@ -322,7 +327,12 @@ 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(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)
|
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))
|
expect(current_path).to eq(edit_admin_conference_program_cfp_path(conference2.short_title, conference2.program.cfp))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue