Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix brittle Time.now mock

  • Loading branch information...
commit 367049cae69ec535e7105b35f4877167adca1188 1 parent 39ff550
Joshua Peek josh authored
Showing with 4 additions and 16 deletions.
  1. +4 −16 actionpack/test/controller/session/cookie_store_test.rb
20 actionpack/test/controller/session/cookie_store_test.rb
View
@@ -199,29 +199,17 @@ def test_session_store_with_expire_after
with_test_route_set do
# First request accesses the session
- time = Time.local(2008, 4, 24)
- Time.stubs(:now).returns(time)
- expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT")
-
cookies[SessionKey] = SignedBar
get '/set_session_value'
assert_response :success
+ cookie = headers['Set-Cookie']
- cookie_body = response.body
- assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly",
- headers['Set-Cookie']
-
- # Second request does not access the session
- time = Time.local(2008, 4, 25)
- Time.stubs(:now).returns(time)
- expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT")
-
+ # Second request does not access the session so the
+ # expires header should not be changed
get '/no_session_access'
assert_response :success
-
- assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly",
- headers['Set-Cookie']
+ assert_equal cookie, headers['Set-Cookie']
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.