mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-02 06:51:40 +00:00
Taking payment methods with no distributor out of circulation
This commit is contained in:
@@ -133,10 +133,10 @@ Spree::Order.class_eval do
|
||||
line_items.map { |li| li.variant }
|
||||
end
|
||||
|
||||
# Show payment methods with no distributor or for this distributor
|
||||
# Show payment methods for this distributor
|
||||
def available_payment_methods
|
||||
@available_payment_methods ||= Spree::PaymentMethod.available(:front_end).select do |pm|
|
||||
(self.distributor && (pm.distributors.include? self.distributor)) || pm.distributors.empty?
|
||||
(self.distributor && (pm.distributors.include? self.distributor))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,6 +22,19 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
describe "Payment methods" do
|
||||
let(:order) { build(:order, distributor: create(:distributor_enterprise)) }
|
||||
let(:pm1) { create(:payment_method, distributors: [order.distributor])}
|
||||
let(:pm2) { create(:payment_method, distributors: [])}
|
||||
|
||||
it "finds the correct payment methods" do
|
||||
Spree::PaymentMethod.stub(:available).and_return [pm1, pm2]
|
||||
order.available_payment_methods.include?(pm2).should == false
|
||||
order.available_payment_methods.include?(pm1).should == true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "updating the distribution charge" do
|
||||
let(:order) { build(:order) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user