diff --git a/app/models/reservation.rb b/app/models/reservation.rb index fa0f5f0cf..ab9f353d4 100644 --- a/app/models/reservation.rb +++ b/app/models/reservation.rb @@ -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 diff --git a/app/services/users_credits/manager.rb b/app/services/users_credits/manager.rb index 6fa9b7398..ce0016575 100644 --- a/app/services/users_credits/manager.rb +++ b/app/services/users_credits/manager.rb @@ -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