mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add feature spec to cover T&Cs ticked by default if customer has already accepted them
This commit is contained in:
@@ -126,7 +126,7 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
end
|
||||
end
|
||||
|
||||
context "when distributor has terms and conditions" do
|
||||
context "when distributor has T&Cs" do
|
||||
let(:fake_terms_and_conditions_path) { Rails.root.join("app/assets/images/logo-white.png") }
|
||||
let(:terms_and_conditions_file) { Rack::Test::UploadedFile.new(fake_terms_and_conditions_path, "application/pdf") }
|
||||
|
||||
@@ -135,14 +135,29 @@ feature "As a consumer I want to check out my cart", js: true do
|
||||
order.distributor.save
|
||||
end
|
||||
|
||||
it "shows a link to the terms and conditions" do
|
||||
visit checkout_path
|
||||
expect(page).to have_link("Terms and Conditions", href: order.distributor.terms_and_conditions.url)
|
||||
describe "when customer has not accepted T&Cs before" do
|
||||
it "shows a link to the T&Cs and disabled checkout button until terms are accepted" do
|
||||
visit checkout_path
|
||||
expect(page).to have_link("Terms and Conditions", href: order.distributor.terms_and_conditions.url)
|
||||
|
||||
expect(page).to have_button("Place order now", disabled: true)
|
||||
expect(page).to have_button("Place order now", disabled: true)
|
||||
|
||||
check "accept_terms"
|
||||
expect(page).to have_button("Place order now", disabled: false)
|
||||
check "accept_terms"
|
||||
expect(page).to have_button("Place order now", disabled: false)
|
||||
end
|
||||
end
|
||||
|
||||
describe "when customer has already accepted T&Cs before" do
|
||||
before do
|
||||
customer = create(:customer, enterprise: order.distributor, user: user)
|
||||
customer.update terms_and_conditions_accepted_at: Time.zone.now
|
||||
end
|
||||
|
||||
it "enables checkout because T&Cs are accepted by default" do
|
||||
visit checkout_path
|
||||
|
||||
expect(page).to have_button("Place order now", disabled: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user