mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Move localize_number from decorator to model
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
module Spree
|
||||
class Payment < ActiveRecord::Base
|
||||
include Spree::Payment::Processing
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
localize_number :amount
|
||||
|
||||
IDENTIFIER_CHARS = (('A'..'Z').to_a + ('0'..'9').to_a - %w(0 1 I O)).freeze
|
||||
|
||||
|
||||
@@ -2,14 +2,10 @@ require 'spree/localized_number'
|
||||
|
||||
module Spree
|
||||
Payment.class_eval do
|
||||
extend Spree::LocalizedNumber
|
||||
|
||||
delegate :line_items, to: :order
|
||||
|
||||
has_one :adjustment, as: :source, dependent: :destroy
|
||||
|
||||
localize_number :amount
|
||||
|
||||
# We bypass this after_rollback callback that is setup in Spree::Payment
|
||||
# The issues the callback fixes are not experienced in OFN:
|
||||
# if a payment fails on checkout the state "failed" is persisted correctly
|
||||
|
||||
@@ -40,6 +40,10 @@ describe Spree::Payment do
|
||||
allow(payment).to receive(:record_response)
|
||||
end
|
||||
|
||||
context "extends LocalizedNumber" do
|
||||
it_behaves_like "a model using the LocalizedNumber module", [:amount]
|
||||
end
|
||||
|
||||
context 'validations' do
|
||||
it "returns useful error messages when source is invalid" do
|
||||
payment.source = Spree::CreditCard.new
|
||||
|
||||
@@ -108,9 +108,5 @@ module Spree
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "extends LocalizedNumber" do
|
||||
it_behaves_like "a model using the LocalizedNumber module", [:amount]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user