mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
UsersCredits::Manager accept an event Reservation but do not do nothing, acting as a blackbox
This commit is contained in:
parent
34648c7e9e
commit
ed478f95c7
@ -219,7 +219,7 @@ class Reservation < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
UsersCredits::Manager.new(reservation: self).update_credits unless reservable_type == 'Event'
|
||||
UsersCredits::Manager.new(reservation: self).update_credits
|
||||
true
|
||||
end
|
||||
end
|
||||
@ -252,7 +252,7 @@ class Reservation < ActiveRecord::Base
|
||||
if user.invoicing_disabled?
|
||||
if valid?
|
||||
save!
|
||||
UsersCredits::Manager.new(reservation: self).update_credits unless reservable_type == 'Event'
|
||||
UsersCredits::Manager.new(reservation: self).update_credits
|
||||
return true
|
||||
end
|
||||
else
|
||||
@ -279,7 +279,7 @@ class Reservation < ActiveRecord::Base
|
||||
save!
|
||||
end
|
||||
|
||||
UsersCredits::Manager.new(reservation: self).update_credits unless reservable_type == 'Event'
|
||||
UsersCredits::Manager.new(reservation: self).update_credits
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -15,8 +15,10 @@ module UsersCredits
|
||||
@manager = Managers::Training.new(reservation, plan)
|
||||
elsif reservation.reservable_type == "Machine"
|
||||
@manager = Managers::Machine.new(reservation, plan)
|
||||
elsif reservation.reservable_type == "Event"
|
||||
@manager = Managers::Event.new(reservation, plan)
|
||||
else
|
||||
raise ArgumentError, "reservation.reservable_type must be Training or Machine"
|
||||
raise ArgumentError, "reservation.reservable_type must be Training, Machine or Event"
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "you have to pass either a reservation or a user to initialize a UsersCredits::Manager"
|
||||
@ -141,5 +143,14 @@ module UsersCredits
|
||||
return false, nil
|
||||
end
|
||||
end
|
||||
|
||||
class Event < Reservation
|
||||
def will_use_credits?
|
||||
false
|
||||
end
|
||||
|
||||
def update_credits
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user