Refactor customer credit payment method

Set fixed name and description
This commit is contained in:
Gaetan Craig-Riou
2026-03-04 13:05:39 +11:00
parent 25c579c478
commit 2e7237197a
3 changed files with 17 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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) }