diff --git a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee index 8f21390a7f..f1fdb224b0 100644 --- a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee @@ -1,13 +1,4 @@ -angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product) -> +angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) -> $scope.data = Product.data + $scope.order_cycle = OrderCycle.order_cycle Product.update() - - - #$scope.order_cycle = OrderCycle.order_cycle - #$scope.updateProducts = -> - #$scope.products = Product.all() - #$scope.$watch "order_cycle.order_cycle_id", $scope.updateProducts - #$scope.updateProducts() - - - diff --git a/app/views/shop/_order_cycles.html.haml b/app/views/shop/_order_cycles.html.haml index 1400de92bd..5c2986bedf 100644 --- a/app/views/shop/_order_cycles.html.haml +++ b/app/views/shop/_order_cycles.html.haml @@ -20,7 +20,6 @@ "ng-change" => "changeOrderCycle()", "ng-options" => "oc.id as oc.time for oc in #{@order_cycles.map {|oc| {time: pickup_time(oc), id: oc.id}}.to_json}"} - %closing -#%img{src: "/icon/goes/here"} Orders close diff --git a/app/views/shop/_products.html.haml b/app/views/shop/_products.html.haml index 8725591d44..d332057931 100644 --- a/app/views/shop/_products.html.haml +++ b/app/views/shop/_products.html.haml @@ -1,4 +1,5 @@ -%products{"ng-controller" => "ProductsCtrl"} +%products{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null"} + %h5 Check out when you have selected everything you want = form_for :order, :url => populate_orders_path, html: {:class => "custom"} do %input#search.text{"ng-model" => "query", placeholder: "Search"} %input.button.right{type: :submit, value: "Check Out"} @@ -22,7 +23,6 @@ %td {{ product.master.options_text }} - %span{"ng-show" => "product.variants.length > 0"} %img.collapse{src: "/assets/collapse.png", "ng-show" => "product.show_variants", diff --git a/app/views/shop/show.html.haml b/app/views/shop/show.html.haml index 3f1a4bb7b3..93d50ab1b2 100644 --- a/app/views/shop/show.html.haml +++ b/app/views/shop/show.html.haml @@ -12,11 +12,11 @@ = render partial: "shop/order_cycles" -#%description - + %tabs .row .section-container.auto{"data-section" => "", "data-options" => "one_up: false"} - %section#about + %section#about{class: current_order_cycle ? nil : "active" } %p.title.avenir{"data-section-title" => ""} %a{href: "#about"} About Us .content{"data-section-content" => ""} @@ -43,9 +43,7 @@ .content{"data-section-content" => ""} %p Contact - %products.row - %h5 Check out when you have selected everything you want = render partial: "shop/products" #footer %section.row diff --git a/spec/features/consumer/shopping_spec.rb b/spec/features/consumer/shopping_spec.rb index 85bdb1270a..dd67d6b765 100644 --- a/spec/features/consumer/shopping_spec.rb +++ b/spec/features/consumer/shopping_spec.rb @@ -58,14 +58,28 @@ feature "As a consumer I want to shop with a distributor", js: true do exchange.update_attribute :pickup_time, "frogs" exchange = Exchange.find(oc2.exchanges.to_enterprises(distributor).outgoing.first.id) exchange.update_attribute :pickup_time, "turtles" + visit shop_path end it "shows a select with all order cycles" do - visit shop_path page.should have_selector "option", text: 'frogs' page.should have_selector "option", text: 'turtles' end + it "shows the About Us by default if no order cycle is selected" do + page.should have_content "Hello, world!" + end + + it "doesn't show the table before an order cycle is selected" do + page.should_not have_button "Check Out" + end + + it "shows the table after an order cycle is selected" do + select "frogs", :from => "order_cycle_id" + save_and_open_page + page.should have_button "Check Out" + end + describe "with products in our order cycle" do let(:product) { create(:simple_product) } before do