From df0c3fbed341711668bdb8e73393edef6ebfb646 Mon Sep 17 00:00:00 2001 From: Vinicius Cubas Brand Date: Thu, 21 Nov 2013 18:02:53 -0300 Subject: [PATCH] shopping_cart delivery: fix delivery options not saving --- plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb | 2 +- plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb b/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb index 153c58f..1056a14 100644 --- a/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb +++ b/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb @@ -63,7 +63,7 @@ class ShoppingCartPluginMyprofileController < MyProfileController def treat_delivery_options(params) result = {} - return result if params.nil? || params[:delivery_options].nil? + return result if params.nil? || params[:options].nil? params[:options].size.times do |counter| if params[:options][counter].present? && params[:prices][counter].present? result[params[:options][counter]] = params[:prices][counter] diff --git a/plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb b/plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb index 306a7f8..edeeaa3 100644 --- a/plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb +++ b/plugins/shopping_cart/test/functional/shopping_cart_plugin_myprofile_controller_test.rb @@ -51,6 +51,14 @@ class ShoppingCartPluginMyprofileControllerTest < ActionController::TestCase assert settings.delivery_price == price end + should 'be able to choose delivery_options' do + delivery_options = {:options => ['car', 'bike'], :prices => ['20', '5']} + post :edit, :profile => enterprise.identifier, :settings => {:delivery_options => delivery_options} + + assert_equal '20', settings.delivery_options['car'] + assert_equal '5', settings.delivery_options['bike'] + end + should 'filter the reports correctly' do another_enterprise = fast_create(Enterprise) po1 = ShoppingCartPlugin::PurchaseOrder.create!(:seller => enterprise, :status => ShoppingCartPlugin::PurchaseOrder::Status::OPENED) -- libgit2 0.21.2