From a7f42568972ef351eb6cd266872bba1dfb81cf23 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 19 Jun 2014 12:10:05 +1000 Subject: [PATCH] Fixing a minor regression --- .../darkswarm/controllers/products_controller.js.coffee | 5 ++--- app/assets/javascripts/darkswarm/services/product.js.coffee | 1 + app/views/shop/products/_form.html.haml | 6 ++---- spec/features/consumer/shopping/shopping_spec.rb | 1 - .../controllers/products_controller_spec.js.coffee | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee index 3fdb58cf8e..3860a2d56e 100644 --- a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee @@ -1,12 +1,11 @@ Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) -> - $scope.products = Product.products - $scope.loading = Product.loading + $scope.Product = Product $scope.limit = 3 $scope.ordering = {order: "name"} $scope.order_cycle = OrderCycle.order_cycle $scope.incrementLimit = -> - if $scope.limit < $scope.products.length + if $scope.limit < $scope.Product.products.length $scope.limit = $scope.limit + 1 $scope.searchKeypress = (e)-> diff --git a/app/assets/javascripts/darkswarm/services/product.js.coffee b/app/assets/javascripts/darkswarm/services/product.js.coffee index 5fae2314a8..21c0921e41 100644 --- a/app/assets/javascripts/darkswarm/services/product.js.coffee +++ b/app/assets/javascripts/darkswarm/services/product.js.coffee @@ -9,6 +9,7 @@ Darkswarm.factory 'Product', ($resource) -> loading: true update: => + @loading = true @products = $resource("/shop/products").query => @loading = false @ diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index d948f18f60..724ec7b249 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -14,7 +14,7 @@ %div{bindonce: true} %product{"ng-controller" => "ProductNodeCtrl", - "ng-repeat" => "product in products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"} + "ng-repeat" => "product in Product.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"} %div = render partial: "shop/products/summary" %div{"bo-if" => "hasVariants"} @@ -22,12 +22,10 @@ .variants.row{"bo-if" => "!hasVariants"} = render partial: "shop/products/master" - %product{"ng-show" => "loading"} + %product{"ng-show" => "Product.loading"} .row.summary .small-12.columns.text-center Loading products - - .row .small-12.columns %input.button.primary.right.add_to_cart{type: :submit, value: "Add to Cart"} diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 304eff7d23..e219e970a2 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -77,7 +77,6 @@ feature "As a consumer I want to shop with a distributor", js: true do page.should have_content "Next order closing in 2 days" Spree::Order.last.order_cycle.should == oc1 page.should have_content product.name - save_screenshot "/Users/willmarshall/Desktop/shop.png" page.should have_content product.master.display_name page.should have_content product.master.display_as end diff --git a/spec/javascripts/unit/darkswarm/controllers/products_controller_spec.js.coffee b/spec/javascripts/unit/darkswarm/controllers/products_controller_spec.js.coffee index 3a1b5fb399..47ad0ccbd4 100644 --- a/spec/javascripts/unit/darkswarm/controllers/products_controller_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/controllers/products_controller_spec.js.coffee @@ -18,4 +18,4 @@ describe 'ProductsCtrl', -> ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle} it 'fetches products from Product', -> - expect(scope.products).toEqual 'testy mctest' + expect(scope.Product.products).toEqual 'testy mctest'