Skip to content

Commit

Permalink
Fix deprecation message for Spree::CreditCard
Browse files Browse the repository at this point in the history
Deprecation messages on `CreditCard#default` and `CreditCard#default=`
are a bit misleading, as they print out `CreditCard.default`
but they are actually referencing an instance method, not a class one.
  • Loading branch information
spaghetticode committed Oct 22, 2019
1 parent e48a6b4 commit 4c076f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/app/models/spree/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def self.default
}.freeze

def default
Spree::Deprecation.warn("CreditCard.default is deprecated. Please use user.wallet.default_wallet_payment_source instead.", caller)
Spree::Deprecation.warn("CreditCard#default is deprecated. Please use user.wallet.default_wallet_payment_source instead.", caller)
return false if user.nil?
user.wallet.default_wallet_payment_source.try!(:payment_source) == self
end

def default=(set_as_default)
Spree::Deprecation.warn("CreditCard.default= is deprecated. Please use user.wallet.default_wallet_payment_source= instead.", caller)
Spree::Deprecation.warn("CreditCard#default= is deprecated. Please use user.wallet.default_wallet_payment_source= instead.", caller)
if user.nil?
raise "Cannot set 'default' on a credit card without a user"
elsif set_as_default # setting this card as default
Expand Down

0 comments on commit 4c076f3

Please sign in to comment.