-
Notifications
You must be signed in to change notification settings - Fork 22k
Update cookies
helper on all HTTP requests
#27586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Backported in cf51e74 |
Update `cookies` helper on all HTTP requests
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. |
This reverts commit cf51e74. Reason: It caused regression and the test case is in the issue.
@rafaelfranca I ran the regression script above on the latest master and it still fails, so I'm not sure if this patch by @maclover7 caused the regression. |
@rafaelfranca @maclover7 @mrageh Any news ? I still can't access to a signed cookie from my tests. |
@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.
test/controllers/carts_controller_test.rb:18
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. |
Reapply "Merge pull request #27586 from maclover7/jm-fix-27584"
Reapply "Merge pull request #27586 from maclover7/jm-fix-27584"
Summary
Regression introduced by ae29142 / 8363b87.
Previously, cookies were only updated on
GET
requests. Now we willupdate the helper for all requests, as part of
process
. Addedregression tests for all available HTTP method helpers in
ActionController::TestCase
.Other Information