mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Enterprises shouldn't be considered ready for checkout if it only has backend shipping methods
This commit is contained in:
committed by
Filipe
parent
7bd56007bd
commit
81730f725d
@@ -120,6 +120,7 @@ class Enterprise < ApplicationRecord
|
||||
joins(:shipping_methods).
|
||||
joins(:payment_methods).
|
||||
merge(Spree::PaymentMethod.available).
|
||||
merge(Spree::ShippingMethod.frontend).
|
||||
select('DISTINCT enterprises.*')
|
||||
}
|
||||
scope :not_ready_for_checkout, lambda {
|
||||
@@ -387,7 +388,7 @@ class Enterprise < ApplicationRecord
|
||||
end
|
||||
|
||||
def ready_for_checkout?
|
||||
shipping_methods.any? && payment_methods.available.any?
|
||||
shipping_methods.frontend.any? && payment_methods.available.any?
|
||||
end
|
||||
|
||||
def self.find_available_permalink(test_permalink)
|
||||
|
||||
@@ -276,6 +276,13 @@ describe Enterprise do
|
||||
expect(Enterprise.ready_for_checkout).not_to include e
|
||||
end
|
||||
|
||||
it "does not show enterprises wchich only have backend shipping methods" do
|
||||
create(:shipping_method, distributors: [e],
|
||||
display_on: Spree::ShippingMethod::DISPLAY_ON_OPTIONS[:back_end])
|
||||
create(:payment_method, distributors: [e])
|
||||
expect(Enterprise.ready_for_checkout).not_to include e
|
||||
end
|
||||
|
||||
it "shows enterprises with available payment and shipping methods" do
|
||||
create(:shipping_method, distributors: [e])
|
||||
create(:payment_method, distributors: [e])
|
||||
@@ -302,6 +309,13 @@ describe Enterprise do
|
||||
expect(Enterprise.not_ready_for_checkout).to include e
|
||||
end
|
||||
|
||||
it "shows enterprises which only have backend shipping methods" do
|
||||
create(:shipping_method, distributors: [e],
|
||||
display_on: Spree::ShippingMethod::DISPLAY_ON_OPTIONS[:back_end])
|
||||
create(:payment_method, distributors: [e])
|
||||
expect(Enterprise.not_ready_for_checkout).to include e
|
||||
end
|
||||
|
||||
it "does not show enterprises with available payment and shipping methods" do
|
||||
create(:shipping_method, distributors: [e])
|
||||
create(:payment_method, distributors: [e])
|
||||
@@ -328,6 +342,13 @@ describe Enterprise do
|
||||
expect(e.reload).not_to be_ready_for_checkout
|
||||
end
|
||||
|
||||
it "returns false for enterprises which only have backend shipping methods" do
|
||||
create(:shipping_method, distributors: [e],
|
||||
display_on: Spree::ShippingMethod::DISPLAY_ON_OPTIONS[:back_end])
|
||||
create(:payment_method, distributors: [e])
|
||||
expect(e.reload).not_to be_ready_for_checkout
|
||||
end
|
||||
|
||||
it "returns true for enterprises with available payment and shipping methods" do
|
||||
create(:shipping_method, distributors: [e])
|
||||
create(:payment_method, distributors: [e])
|
||||
|
||||
Reference in New Issue
Block a user