Skip to content

Commit

Permalink
Rename to StoreCreditPrioritizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtrademarked committed Nov 4, 2022
1 parent 174dbe1 commit f385be9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def add_store_credit_payments

if matching_store_credits.any?
payment_method = Spree::PaymentMethod::StoreCredit.first
sorter = Spree::Config.order_credit_sorter_class.new(matching_store_credits, self)
sorter = Spree::Config.store_credit_prioritizer_class.new(matching_store_credits, self)

sorter.call.each do |credit|
break if remaining_total.zero?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Spree
class OrderCreditSorter
class StoreCreditPrioritizer
def initialize(credits, _order)
@credits = credits
end
Expand Down
17 changes: 9 additions & 8 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,6 @@ def default_pricing_options
# Spree::OrderContents.
class_name_attribute :order_contents_class, default: 'Spree::OrderContents'

# Allows providing your own class for prioritizing store credit application
# to an order.
#
# @!attribute [rw] order_credit_sorter_class
# @return [Class] a class with the same public interfaces as
# Spree::OrderCreditSorter.
class_name_attribute :order_credit_sorter_class, default: 'Spree::OrderCreditSorter'

# Allows providing your own class for shipping an order.
#
# @!attribute [rw] order_shipping_class
Expand Down Expand Up @@ -540,6 +532,15 @@ def payment_canceller
small: '400x400>',
product: '680x680>',
large: '1200x1200>' }

# Allows providing your own class for prioritizing store credit application
# to an order.
#
# @!attribute [rw] store_credit_prioritizer_class
# @return [Class] a class with the same public interfaces as
# Spree::StoreCreditPrioritizer.
class_name_attribute :store_credit_prioritizer_class, default: 'Spree::StoreCreditPrioritizer'

# @!attribute [rw] taxon_image_style_default
#
# Defines which style to default to when style is not provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe Spree::OrderCreditSorter, type: :model do
RSpec.describe Spree::StoreCreditPrioritizer, type: :model do
let(:order) { create(:order) }
let(:credits) { Spree::StoreCredit.all }
let(:sorter) { described_class.new(credits, order) }
Expand Down

0 comments on commit f385be9

Please sign in to comment.