From 7b5cef7abdc286fede534360776b038570695c3a Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 3 May 2024 08:12:27 +0200 Subject: [PATCH] fix(StoreCredit): Add display_number method 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 89aaf702cef91e5b40dad3eec80099d3fc248149) --- core/app/models/spree/store_credit.rb | 2 ++ core/spec/models/spree/store_credit_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/core/app/models/spree/store_credit.rb b/core/app/models/spree/store_credit.rb index 1e2bc0bdd0..7901905675 100644 --- a/core/app/models/spree/store_credit.rb +++ b/core/app/models/spree/store_credit.rb @@ -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. # diff --git a/core/spec/models/spree/store_credit_spec.rb b/core/spec/models/spree/store_credit_spec.rb index a91104e9a8..c78591e4b0 100644 --- a/core/spec/models/spree/store_credit_spec.rb +++ b/core/spec/models/spree/store_credit_spec.rb @@ -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)