Skip to content

Commit 367049c

Browse files
committed
Fix brittle Time.now mock
1 parent 39ff550 commit 367049c

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

actionpack/test/controller/session/cookie_store_test.rb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,17 @@ def test_session_store_with_expire_after
199199

200200
with_test_route_set do
201201
# First request accesses the session
202-
time = Time.local(2008, 4, 24)
203-
Time.stubs(:now).returns(time)
204-
expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT")
205-
206202
cookies[SessionKey] = SignedBar
207203

208204
get '/set_session_value'
209205
assert_response :success
206+
cookie = headers['Set-Cookie']
210207

211-
cookie_body = response.body
212-
assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly",
213-
headers['Set-Cookie']
214-
215-
# Second request does not access the session
216-
time = Time.local(2008, 4, 25)
217-
Time.stubs(:now).returns(time)
218-
expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT")
219-
208+
# Second request does not access the session so the
209+
# expires header should not be changed
220210
get '/no_session_access'
221211
assert_response :success
222-
223-
assert_equal "_myapp_session=#{cookie_body}; path=/; expires=#{expected_expiry}; HttpOnly",
224-
headers['Set-Cookie']
212+
assert_equal cookie, headers['Set-Cookie']
225213
end
226214
end
227215

0 commit comments

Comments
 (0)