diff --git a/app/models/ability.rb b/app/models/ability.rb index 6713127c..18f9d4c4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -75,7 +75,9 @@ class Ability can [:new, :create], Payment, user_id: user.id can [:index, :show], PhysicalTicket, user: user - can [:new, :create], Booth + can [:new, :create], Booth do |booth| + booth.new_record? && booth.conference.program.cfps.for_booths.try(:open?) + end can [:edit, :update, :index, :show], Booth do |booth| booth.users.include?(user) diff --git a/app/models/cfp.rb b/app/models/cfp.rb index 8248cd1a..17b37809 100644 --- a/app/models/cfp.rb +++ b/app/models/cfp.rb @@ -94,6 +94,15 @@ class Cfp < ActiveRecord::Base find_by(cfp_type: 'tracks') end + ## + # Finds the cfp for booths if it exists + # + # ====Returns + # * +Cfp+ -> The cfp with type 'booths' + def self.for_booths + find_by(cfp_type: 'booths') + end + private def before_end_of_conference diff --git a/spec/controllers/booths_controller_spec.rb b/spec/controllers/booths_controller_spec.rb index 243bc6e2..56f3b9d9 100644 --- a/spec/controllers/booths_controller_spec.rb +++ b/spec/controllers/booths_controller_spec.rb @@ -8,6 +8,7 @@ describe BoothsController do context 'user is signed in with submitter role' do before :each do + create(:cfp, program: conference.program, cfp_type: 'booths') sign_in booth.submitter end