Skip to content

Commit

Permalink
fix(StoreCredit): Add display_number method
Browse files Browse the repository at this point in the history
display_number is used by many partials and templates
displaying the payment source identifier to users
or admins.

StoreCredit was missing this metho, leading to errors
if a store credit is used as payment source.

(cherry picked from commit 89aaf70)
  • Loading branch information
tvdeyen committed May 8, 2024
1 parent 5dbd82c commit d41577f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/app/models/spree/store_credit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Spree::StoreCredit < Spree::PaymentSource
extend Spree::DisplayMoney
money_methods :amount, :amount_used, :amount_authorized

alias_method :display_number, :category_name

# Sets this store credit's amount to a new value,
# parsing it as a localized number if the new value is a string.
#
Expand Down
6 changes: 6 additions & 0 deletions core/spec/models/spree/store_credit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
end
end

describe "#display_number" do
it "returns the category name" do
expect(store_credit.display_number).to eq("Exchange")
end
end

describe "#display_amount" do
it "returns a Spree::Money instance" do
expect(store_credit.display_amount).to be_instance_of(Spree::Money)
Expand Down

0 comments on commit d41577f

Please sign in to comment.