diff --git a/Guardfile b/Guardfile index 52b9faac02..5205fdcf62 100644 --- a/Guardfile +++ b/Guardfile @@ -2,8 +2,8 @@ # More info at https://github.com/guard/guard#readme guard 'livereload' do - #watch(%r{app/views/.+\.(erb|haml|slim)$}) - #watch(%r{app/helpers/.+\.rb}) + watch(%r{app/views/.+\.(erb|haml|slim)$}) + watch(%r{app/helpers/.+\.rb}) watch(%r{public/.+\.(css|js|html)}) #watch(%r{config/locales/.+\.yml}) # Rails Assets Pipeline diff --git a/app/controllers/distributors_controller.rb b/app/controllers/distributors_controller.rb deleted file mode 100644 index a2081da542..0000000000 --- a/app/controllers/distributors_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -class DistributorsController < ApplicationController - layout "darkswarm" -end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb new file mode 100644 index 0000000000..777b7b26c7 --- /dev/null +++ b/app/controllers/shop_controller.rb @@ -0,0 +1,9 @@ +class ShopController < BaseController + layout "darkswarm" + + def index + @distributor = current_distributor + end + + +end diff --git a/app/helpers/distributors_helper.rb b/app/helpers/distributors_helper.rb deleted file mode 100644 index 0206363d57..0000000000 --- a/app/helpers/distributors_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module DistributorsHelper -end diff --git a/app/helpers/shop_helper.rb b/app/helpers/shop_helper.rb new file mode 100644 index 0000000000..6d2457ec16 --- /dev/null +++ b/app/helpers/shop_helper.rb @@ -0,0 +1,3 @@ +module ShopHelper + +end diff --git a/app/views/enterprises/_about_us.html.haml b/app/views/enterprises/_about_us.html.haml new file mode 100644 index 0000000000..24cffec25e --- /dev/null +++ b/app/views/enterprises/_about_us.html.haml @@ -0,0 +1 @@ +About Us diff --git a/app/views/enterprises/_contact_us.html.haml b/app/views/enterprises/_contact_us.html.haml new file mode 100644 index 0000000000..bb7297252b --- /dev/null +++ b/app/views/enterprises/_contact_us.html.haml @@ -0,0 +1 @@ +Contact Us diff --git a/app/views/products/_list.html.haml b/app/views/products/_list.html.haml new file mode 100644 index 0000000000..3770387175 --- /dev/null +++ b/app/views/products/_list.html.haml @@ -0,0 +1,13 @@ +%table#product-list + %thead + %th Item + %th Description + %th Variant + %th Quantity + %th Available? + %th Price + + - list.each do |product| + %tr + %td= product.name + %td= product.description diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml new file mode 100644 index 0000000000..029f130512 --- /dev/null +++ b/app/views/shop/index.html.haml @@ -0,0 +1,10 @@ += @distributor.name + +%description + = @distributor.long_description.andand.html_safe + + + += render partial: "enterprises/contact_us" += render partial: "enterprises/about_us" + diff --git a/config/routes.rb b/config/routes.rb index 91fbf0eb73..3c6b0b26cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,8 @@ Openfoodnetwork::Application.routes.draw do root :to => 'home#temp_landing_page' + resources :shop + resources :enterprises do collection do get :suppliers diff --git a/spec/controllers/distributors_controller_spec.rb b/spec/controllers/distributors_controller_spec.rb deleted file mode 100644 index 84d9c2923e..0000000000 --- a/spec/controllers/distributors_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe DistributorsController do - -end diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb new file mode 100644 index 0000000000..bf5c8008b6 --- /dev/null +++ b/spec/controllers/shop_controller_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe DistributorsController do + it "should set the distributor when loading show" + + it "should create/load an order when loading show" +end diff --git a/spec/features/consumer/shopping_spec.rb b/spec/features/consumer/shopping_spec.rb new file mode 100644 index 0000000000..fb3b0c3e55 --- /dev/null +++ b/spec/features/consumer/shopping_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +feature "As a consumer I want to shop with a distributor" do + include AuthenticationWorkflow + include WebHelper + + describe "Viewing a distributor" do + let(:distributor) { create(:distributor_enterprise) } + + before do #temporarily using the old way to select distributor + create_enterprise_group_for distributor + visit "/" + click_link distributor.name + end + it "shows a distributor" do + visit shop_index_path + page.should have_text distributor.name + end + + 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]) + exchange = Exchange.find(oc1.exchanges.to_enterprises(d).outgoing.first.id) + exchange.update_attribute :pickup_time, "turtles" + + visit shop_index_path + page.should have_selector "option[selected]", text: 'Packing' + + # Should see order cycle selected in dropdown + # (Should also render products) + 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" + 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