From fcb1701d36c3463526b3e7e37ec9d13f21b213b3 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 Feb 2013 15:29:55 +1100 Subject: [PATCH] WIP Add hub and order cycle display stub with failing tests --- .../stylesheets/store/openfoodweb.css.scss | 9 ++++++- app/views/order_cycles/_choice.html.haml | 1 + app/views/order_cycles/_selection.html.erb | 2 +- app/views/spree/_sidebar.html.haml | 1 + spec/features/consumer/order_cycles_spec.rb | 25 ++++++++++++++----- 5 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 app/views/order_cycles/_choice.html.haml diff --git a/app/assets/stylesheets/store/openfoodweb.css.scss b/app/assets/stylesheets/store/openfoodweb.css.scss index 107fdd6a20..0aaad1ab0e 100644 --- a/app/assets/stylesheets/store/openfoodweb.css.scss +++ b/app/assets/stylesheets/store/openfoodweb.css.scss @@ -65,8 +65,15 @@ nav#filters { } -/* Distributor / order cycle selection */ +/* Distributor and order cycle selection and display */ #distribution-choice { + margin-bottom: 2em; + padding: 5px; + border: 2px solid #ccc; + @include border-radius(10px); +} + +#distribution-selection { overflow: auto; margin-bottom: 2em; padding: 5px; diff --git a/app/views/order_cycles/_choice.html.haml b/app/views/order_cycles/_choice.html.haml new file mode 100644 index 0000000000..db74d5bb6f --- /dev/null +++ b/app/views/order_cycles/_choice.html.haml @@ -0,0 +1 @@ +#distribution-choice You have not yet picked where you will get your order from. diff --git a/app/views/order_cycles/_selection.html.erb b/app/views/order_cycles/_selection.html.erb index 85af742e8d..84a917f9c0 100644 --- a/app/views/order_cycles/_selection.html.erb +++ b/app/views/order_cycles/_selection.html.erb @@ -1,7 +1,7 @@ <%# When written in HAML, dynamic attributes (ie. (class="order-cycle-#{foo}")) were failing to parse. Regrettably rewritten in ERB. Fix me! %> -
+
<%= form_for current_order(true) do |f| %>

Active Hubs

diff --git a/app/views/spree/_sidebar.html.haml b/app/views/spree/_sidebar.html.haml index 20e8748ecb..a7a11f5733 100644 --- a/app/views/spree/_sidebar.html.haml +++ b/app/views/spree/_sidebar.html.haml @@ -1,3 +1,4 @@ += render :partial => 'order_cycles/choice' = render :partial => 'spree/shared/taxonomies' = render :partial => 'spree/shared/filters' = render :partial => 'spree/products/source_sidebar' diff --git a/spec/features/consumer/order_cycles_spec.rb b/spec/features/consumer/order_cycles_spec.rb index 2c191a1992..3d85ab4335 100644 --- a/spec/features/consumer/order_cycles_spec.rb +++ b/spec/features/consumer/order_cycles_spec.rb @@ -26,8 +26,8 @@ feature %q{ visit spree.products_path # Then I should see a choice of hubs - page.should have_selector "#distribution-choice option[value='#{@d1.id}']", text: @d1.name - page.should have_selector "#distribution-choice option[value='#{@d2.id}']", text: @d2.name + page.should have_selector "#distribution-selection option[value='#{@d1.id}']", text: @d1.name + page.should have_selector "#distribution-selection option[value='#{@d2.id}']", text: @d2.name # And I should see a choice of order cycles with closing times [{oc: @oc1, closing: '7 days'}, {oc: @oc2, closing: '2 days'}].each do |data| @@ -36,6 +36,9 @@ feature %q{ page.should have_content data[:closing] end end + + # And I should see an indication of my current choices + page.should have_selector "#distribution-choice", text: 'You have not yet picked where you will get your order from.' end context "without javascript" do @@ -49,7 +52,8 @@ feature %q{ # Then associated order cycles should be highlighted page.should have_content "Your hub has been selected." - within '#distribution-choice' do + page.should have_selector '#distribution-choice', text: "Hub: #{@d1.name}" + within "#distribution-selection" do page.should have_selector "tr.order-cycle-#{@oc1.id}.local" page.should have_selector "tr.order-cycle-#{@oc2.id}.remote" end @@ -59,7 +63,9 @@ feature %q{ click_button 'Choose Hub' # Then associated order cycles should be highlighted - within '#distribution-choice' do + page.should have_content "Your hub has been selected." + page.should have_selector '#distribution-choice', text: "Hub: #{@d2.name}" + within '#distribution-selection' do page.should have_selector "tr.order-cycle-#{@oc1.id}.remote" page.should have_selector "tr.order-cycle-#{@oc2.id}.local" end @@ -75,7 +81,8 @@ feature %q{ # Then the associated distributor should be highlighted page.should have_content "Your order cycle has been selected." - within '#distribution-choice' do + page.should have_selector '#distribution-choice', text: "Order Cycle: #{@oc1.name}" + within '#distribution-selection' do page.should have_selector "option.local[value='#{@d1.id}']" page.should have_selector "option.remote[value='#{@d2.id}']" end @@ -86,7 +93,8 @@ feature %q{ # Then the associated distributor should be highlighted page.should have_content "Your order cycle has been selected." - within '#distribution-choice' do + page.should have_selector '#distribution-choice', text: "Order Cycle: #{@oc2.name}" + within '#distribution-selection' do page.should have_selector "option.remote[value='#{@d1.id}']" page.should have_selector "option.local[value='#{@d2.id}']" end @@ -137,6 +145,11 @@ feature %q{ click_button 'Choose Hub' # Then my order cycle and distributor should be set + within '#distribution-choice' do + page.should have_content "Hub: #{@d1.name}" + page.should have_content "Order Cycle: #{@oc1.name}" + end + page.should have_selector "input[value='#{@oc1.id}'][checked='checked']" page.should have_selector "option[value='#{@d1.id}'][selected='selected']" end