Payment methods need to be available, too

This commit is contained in:
Rohan Mitchell
2014-10-29 17:01:08 +11:00
parent f0d3b987d4
commit 9f43146e47
2 changed files with 8 additions and 2 deletions

View File

@@ -20,11 +20,11 @@ module OrderCyclesHelper
enterprises.map do |e|
disabled_message = nil
if e.shipping_methods.empty? && e.payment_methods.empty?
if e.shipping_methods.empty? && e.payment_methods.available.empty?
disabled_message = 'no shipping or payment methods'
elsif e.shipping_methods.empty?
disabled_message = 'no shipping methods'
elsif e.payment_methods.empty?
elsif e.payment_methods.available.empty?
disabled_message = 'no payment methods'
end

View File

@@ -18,6 +18,12 @@ describe OrderCyclesHelper do
helper.order_cycle_hub_enterprises.should == [['enterprise (no payment methods)', e.id, {disabled: true}]]
end
it "returns enterprises with unavailable payment methods as disabled" do
create(:shipping_method, distributors: [e])
create(:payment_method, distributors: [e], active: false)
helper.order_cycle_hub_enterprises.should == [['enterprise (no payment methods)', e.id, {disabled: true}]]
end
it "returns enterprises with neither shipping nor payment methods as disabled" do
helper.order_cycle_hub_enterprises.should == [['enterprise (no shipping or payment methods)', e.id, {disabled: true}]]
end