1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

12 commits

Author SHA1 Message Date
Andrew White
e864ff7259 Add backward compatibility for testing cookies
This commit restores the ability to assign cookies for testing via
@request.env['HTTP_COOKIE'] and @request.cookies, e.g:

    @request.env['HTTP_COOKIE'] = 'user_name=david'
    get :index
    assert_equal 'david', cookies[:user_name]

and

    @request.cookies[:user_name] = 'david'
    get :index
    assert_equal 'david', cookies[:user_name]

Assigning via cookies[] is the preferred method and will take precedence
over the other two methods. This is so that cookies set in controller
actions have precedence and are carried over between calls to get, post, etc.
2011-06-05 12:34:27 +01:00
Andrew White
d4658d86fe Refactor ActionController::TestCase cookies
Assigning cookies for test cases should now use cookies[], e.g:

  cookies[:email] = 'user@example.com'
  get :index
  assert_equal 'user@example.com', cookies[:email]

To clear the cookies, use clear, e.g:

  cookies.clear
  get :index
  assert_nil cookies[:email]

We now no longer write out HTTP_COOKIE and the cookie jar is
persistent between requests so if you need to manipulate the environment
for your test you need to do it before the cookie jar is created.
2011-06-04 07:09:11 +01:00
Andrew White
31f09f9dbc Improve testing of cookies in functional tests:
- cookies can be set using string or symbol keys
- cookies are preserved across calls to get, post, etc.
- cookie names and values are escaped
- cookies can be cleared using @request.cookies.clear

[#6272 state:resolved]
2011-03-06 12:49:44 +00:00
Emilio Tagua
1ed18fcc91 Initialize @cookies. 2010-09-27 11:19:23 -03:00
Emilio Tagua
dafb4bd33b Don't shadow outer local variables. 2010-09-27 11:19:22 -03:00
Piotr Sarnacki
a132229d7b Added ability to set asset_path for engines 2010-09-03 22:59:08 +02:00
José Valim
6690d66292 Rename config.cookie_secret to config.secret_token and pass it as configuration in request.env. This is another step forward removing global configuration. 2010-04-05 12:00:24 +02:00
Xavier Noria
76f024ac8d adds missing requires for Object#blank? and Object#present? 2010-03-28 14:15:02 +02:00
Joshua Peek
f32cf44870 Switch functional tests to run through the rack interface instead of process 2009-05-02 15:29:18 -05:00
Joshua Peek
1fcc7dbcc8 Move TestRequest#query_parameters into AD TestRequest 2009-04-30 23:46:34 -05:00
Joshua Peek
a6fff94baf Move TestRequest cookies accessor into AD TestRequest 2009-04-30 19:23:50 -05:00
Joshua Peek
00d1a57e9f Start moving TestRequest and TestResponse into ActionDispatch 2009-04-30 17:26:03 -05:00