mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Refactor customer credit payment method
Set fixed name and description
This commit is contained in:
@@ -3,6 +3,15 @@
|
||||
module Spree
|
||||
class PaymentMethod
|
||||
class CustomerCredit < Spree::PaymentMethod
|
||||
# Name and description are translatable string, to allow instances to customise them
|
||||
def name
|
||||
"credit_payment_method.name"
|
||||
end
|
||||
|
||||
def description
|
||||
"credit_payment_method.description"
|
||||
end
|
||||
|
||||
def actions
|
||||
%w{internal_void}
|
||||
end
|
||||
|
||||
@@ -31,10 +31,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :customer_credit_payment_method, class: Spree::PaymentMethod::CustomerCredit do
|
||||
name { Rails.application.config.credit_payment_method[:name] }
|
||||
description { Rails.application.config.credit_payment_method[:description] }
|
||||
environment { 'test' }
|
||||
internal { true }
|
||||
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,14 @@ require "spec_helper"
|
||||
RSpec.describe Spree::PaymentMethod::CustomerCredit do
|
||||
subject { build(:customer_credit_payment_method) }
|
||||
|
||||
describe "#name" do
|
||||
it { expect(subject.name).to eq("credit_payment_method.name") }
|
||||
end
|
||||
|
||||
describe "#description" do
|
||||
it { expect(subject.description).to eq("credit_payment_method.description") }
|
||||
end
|
||||
|
||||
describe "#purchase" do
|
||||
let(:response) { subject.purchase(amount, nil, options) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user