Merge pull request #3803 from RedZapdos123/fix-commercial-auth

Fix: event commercial permissions in non-admin flow
This commit is contained in:
Henne Vogelsang 2026-06-18 17:29:24 +02:00 committed by GitHub
commit cb5ad735c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View file

@ -152,6 +152,8 @@ class Ability
can :manage, Registration, conference_id: conf_ids_for_organizer can :manage, Registration, conference_id: conf_ids_for_organizer
# To access conference/proposals # To access conference/proposals
can :manage, Event, program: { conference_id: conf_ids_for_organizer } can :manage, Event, program: { conference_id: conf_ids_for_organizer }
can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
# To access comment link in menu bar # To access comment link in menu bar
can :index, Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
@ -163,6 +165,8 @@ class Ability
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
# To access conference/proposals # To access conference/proposals
can :manage, Event, program: { conference_id: conf_ids_for_cfp } can :manage, Event, program: { conference_id: conf_ids_for_cfp }
can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
end end
if conf_ids_for_info_desk if conf_ids_for_info_desk

View file

@ -264,5 +264,31 @@ describe 'User' do
it{ should_not be_able_to(:edit, other_self_organized_track) } it{ should_not be_able_to(:edit, other_self_organized_track) }
it{ should_not be_able_to(:update, other_self_organized_track) } it{ should_not be_able_to(:update, other_self_organized_track) }
end end
context 'when user is organizer of conference' do
let(:conference) { create(:conference) }
let(:user) { create(:organizer, resource: conference) }
let(:event_in_conference) { create(:event, program: conference.program) }
let(:event_in_other_conference) { create(:event) }
let(:commercial_in_conference) { create(:commercial, commercialable: event_in_conference) }
let(:commercial_in_other_conference) { create(:commercial, commercialable: event_in_other_conference) }
it{ should be_able_to(:create, event_in_conference.commercials.new) }
it{ should be_able_to(:manage, commercial_in_conference) }
it{ should_not be_able_to(:manage, commercial_in_other_conference) }
end
context 'when user is on cfp team of conference' do
let(:conference) { create(:conference) }
let(:user) { create(:cfp_user, resource: conference) }
let(:event_in_conference) { create(:event, program: conference.program) }
let(:event_in_other_conference) { create(:event) }
let(:commercial_in_conference) { create(:commercial, commercialable: event_in_conference) }
let(:commercial_in_other_conference) { create(:commercial, commercialable: event_in_other_conference) }
it{ should be_able_to(:create, event_in_conference.commercials.new) }
it{ should be_able_to(:manage, commercial_in_conference) }
it{ should_not be_able_to(:manage, commercial_in_other_conference) }
end
end end
end end