1
0
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:
Nicolas Florentin 2016-04-20 11:24:28 +02:00
parent 34648c7e9e
commit ed478f95c7
2 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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