Update ConferenceRegistrationsController#new

- authenticate on all controller actions unless (OSEM_ICHAIN_ENABLED != true and
  action is 'new' or 'create')

- before_filter rename to before_action

- addition of before_action :user_already_registered on :new action (redirects
  to edit if user already registered)

- increased specs
This commit is contained in:
charliequinn 2016-08-19 14:49:59 +01:00
parent c6be0999b9
commit af08dabc12
3 changed files with 78 additions and 46 deletions

View file

@ -45,16 +45,17 @@ class Ability
# can view Commercials of confirmed Events
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
can [:show, :create], User
can [:new, :create], Registration do |registration|
conference = registration.conference
conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?
end
unless ENV['OSEM_ICHAIN_ENABLED'] == 'true'
can :show, Registration do |registration|
registration.new_record?
end
can [:new, :create], Registration do |registration|
conference = registration.conference
conference.registration_open? && registration.new_record? && !conference.registration_limit_exceeded?
end
can :show, Event do |event|
event.new_record?
end
@ -74,11 +75,6 @@ class Ability
can :manage, Registration, user_id: user.id
can [:new, :create], Registration do |registration|
conference = registration.conference
conference.registration_open? && !conference.registration_limit_exceeded?
end
can :index, Ticket
can :manage, TicketPurchase, user_id: user.id
can [:new, :create], Payment, user_id: user.id