Prevent page being orphaned when changing page size in BPE

This commit is contained in:
Rob H
2013-12-26 19:37:21 +08:00
parent 2df0545819
commit ef78609049
2 changed files with 16 additions and 0 deletions

View File

@@ -149,6 +149,9 @@ productsApp.controller "AdminBulkProductsCtrl", [
$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))
$scope.$watch 'perPage', (newVal, oldVal) ->
$scope.currentPage = $scope.totalPages() if newVal != oldVal && $scope.totalPages() < $scope.currentPage
$scope.initialise = (spree_api_key) ->
authorise_api_reponse = ""
dataFetcher("/api/users/authorise_api?token=" + spree_api_key).then (data) ->

View File

@@ -564,6 +564,19 @@ feature %q{
click_link "2"
page.all("input[name='product_name']").select{ |e| e.visible? }.all?{ |e| e.value == "page2product" }.should == true
end
it "moves the user to the last available page when changing perPage value causes user to become orphaned" do
51.times { FactoryGirl.create(:product) }
login_to_admin_section
visit '/admin/products/bulk_edit'
select '25', :from => 'perPage'
click_link "3"
select '50', :from => 'perPage'
page.first("div.pagenav span.page.current").should have_text "2"
page.all("input[name='product_name']").select{ |e| e.visible? }.length.should == 1
end
end
end