Update `cookies` helper on all HTTP requests #27586
Previously, cookies were only updated on
This caused a regression:
begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" raise e end gemfile(true) do source "https://rubygems.org" gem "rails", github: "rails/rails", branch: "5-0-stable" gem "pry-byebug" end require "action_controller/railtie" class TestApp < Rails::Application config.root = File.dirname(__FILE__) config.session_store :cookie_store, key: "cookie_store_key" secrets.secret_token = "secret_token" secrets.secret_key_base = "secret_key_base" config.logger = Logger.new($stdout) Rails.logger = config.logger routes.draw do resources :users, only: [:index] end end class UsersController < ActionController::Base def index unless cookies[:name].present? cookies[:name] = "Alice" end render plain: "Home" end end require "minitest/autorun" require "rack/test" class UsersControllerTest < ActionController::TestCase setup do @controller = UsersController.new @routes = Rails.application.routes end test '#index sets a cookie if it is not already present' do get :index assert_response :ok assert_equal "Alice", cookies[:name] cookies[:name] = "Bob" get :index assert_response :ok assert_equal "Bob", cookies[:name] end end
@davidcornu was taking a look but I'll revert it for now.
@rafaelfranca Hello Rafael, I just realized how useless my precedent message was. It's my first participation on Github. Sorry for my inexperience. I just updated to 5.0.2.rc1.
At first I thought it was not the appropriate way to test the presence of a signed cookie. And then, I read this message.
Note : I have successfully tested the presence and/or the value of a simple cookie.
Hope it helps. Otherwise, could you show me the way.