diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index d1be7ef2a2..45a8eee28f 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -145,6 +145,7 @@ productsApp.controller "AdminBulkProductsCtrl", [ $scope.totalPages = -> Math.ceil($scope.totalCount()/$scope.perPage) $scope.firstVisibleProduct = -> ($scope.currentPage-1)*$scope.perPage+1 $scope.lastVisibleProduct = -> Math.min($scope.totalCount(),$scope.currentPage*$scope.perPage) + $scope.setPage = (page) -> $scope.currentPage = page $scope.minPage = -> Math.max(1,Math.min($scope.totalPages()-4,$scope.currentPage-2)) $scope.maxPage = -> Math.min($scope.totalPages(),Math.max(5,$scope.currentPage+2)) diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 8ec49fea8c..6487a6b323 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -520,9 +520,22 @@ feature %q{ visit '/admin/products/bulk_edit' select '25', :from => 'perPage' - page.all("input[name='product_name']").select{|e| e.visible?}.length.should == 25 + page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 25 select '50', :from => 'perPage' - page.all("input[name='product_name']").select{|e| e.visible?}.length.should == 27 + page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 27 + end + + it "displays the correct products when changing pages" do + 25.times { FactoryGirl.create(:product, :name => "page1product") } + 5.times { FactoryGirl.create(:product, :name => "page2product") } + login_to_admin_section + + visit '/admin/products/bulk_edit' + + select '25', :from => 'perPage' + page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page1product" }.should == true + click_link "2" + page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page2product" }.should == true end end end