Commit ff8e7e2d24ba4b1e80ce00963616b3ceca7e8441

Authored by Antonio Terceiro
1 parent da6c280a

Use the appropriate API for deleting a cookie

plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
@@ -280,11 +280,7 @@ class ShoppingCartPluginController < PublicController @@ -280,11 +280,7 @@ class ShoppingCartPluginController < PublicController
280 after_filter :save_cookie 280 after_filter :save_cookie
281 def save_cookie 281 def save_cookie
282 if @cart.nil? 282 if @cart.nil?
283 - cookies[cookie_key] = {  
284 - :value => '',  
285 - :path => '/plugin/shopping_cart',  
286 - :expires => 1.year.ago,  
287 - } 283 + cookies.delete(cookie_key, :path => '/plugin/shopping_cart')
288 else 284 else
289 cookies[cookie_key] = { 285 cookies[cookie_key] = {
290 :value => Base64.encode64(@cart.to_yaml), 286 :value => Base64.encode64(@cart.to_yaml),
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
@@ -18,8 +18,7 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase @@ -18,8 +18,7 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase
18 18
19 should 'force cookie expiration with explicit path for an empty cart' do 19 should 'force cookie expiration with explicit path for an empty cart' do
20 get :get 20 get :get
21 - last_year = 1.year.ago.year  
22 - assert @response.headers['Set-Cookie'].any? { |c| c =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*-#{last_year}/} 21 + assert @response.headers['Set-Cookie'].any? { |c| c =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*-1970/}
23 end 22 end
24 23
25 should 'add a new product to cart' do 24 should 'add a new product to cart' do