Make display only shops work again, this will show the product list when the OC is open but ship and pay methods are not available

Add spec to cover display only shops, it's oficially a feature now :-)
This commit is contained in:
Luis Ramos
2020-06-04 16:26:53 +01:00
parent 12000d2d44
commit 02b351b9d5
2 changed files with 27 additions and 2 deletions

View File

@@ -4,7 +4,8 @@
- if no_open_order_cycles?
= render partial: "shop/messages/closed_shop"
- else
= render partial: "shop/messages/select_oc"
= render partial: "shop/products/form"
-# Rendering the form, even if there are no open OCs, makes display only shops possible
= render partial: "shop/products/form"

View File

@@ -232,6 +232,28 @@ feature "As a consumer I want to shop with a distributor", js: true do
expect(page).not_to have_content variant3.display_name
end
end
context "when the distributor has no available payment/shipping methods" do
before do
distributor.update_attributes shipping_methods: [], payment_methods: []
end
# Display only shops are a very useful hack that is described in the user guide
it "still renders a display only shop" do
visit shop_path
expect(page).to have_content product.name
# Add product to cart
fill_in "variants[#{variant.id}]", with: '1'
wait_for_debounce
expect(page).to have_in_cart product.name
wait_until { !cart_dirty }
# Try to go to cart
visit main_app.cart_path
expect(page).to have_content "The hub you have selected is temporarily closed for orders. Please try again later."
end
end
end
describe "group buy products" do
@@ -463,11 +485,13 @@ feature "As a consumer I want to shop with a distributor", js: true do
visit shop_path
expect(page).to have_content "Orders are closed"
end
it "shows the last order cycle" do
oc1 = create(:simple_order_cycle, distributors: [distributor], orders_open_at: 17.days.ago, orders_close_at: 10.days.ago)
visit shop_path
expect(page).to have_content "The last cycle closed 10 days ago"
end
it "shows the next order cycle" do
oc1 = create(:simple_order_cycle, distributors: [distributor], orders_open_at: 10.days.from_now, orders_close_at: 17.days.from_now)
visit shop_path