mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Adding some feature tests for the basic products page
This commit is contained in:
@@ -20,7 +20,7 @@ feature "As a consumer I want to shop with a distributor" do
|
||||
describe "selecting an order cycle" do
|
||||
it "selects an order cycle if only one is open" do
|
||||
# create order cycle
|
||||
oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [distributor])
|
||||
oc1 = create(:simple_order_cycle, distributors: [distributor])
|
||||
exchange = Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
exchange.update_attribute :pickup_time, "turtles"
|
||||
|
||||
@@ -31,28 +31,48 @@ feature "As a consumer I want to shop with a distributor" do
|
||||
# (Should also render products)
|
||||
end
|
||||
|
||||
it "shows a select with all order cycles" do
|
||||
oc1 = create(:simple_order_cycle, name: 'oc 1', distributors: [distributor])
|
||||
oc2 = create(:simple_order_cycle, name: 'oc 1', distributors: [distributor])
|
||||
describe "with multiple order cycles" do
|
||||
let(:oc1) {create(:simple_order_cycle, distributors: [distributor])}
|
||||
let(:oc2) {create(:simple_order_cycle, distributors: [distributor])}
|
||||
before do
|
||||
exchange = Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
exchange.update_attribute :pickup_time, "frogs"
|
||||
exchange = Exchange.find(oc2.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
exchange.update_attribute :pickup_time, "turtles"
|
||||
end
|
||||
|
||||
exchange = Exchange.find(oc1.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
exchange.update_attribute :pickup_time, "frogs"
|
||||
exchange = Exchange.find(oc2.exchanges.to_enterprises(distributor).outgoing.first.id)
|
||||
exchange.update_attribute :pickup_time, "turtles"
|
||||
it "shows a select with all order cycles" do
|
||||
visit shop_index_path
|
||||
page.should have_selector "option", text: 'frogs'
|
||||
page.should have_selector "option", text: 'turtles'
|
||||
page.should_not have_selector "option[selected]"
|
||||
end
|
||||
|
||||
visit shop_index_path
|
||||
page.should have_selector "option", text: 'frogs'
|
||||
page.should have_selector "option", text: 'turtles'
|
||||
page.should_not have_selector "option[selected]"
|
||||
it "allows the user to select an order cycle" do
|
||||
visit shop_index_path
|
||||
|
||||
select "frogs", :from => "order_cycle_id"
|
||||
page.should have_content "Products"
|
||||
end
|
||||
end
|
||||
|
||||
context "when no order cycles are available" do
|
||||
it "shows the last order cycle, if any"
|
||||
it "shows the next order cycle, if any"
|
||||
it "tells us orders are closed" do
|
||||
visit shop_index_path
|
||||
page.should have_content "Orders are currently closed for this hub"
|
||||
end
|
||||
it "shows the last order cycle" do
|
||||
oc1 = create(:simple_order_cycle, distributors: [distributor], orders_close_at: 10.days.ago)
|
||||
visit shop_index_path
|
||||
page.should 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)
|
||||
visit shop_index_path
|
||||
page.should have_content "The next cycle opens in 10 days"
|
||||
end
|
||||
end
|
||||
|
||||
it "renders the order cycle selector when multiple order cycles are available"
|
||||
it "allows the user to select an order cycle"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user