diff --git a/app/views/checkout/_form.html.haml b/app/views/checkout/_form.html.haml index f341a666d9..e755af01e4 100644 --- a/app/views/checkout/_form.html.haml +++ b/app/views/checkout/_form.html.haml @@ -16,6 +16,6 @@ = render "checkout/already_ordered", f: f if show_bought_items? = render "checkout/terms_and_conditions", f: f %p - %button.button.primary{type: :submit} + %button.button.primary{ type: :submit, ng: { disabled: "terms_and_conditions_activated && !terms_and_conditions_accepted" } } = t :checkout_send / {{ checkout.$valid }} diff --git a/app/views/checkout/_terms_and_conditions.html.haml b/app/views/checkout/_terms_and_conditions.html.haml index a99cf44785..bf301139b0 100644 --- a/app/views/checkout/_terms_and_conditions.html.haml +++ b/app/views/checkout/_terms_and_conditions.html.haml @@ -1,2 +1,5 @@ -%p.small - = t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank')) if current_order.distributor.terms_and_conditions.file? +- terms_and_conditions_activated = current_order.distributor.terms_and_conditions.file? +- if terms_and_conditions_activated + %p.small + %input{ type: 'checkbox', id: 'accept_terms', ng: { model: "terms_and_conditions_accepted", init: "terms_and_conditions_activated=#{terms_and_conditions_activated}" } } + %label{for: "accept_terms"}= t('.message_html', terms_and_conditions_link: link_to( t( '.link_text' ), current_order.distributor.terms_and_conditions.url, target: '_blank')) diff --git a/lib/tasks/sample_data/order_factory.rb b/lib/tasks/sample_data/order_factory.rb index 9614f685a0..cdb2dfcc4e 100644 --- a/lib/tasks/sample_data/order_factory.rb +++ b/lib/tasks/sample_data/order_factory.rb @@ -57,7 +57,7 @@ class OrderFactory bill_address: order_address, ship_address: order_address ) - order.line_items.create( variant_id: first_variant.id, quantity: 5 ) + order.line_items.create(variant_id: first_variant.id, quantity: 5) order.payments.create(payment_method_id: first_payment_method_id) order end diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 26be7c62a5..23e0386078 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -138,6 +138,11 @@ feature "As a consumer I want to check out my cart", js: true do it "shows a link to the terms and conditions" do visit checkout_path expect(page).to have_link("Terms of Service", href: order.distributor.terms_and_conditions.url) + + expect(page).to have_button("Place order now", disabled: true) + + check "accept_terms" + expect(page).to have_button("Place order now", disabled: false) end end