mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-31 22:38:49 +01:00
upgrade to rails 2.3.12 and fix deprecation warning and fix some version numbers of gems used for testing
This commit is contained in:
parent
a3c5920a2b
commit
ceda51b5bf
34 changed files with 2451 additions and 11266 deletions
64
vendor/rails/actionpack/test/controller/session/abstract_store_test.rb
vendored
Normal file
64
vendor/rails/actionpack/test/controller/session/abstract_store_test.rb
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
# You need to start a memcached server inorder to run these tests
|
||||
class AbstractStoreTest < ActionController::IntegrationTest
|
||||
SessionKey = '_myapp_session'
|
||||
DispatcherApp = ActionController::Dispatcher.new
|
||||
|
||||
class TestController < ActionController::Base
|
||||
def get_session
|
||||
session[:test] = 'test'
|
||||
head :ok
|
||||
end
|
||||
end
|
||||
|
||||
def test_expiry_after
|
||||
with_test_route_set(:expire_after => 5 * 60) do
|
||||
get 'get_session'
|
||||
assert_response :success
|
||||
assert_match /expires=\S+/, headers['Set-Cookie']
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def with_test_route_set(options = {})
|
||||
with_routing do |set|
|
||||
set.draw do |map|
|
||||
map.with_options :controller => "abstract_store_test/test" do |c|
|
||||
c.connect "/:action"
|
||||
end
|
||||
end
|
||||
|
||||
options = { :key => SessionKey, :secret => 'SessionSecret' }.merge!(options)
|
||||
@integration_session = open_session(TestStore.new(DispatcherApp, options))
|
||||
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
class TestStore < ActionController::Session::AbstractStore
|
||||
def initialize(app, options = {})
|
||||
super
|
||||
@_store = Hash.new({})
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_session(env, sid)
|
||||
sid ||= generate_sid
|
||||
session = @_store[sid]
|
||||
[sid, session]
|
||||
end
|
||||
|
||||
def set_session(env, sid, session_data)
|
||||
@_store[sid] = session_data
|
||||
end
|
||||
|
||||
def destroy(env)
|
||||
@_store.delete(sid)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -42,6 +42,12 @@ class CookieStoreTest < ActionController::IntegrationTest
|
|||
head :ok
|
||||
end
|
||||
|
||||
def call_reset_session_twice
|
||||
reset_session
|
||||
reset_session
|
||||
head :ok
|
||||
end
|
||||
|
||||
def call_reset_session
|
||||
reset_session
|
||||
head :ok
|
||||
|
|
@ -190,6 +196,44 @@ class CookieStoreTest < ActionController::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_calling_session_reset_twice
|
||||
with_test_route_set do
|
||||
get '/set_session_value'
|
||||
assert_response :success
|
||||
session_payload = response.body
|
||||
assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
|
||||
headers['Set-Cookie']
|
||||
|
||||
get '/call_reset_session_twice'
|
||||
assert_response :success
|
||||
assert_not_equal "", headers['Set-Cookie']
|
||||
assert_not_equal session_payload, cookies[SessionKey]
|
||||
|
||||
get '/get_session_value'
|
||||
assert_response :success
|
||||
assert_equal 'foo: nil', response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_setting_session_value_after_session_reset
|
||||
with_test_route_set do
|
||||
get '/set_session_value'
|
||||
assert_response :success
|
||||
session_payload = response.body
|
||||
assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly",
|
||||
headers['Set-Cookie']
|
||||
|
||||
get '/call_reset_session'
|
||||
assert_response :success
|
||||
assert_not_equal "", headers['Set-Cookie']
|
||||
assert_not_equal session_payload, cookies[SessionKey]
|
||||
|
||||
get '/get_session_value'
|
||||
assert_response :success
|
||||
assert_equal 'foo: nil', response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_setting_session_value_after_session_reset
|
||||
with_test_route_set do
|
||||
get '/set_session_value'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue