Skip to content

Commit

Permalink
Remove hardcoded created_by user from returns methods
Browse files Browse the repository at this point in the history
This applies only to some deprecated blocks and does not
change the new, working logic.

This means that if those methods were used by some store or
extension, they will now don't have the creator set instead
of having a specific user that could even be not present in the
database, causing the creator to be nil anyway.
  • Loading branch information
kennyadsl committed Nov 1, 2018
1 parent 69f7165 commit 05b6354
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/app/models/spree/order_cancellations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodu
# @return [Reimbursement] the reimbursement for inventory being canceled
def reimburse_units(inventory_units, created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #reimburse_units on #{self} without created_by is deprecated")
end
reimbursement = nil
Expand Down
3 changes: 0 additions & 3 deletions core/app/models/spree/reimbursement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def unpaid_amount

def perform!(created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
end
reimbursement_tax_calculator.call(self)
Expand All @@ -122,7 +121,6 @@ def perform!(created_by: nil)

def simulate(created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
end
reimbursement_simulator_tax_calculator.call(self)
Expand Down Expand Up @@ -151,7 +149,6 @@ def all_exchanges?
# @return [void]
def return_all(created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #return_all on #{self} without created_by is deprecated")
end
return_items.each(&:accept!)
Expand Down
2 changes: 0 additions & 2 deletions core/app/models/spree/reimbursement_performer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class << self
# so they can be displayed in the Admin UI appropriately.
def simulate(reimbursement, created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
end
execute(reimbursement, true, created_by: created_by)
Expand All @@ -22,7 +21,6 @@ def simulate(reimbursement, created_by: nil)
# Actually perform the reimbursement
def perform(reimbursement, created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
end
execute(reimbursement, false, created_by: created_by)
Expand Down
1 change: 0 additions & 1 deletion core/app/models/spree/reimbursement_type/credit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ReimbursementType::Credit < Spree::ReimbursementType
class << self
def reimburse(reimbursement, return_items, simulate, created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
end
unpaid_amount = return_items.sum(&:total).round(2, :down)
Expand Down
1 change: 0 additions & 1 deletion core/app/models/spree/reimbursement_type/store_credit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Spree::ReimbursementType::StoreCredit < Spree::ReimbursementType
class << self
def reimburse(reimbursement, return_items, simulate, created_by: nil)
unless created_by
created_by = Spree.user_class.find_by(email: 'spree@example.com')
Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
end
unpaid_amount = return_items.sum(&:total).to_d.round(2, :down)
Expand Down

0 comments on commit 05b6354

Please sign in to comment.