diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 45a8eee28f..58c8d72f7c 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -288,8 +288,10 @@ productsApp.controller "AdminBulkProductsCtrl", [ $scope.packProduct product productsToSubmit = filterSubmitProducts($scope.dirtyProducts) - $scope.updateProducts productsToSubmit - + if productsToSubmit.length > 0 + $scope.updateProducts productsToSubmit # Don't submit an empty list + else + $scope.setMessage $scope.updateStatusMessage, "No changes to update.", color: "grey", 3000 $scope.packProduct = (product) -> if product.variant_unit_with_scale diff --git a/app/views/spree/api/products/bulk_index.v1.rabl b/app/views/spree/api/products/bulk_index.v1.rabl index 4e90cc01ca..e35c8c9d59 100644 --- a/app/views/spree/api/products/bulk_index.v1.rabl +++ b/app/views/spree/api/products/bulk_index.v1.rabl @@ -1,3 +1,2 @@ collection @products.order('id ASC') -extends "spree/api/products/bulk_show" -attributes :variant_unit, :variant_unit_scale, :variant_unit_name \ No newline at end of file +extends "spree/api/products/bulk_show" \ No newline at end of file diff --git a/app/views/spree/api/products/bulk_show.v1.rabl b/app/views/spree/api/products/bulk_show.v1.rabl index df45c86b42..534dd87846 100644 --- a/app/views/spree/api/products/bulk_show.v1.rabl +++ b/app/views/spree/api/products/bulk_show.v1.rabl @@ -1,5 +1,5 @@ object @product -attributes :id, :name, :price, :on_hand +attributes :id, :name, :price, :on_hand, :variant_unit, :variant_unit_scale, :variant_unit_name node( :available_on ) { |p| p.available_on.blank? ? "" : p.available_on.strftime("%F %T") } node( :permalink_live ) { |p| p.permalink } diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 6487a6b323..66effcd295 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -351,6 +351,33 @@ feature %q{ page.find("span#update-status-message").should have_content "Update complete" end + scenario "updating a product after cloning a product" do + FactoryGirl.create(:product, :name => "product 1") + login_to_admin_section + + visit '/admin/products/bulk_edit' + + first("a.clone-product").click + + fill_in "product_name", :with => "new product name" + + click_button 'Update' + page.find("span#update-status-message").should have_content "Update complete" + end + + scenario "updating when no changes have been made" do + Capybara.default_wait_time = 2 + FactoryGirl.create(:product, :name => "product 1") + FactoryGirl.create(:product, :name => "product 2") + login_to_admin_section + + visit '/admin/products/bulk_edit' + + click_button 'Update' + page.find("span#update-status-message").should have_content "No changes to update." + Capybara.default_wait_time = 5 + end + scenario "updating a product when there are more products than the default API page size" do 26.times { FactoryGirl.create(:simple_product) } login_to_admin_section