Adapt ability to allow proposal creation if cfp is open

This was not possible before when iChain was enabled.
- Initialize @event object now with load_and_autorize before filter
- Remove not necessary event_users initilization in :new action
- Adapt ability and feature tests
This commit is contained in:
Christian Bruckmayer 2016-05-19 11:47:41 +02:00
parent 65ee166570
commit 406e37a1d8
4 changed files with 16 additions and 24 deletions

View file

@ -82,14 +82,12 @@ class Ability
can [:create, :destroy], Subscription, user_id: user.id
can :manage, Event do |event|
event.users.include?(user)
can [:new, :create], Event do |event|
event.program.cfp_open? && event.new_record?
end
# cannot create an event if program does not have open cfp
cannot [:new, :create], Event do |event|
user_inclusion = event.event_users.map { |event_user| event_user.user.id }.compact.include? user.id
!event.program.cfp_open? || !event.new_record? || !user_inclusion
can [:update, :show, :delete, :index], Event do |event|
event.users.include?(user)
end
# can manage the commercials of their own events