Skip to content

Commit

Permalink
Merge pull request #5741 from tvdeyen/store_credit-display_number
Browse files Browse the repository at this point in the history
fix(StoreCredit): Add display_number method
  • Loading branch information
tvdeyen authored May 8, 2024
2 parents 1fdedd4 + 89aaf70 commit 88f7711
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 88f7711

Please sign in to comment.