redis-actionpack 3.1.3.rc2 → 3.1.3.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -1
- data/Rakefile +0 -6
- data/lib/action_dispatch/middleware/session/redis_store.rb +7 -54
- data/lib/redis/actionpack/version.rb +1 -1
- data/redis-actionpack.gemspec +8 -7
- data/test/dummy/.gitignore +1 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/test_controller.rb +37 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +11 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/test.rb +25 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +11 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +10 -0
- data/test/integration/redis_store_integration_test.rb +130 -0
- data/test/redis/actionpack/version_test.rb +2 -2
- data/test/test_helper.rb +45 -6
- metadata +75 -27
- data/test/action_dispatch/middleware/session/redis_store_test.rb +0 -77
data/Gemfile
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem 'redis-store', '1.1.0.
|
4
|
+
gem 'redis-store', '1.1.0.rc2', :path => File.expand_path('../../redis-store', __FILE__)
|
5
5
|
gem 'redis-rack-cache', '1.1.rc2', :path => File.expand_path('../../redis-rack-cache', __FILE__)
|
6
|
+
gem 'redis-rack', '1.3.5.rc', :path => File.expand_path('../../redis-rack', __FILE__)
|
7
|
+
gem 'SystemTimer', :platform => :mri_18
|
8
|
+
gem 'minitest_tu_shim', :platform => :ruby_18
|
data/Rakefile
CHANGED
@@ -1,64 +1,17 @@
|
|
1
1
|
require 'redis-store'
|
2
|
+
require 'redis-rack'
|
2
3
|
require 'action_dispatch/middleware/session/abstract_store'
|
3
4
|
|
4
|
-
# Redis session storage for Rails, and for Rails only. Derived from
|
5
|
-
# the MemCacheStore code, simply dropping in Redis instead.
|
6
|
-
#
|
7
|
-
# Options:
|
8
|
-
# :key => Same as with the other cookie stores, key name
|
9
|
-
# :secret => Encryption secret for the key
|
10
|
-
# :host => Redis host name, default is localhost
|
11
|
-
# :port => Redis port, default is 6379
|
12
|
-
# :db => Database number, defaults to 0. Useful to separate your session storage from other data
|
13
|
-
# :key_prefix => Prefix for keys used in Redis, e.g. myapp-. Useful to separate session storage keys visibly from others
|
14
|
-
# :expire_after => A number in seconds to set the timeout interval for the session. Will map directly to expiry in Redis
|
15
5
|
module ActionDispatch
|
16
6
|
module Session
|
17
|
-
class
|
7
|
+
class RedisStore < Rack::Session::Redis
|
8
|
+
include Compatibility
|
9
|
+
include StaleSessionCheck
|
18
10
|
def initialize(app, options = {})
|
19
|
-
# Support old :expires option
|
20
|
-
options[:expire_after] ||= options[:expires]
|
21
|
-
|
22
|
-
super
|
23
|
-
|
24
11
|
options = options.dup
|
25
|
-
|
26
|
-
|
27
|
-
servers.map! do |server|
|
28
|
-
server = Redis::Factory.resolve(server)
|
29
|
-
server.merge(options)
|
30
|
-
end
|
31
|
-
|
32
|
-
@pool = Redis::Factory.create(*servers)
|
12
|
+
options[:redis_server] ||= options[:servers]
|
13
|
+
super
|
33
14
|
end
|
34
|
-
|
35
|
-
private
|
36
|
-
def get_session(env, sid)
|
37
|
-
sid ||= generate_sid
|
38
|
-
begin
|
39
|
-
session = @pool.get(sid) || {}
|
40
|
-
rescue Errno::ECONNREFUSED
|
41
|
-
session = {}
|
42
|
-
end
|
43
|
-
[sid, session]
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_session(env, sid, session_data, opts=nil)
|
47
|
-
options = env['rack.session.options']
|
48
|
-
@pool.set(sid, session_data, options)
|
49
|
-
sid
|
50
|
-
rescue Errno::ECONNREFUSED
|
51
|
-
return false
|
52
|
-
end
|
53
|
-
|
54
|
-
def destroy(env)
|
55
|
-
if sid = current_session_id(env)
|
56
|
-
@pool.del(sid)
|
57
|
-
sid
|
58
|
-
end
|
59
|
-
rescue Errno::ECONNREFUSED
|
60
|
-
false
|
61
|
-
end
|
62
15
|
end
|
63
16
|
end
|
64
|
-
end
|
17
|
+
end
|
data/redis-actionpack.gemspec
CHANGED
@@ -18,14 +18,15 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'redis-store', '1.1.0.
|
21
|
+
s.add_runtime_dependency 'redis-store', '1.1.0.rc2'
|
22
22
|
s.add_runtime_dependency 'actionpack', '3.1.3'
|
23
23
|
s.add_runtime_dependency 'redis-rack-cache', '1.1.rc2'
|
24
|
+
s.add_runtime_dependency 'redis-rack', '1.3.5.rc'
|
24
25
|
|
25
|
-
s.add_development_dependency 'rake',
|
26
|
-
s.add_development_dependency 'bundler',
|
27
|
-
s.add_development_dependency '
|
28
|
-
s.add_development_dependency '
|
29
|
-
s.add_development_dependency '
|
26
|
+
s.add_development_dependency 'rake', '~> 0.9.2.2'
|
27
|
+
s.add_development_dependency 'bundler', '~> 1.1.rc'
|
28
|
+
s.add_development_dependency 'minitest', '~> 2.8.0'
|
29
|
+
s.add_development_dependency 'purdytest', '~> 1.0.0'
|
30
|
+
s.add_development_dependency 'minitest-rails', '~> 0.0.5'
|
31
|
+
s.add_development_dependency 'tzinfo'
|
30
32
|
end
|
31
|
-
|
@@ -0,0 +1 @@
|
|
1
|
+
log/*
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class TestController < ActionController::Base
|
2
|
+
def no_session_access
|
3
|
+
head :ok
|
4
|
+
end
|
5
|
+
|
6
|
+
def set_session_value
|
7
|
+
session[:foo] = "bar"
|
8
|
+
head :ok
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_session_value_with_expiry
|
12
|
+
request.session_options[:expire_after] = 1.second
|
13
|
+
set_session_value
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_serialized_session_value
|
17
|
+
session[:foo] = SessionAutoloadTest::Foo.new
|
18
|
+
head :ok
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_session_value
|
22
|
+
render :text => "foo: #{session[:foo].inspect}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_session_id
|
26
|
+
render :text => "#{request.session_options[:id]}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def call_reset_session
|
30
|
+
session[:bar]
|
31
|
+
reset_session
|
32
|
+
session[:bar] = "baz"
|
33
|
+
head :ok
|
34
|
+
end
|
35
|
+
|
36
|
+
def rescue_action(e) raise end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = false
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Print deprecation notices to the stderr
|
24
|
+
config.active_support.deprecation = :stderr
|
25
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'a7d2ff143cdb3d1f9470a3ce2df7bb220a9c4498cb5c4a35150705de6719114b12ab7512a9618a2d3c25f8d6e62ab22c042445ed856ff674f4ee2faabd9d2041'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :redis_store,
|
4
|
+
:key => '_session_id',
|
5
|
+
:servers => ["redis://127.0.0.1:6380/1/theplaylist",
|
6
|
+
"redis://127.0.0.1:6381/1/theplaylist"]
|
7
|
+
|
8
|
+
# Use the database for sessions instead of the cookie-based default,
|
9
|
+
# which shouldn't be used to store highly confidential information
|
10
|
+
# (create the session table with "rails generate session_migration")
|
11
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RedisStoreIntegrationTest < MiniTest::Rails::IntegrationTest
|
4
|
+
it "reads the data" do
|
5
|
+
get '/set_session_value'
|
6
|
+
response.must_be :success?
|
7
|
+
cookies['_session_id'].wont_be_nil
|
8
|
+
|
9
|
+
get '/get_session_value'
|
10
|
+
response.must_be :success?
|
11
|
+
response.body.must_equal 'foo: "bar"'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should get nil session value" do
|
15
|
+
get '/get_session_value'
|
16
|
+
response.must_be :success?
|
17
|
+
response.body.must_equal 'foo: nil'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should delete the data after session reset" do
|
21
|
+
get '/set_session_value'
|
22
|
+
response.must_be :success?
|
23
|
+
cookies['_session_id'].wont_be_nil
|
24
|
+
session_cookie = cookies.send(:hash_for)['_session_id']
|
25
|
+
|
26
|
+
get '/call_reset_session'
|
27
|
+
response.must_be :success?
|
28
|
+
headers['Set-Cookie'].wont_equal []
|
29
|
+
|
30
|
+
cookies << session_cookie
|
31
|
+
|
32
|
+
get '/get_session_value'
|
33
|
+
response.must_be :success?
|
34
|
+
response.body.must_equal 'foo: nil'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not send cookies on write, not read" do
|
38
|
+
get '/get_session_value'
|
39
|
+
response.must_be :success?
|
40
|
+
response.body.must_equal 'foo: nil'
|
41
|
+
cookies['_session_id'].must_be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should set session value after session reset" do
|
45
|
+
get '/set_session_value'
|
46
|
+
response.must_be :success?
|
47
|
+
cookies['_session_id'].wont_be_nil
|
48
|
+
session_id = cookies['_session_id']
|
49
|
+
|
50
|
+
get '/call_reset_session'
|
51
|
+
response.must_be :success?
|
52
|
+
headers['Set-Cookie'].wont_equal []
|
53
|
+
|
54
|
+
get '/get_session_value'
|
55
|
+
response.must_be :success?
|
56
|
+
response.body.must_equal 'foo: nil'
|
57
|
+
|
58
|
+
get '/get_session_id'
|
59
|
+
response.must_be :success?
|
60
|
+
response.body.wont_equal session_id
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be able to read session id without accessing the session hash" do
|
64
|
+
get '/set_session_value'
|
65
|
+
response.must_be :success?
|
66
|
+
cookies['_session_id'].wont_be_nil
|
67
|
+
session_id = cookies['_session_id']
|
68
|
+
|
69
|
+
get '/get_session_id'
|
70
|
+
response.must_be :success?
|
71
|
+
response.body.must_equal session_id
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should auto-load unloaded class" do
|
75
|
+
with_autoload_path "session_autoload_test" do
|
76
|
+
get '/set_serialized_session_value'
|
77
|
+
response.must_be :success?
|
78
|
+
cookies['_session_id'].wont_be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
with_autoload_path "session_autoload_test" do
|
82
|
+
get '/get_session_id'
|
83
|
+
assert_response :success
|
84
|
+
end
|
85
|
+
|
86
|
+
with_autoload_path "session_autoload_test" do
|
87
|
+
get '/get_session_value'
|
88
|
+
response.must_be :success?
|
89
|
+
response.body.must_equal 'foo: #<SessionAutoloadTest::Foo bar:"baz">'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should not resend the cookie again if session_id cookie is already exists" do
|
94
|
+
get '/set_session_value'
|
95
|
+
response.must_be :success?
|
96
|
+
cookies['_session_id'].wont_be_nil
|
97
|
+
|
98
|
+
get '/get_session_value'
|
99
|
+
response.must_be :success?
|
100
|
+
headers['Set-Cookie'].must_be_nil
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should prevent session fixation" do
|
104
|
+
get '/get_session_value'
|
105
|
+
response.must_be :success?
|
106
|
+
response.body.must_equal 'foo: nil'
|
107
|
+
session_id = cookies['_session_id']
|
108
|
+
|
109
|
+
reset!
|
110
|
+
|
111
|
+
get '/set_session_value', :_session_id => session_id
|
112
|
+
response.must_be :success?
|
113
|
+
cookies['_session_id'].wont_equal session_id
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should write the data with expiration time" do
|
117
|
+
get '/set_session_value_with_expiry'
|
118
|
+
response.must_be :success?
|
119
|
+
|
120
|
+
get '/get_session_value'
|
121
|
+
response.must_be :success?
|
122
|
+
response.body.must_equal 'foo: "bar"'
|
123
|
+
|
124
|
+
sleep 1
|
125
|
+
|
126
|
+
get '/get_session_value'
|
127
|
+
response.must_be :success?
|
128
|
+
response.body.must_equal 'foo: nil'
|
129
|
+
end
|
130
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,47 @@
|
|
1
|
-
Bundler.setup
|
2
|
-
gem 'minitest'
|
3
|
-
require 'minitest/spec'
|
4
1
|
require 'minitest/autorun'
|
5
|
-
require '
|
2
|
+
require 'minitest/rails'
|
6
3
|
require 'active_support/core_ext/numeric/time'
|
7
|
-
|
8
|
-
|
4
|
+
|
5
|
+
ENV["RAILS_ENV"] = "test"
|
6
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
7
|
+
require "rails/test_help"
|
8
|
+
|
9
|
+
Rails.backtrace_cleaner.remove_silencers!
|
10
|
+
|
11
|
+
# TODO: remove once https://github.com/blowmage/minitest-rails/issues/12 is resolved
|
12
|
+
class MiniTest::Rails::IntegrationTest < MiniTest::Rails::Spec
|
13
|
+
include ActiveSupport::Testing::SetupAndTeardown
|
14
|
+
|
15
|
+
include ActionDispatch::Integration::Runner
|
16
|
+
|
17
|
+
@@app = nil
|
18
|
+
|
19
|
+
def self.app
|
20
|
+
# DEPRECATE Rails application fallback
|
21
|
+
# This should be set by the initializer
|
22
|
+
@@app || (defined?(Rails.application) && Rails.application) || nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.app=(app)
|
26
|
+
@@app = app
|
27
|
+
end
|
28
|
+
|
29
|
+
def app
|
30
|
+
super || self.class.app
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_autoload_path(path)
|
35
|
+
path = File.join(File.dirname(__FILE__), "fixtures", path)
|
36
|
+
if ActiveSupport::Dependencies.autoload_paths.include?(path)
|
37
|
+
yield
|
38
|
+
else
|
39
|
+
begin
|
40
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
41
|
+
yield
|
42
|
+
ensure
|
43
|
+
ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
|
44
|
+
ActiveSupport::Dependencies.clear
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.3.
|
4
|
+
version: 3.1.3.rc3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis-store
|
16
|
-
requirement: &
|
16
|
+
requirement: &70362130694300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.1.0.
|
21
|
+
version: 1.1.0.rc2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70362130694300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: actionpack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70362130693480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70362130693480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: redis-rack-cache
|
38
|
-
requirement: &
|
38
|
+
requirement: &70362130691920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,10 +43,21 @@ dependencies:
|
|
43
43
|
version: 1.1.rc2
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70362130691920
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: redis-rack
|
49
|
+
requirement: &70362130691260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - =
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.5.rc
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70362130691260
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: rake
|
49
|
-
requirement: &
|
60
|
+
requirement: &70362130690640 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ~>
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: 0.9.2.2
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70362130690640
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: bundler
|
60
|
-
requirement: &
|
71
|
+
requirement: &70362130689740 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ~>
|
@@ -65,40 +76,51 @@ dependencies:
|
|
65
76
|
version: 1.1.rc
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70362130689740
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement: &
|
81
|
+
name: minitest
|
82
|
+
requirement: &70362130688860 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ~>
|
75
86
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
87
|
+
version: 2.8.0
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70362130688860
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
requirement: &
|
92
|
+
name: purdytest
|
93
|
+
requirement: &70362130687820 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ~>
|
86
97
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
98
|
+
version: 1.0.0
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70362130687820
|
91
102
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
93
|
-
requirement: &
|
103
|
+
name: minitest-rails
|
104
|
+
requirement: &70362130686860 !ruby/object:Gem::Requirement
|
94
105
|
none: false
|
95
106
|
requirements:
|
96
107
|
- - ~>
|
97
108
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
109
|
+
version: 0.0.5
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70362130686860
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: tzinfo
|
115
|
+
requirement: &70362130686180 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
99
121
|
type: :development
|
100
122
|
prerelease: false
|
101
|
-
version_requirements: *
|
123
|
+
version_requirements: *70362130686180
|
102
124
|
description: Redis session store for ActionPack
|
103
125
|
email:
|
104
126
|
- guidi.luca@gmail.com
|
@@ -115,7 +137,20 @@ files:
|
|
115
137
|
- lib/redis-actionpack.rb
|
116
138
|
- lib/redis/actionpack/version.rb
|
117
139
|
- redis-actionpack.gemspec
|
118
|
-
- test/
|
140
|
+
- test/dummy/.gitignore
|
141
|
+
- test/dummy/Rakefile
|
142
|
+
- test/dummy/app/controllers/test_controller.rb
|
143
|
+
- test/dummy/config.ru
|
144
|
+
- test/dummy/config/application.rb
|
145
|
+
- test/dummy/config/boot.rb
|
146
|
+
- test/dummy/config/environment.rb
|
147
|
+
- test/dummy/config/environments/test.rb
|
148
|
+
- test/dummy/config/initializers/secret_token.rb
|
149
|
+
- test/dummy/config/initializers/session_store.rb
|
150
|
+
- test/dummy/config/routes.rb
|
151
|
+
- test/dummy/script/rails
|
152
|
+
- test/fixtures/session_autoload_test/session_autoload_test/foo.rb
|
153
|
+
- test/integration/redis_store_integration_test.rb
|
119
154
|
- test/redis/actionpack/version_test.rb
|
120
155
|
- test/test_helper.rb
|
121
156
|
homepage: http://jodosha.github.com/redis-store
|
@@ -143,6 +178,19 @@ signing_key:
|
|
143
178
|
specification_version: 3
|
144
179
|
summary: Redis session store for ActionPack
|
145
180
|
test_files:
|
146
|
-
- test/
|
181
|
+
- test/dummy/.gitignore
|
182
|
+
- test/dummy/Rakefile
|
183
|
+
- test/dummy/app/controllers/test_controller.rb
|
184
|
+
- test/dummy/config.ru
|
185
|
+
- test/dummy/config/application.rb
|
186
|
+
- test/dummy/config/boot.rb
|
187
|
+
- test/dummy/config/environment.rb
|
188
|
+
- test/dummy/config/environments/test.rb
|
189
|
+
- test/dummy/config/initializers/secret_token.rb
|
190
|
+
- test/dummy/config/initializers/session_store.rb
|
191
|
+
- test/dummy/config/routes.rb
|
192
|
+
- test/dummy/script/rails
|
193
|
+
- test/fixtures/session_autoload_test/session_autoload_test/foo.rb
|
194
|
+
- test/integration/redis_store_integration_test.rb
|
147
195
|
- test/redis/actionpack/version_test.rb
|
148
196
|
- test/test_helper.rb
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe ActionDispatch::Session::RedisSessionStore do
|
4
|
-
attr_reader :app
|
5
|
-
|
6
|
-
before do
|
7
|
-
@app = Object.new
|
8
|
-
@store = ActionDispatch::Session::RedisSessionStore.new(app)
|
9
|
-
@dstore = ActionDispatch::Session::RedisSessionStore.new app, :servers => ["redis://127.0.0.1:6380/1", "redis://127.0.0.1:6381/1"]
|
10
|
-
@rabbit = OpenStruct.new :name => "bunny"
|
11
|
-
@white_rabbit = OpenStruct.new :color => "white"
|
12
|
-
@sid = "rabbit"
|
13
|
-
@env = {'rack.session.options' => {:id => @sid}}
|
14
|
-
with_store_management do |store|
|
15
|
-
class << store
|
16
|
-
attr_reader :pool
|
17
|
-
public :get_session, :set_session, :destroy
|
18
|
-
end
|
19
|
-
store.set_session(@env, @sid, @rabbit)
|
20
|
-
store.pool.del "counter"
|
21
|
-
store.pool.del "rub-a-dub"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "reads the data" do
|
26
|
-
with_store_management do |store|
|
27
|
-
store.get_session(@env, @sid).must_equal([@sid, @rabbit])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should write the data" do
|
32
|
-
with_store_management do |store|
|
33
|
-
store.set_session(@env, @sid, @white_rabbit)
|
34
|
-
store.get_session(@env, @sid).must_equal([@sid, @white_rabbit])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should delete the data" do
|
39
|
-
with_store_management do |store|
|
40
|
-
store.destroy(@env)
|
41
|
-
store.get_session(@env, @sid).must_equal([@sid, {}])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should write the data with expiration time" do
|
46
|
-
with_store_management do |store|
|
47
|
-
@env['rack.session.options'].merge!(:expires_in => 1.second)
|
48
|
-
store.set_session(@env, @sid, @white_rabbit); sleep 2
|
49
|
-
store.get_session(@env, @sid).must_equal([@sid, {}])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "namespace" do
|
54
|
-
before do
|
55
|
-
@namespace = "theplaylist"
|
56
|
-
@store = ActionDispatch::Session::RedisSessionStore.new(lambda {|| }, :servers => [{ :namespace => @namespace }])
|
57
|
-
@pool = @store.instance_variable_get(:@pool)
|
58
|
-
@client = @pool.instance_variable_get(:@client)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should read the data" do
|
62
|
-
@client.expects(:call).with([:get, "#{@namespace}:#{@sid}"])
|
63
|
-
@store.send :get_session, @env, @sid
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should write the data" do
|
67
|
-
@client.expects(:call).with([:set, "#{@namespace}:#{@sid}", Marshal.dump(@white_rabbit)])
|
68
|
-
@store.send :set_session, @env, @sid, @white_rabbit
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
def with_store_management
|
74
|
-
yield @store
|
75
|
-
yield @dstore
|
76
|
-
end
|
77
|
-
end
|