Commit e6ab61ced59f19753c4f1c8ab6b16baa6b3be272

Authored by Arthur Esposte
1 parent 82d3ed8e

Change deprecated save in shopping_cart plugin

plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
@@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper @@ -42,7 +42,7 @@ module ShoppingCartPlugin::CartHelper
42 else 42 else
43 delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option]) 43 delivery = Product.new(:name => delivery_option || _('Delivery'), :price => settings.delivery_options[delivery_option])
44 end 44 end
45 - delivery.save(false) 45 + delivery.save(validate: false)
46 items << [delivery.id, ''] 46 items << [delivery.id, '']
47 end 47 end
48 48
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest &lt; ActiveSupport::TestCase @@ -41,5 +41,19 @@ class ShoppingCartPlugin::CartHelperTest &lt; ActiveSupport::TestCase
41 assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment) 41 assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment)
42 end 42 end
43 43
44 -end 44 + should 'return a table of items' do
  45 + enterprise = Enterprise.new(name: "Test Enterprise", identifier: "test-enterprise")
  46 + enterprise.environment = Environment.default
  47 + enterprise.save!
  48 +
  49 + product_category = fast_create(ProductCategory, :name => 'Products')
  50 + product = fast_create(Product, :name => 'test product1', :product_category_id => product_category.id, :profile_id => enterprise.id)
  51 + setting = Noosfero::Plugin::Settings.new(enterprise, ShoppingCartPlugin)
  52 + setting.delivery = true
  53 + setting.save!
  54 +
  55 + assert_match 'table id="cart-items-table"', items_table([product], enterprise)
  56 + assert_match '<td>test product1</td>', items_table([product], enterprise)
  57 + end
45 58
  59 +end