Fix some outstanding updating issues in BPE

This commit is contained in:
Rob H
2013-12-23 23:09:19 +08:00
parent 3372f1d605
commit 2df0545819
4 changed files with 33 additions and 5 deletions

View File

@@ -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

View File

@@ -1,3 +1,2 @@
collection @products.order('id ASC')
extends "spree/api/products/bulk_show"
attributes :variant_unit, :variant_unit_scale, :variant_unit_name
extends "spree/api/products/bulk_show"

View File

@@ -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 }

View File

@@ -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