diff --git a/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb b/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb index 8b4981f..4783957 100644 --- a/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb +++ b/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb @@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper else delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option]) end - delivery.save(false) + delivery.save(validate: false) items << [delivery.id, ''] end diff --git a/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb b/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb index 2203bc7..c65a1e2 100644 --- a/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb +++ b/plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb @@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest < ActiveSupport::TestCase assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment) end -end + should 'return a table of items' do + enterprise = Enterprise.new(name: "Test Enterprise", identifier: "test-enterprise") + enterprise.environment = Environment.default + enterprise.save! + + product_category = fast_create(ProductCategory, :name => 'Products') + product = fast_create(Product, :name => 'test product1', :product_category_id => product_category.id, :profile_id => enterprise.id) + setting = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin) + setting.delivery = true + setting.save! + + assert_match 'table id="cart-items-table"', items_table([product], enterprise) + assert_match 'test product1', items_table([product], enterprise) + end +end -- libgit2 0.21.2