Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
language: ruby
rvm:
- ree
- 1.9.3
- 2.0.0
- 1.8.7

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notifications:
email: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in redis-session-store.gemspec
gemspec

gem 'activesupport', '1.0.0'
gem 'rake', :group => :test
gem 'minitest', :group => :test, :platform => :ruby_18
4 changes: 4 additions & 0 deletions lib/redis-session-store.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'redis'
require 'active_support/core_ext'

# Redis session storage for Rails, and for Rails only. Derived from
# the MemCacheStore code, simply dropping in Redis instead.
Expand All @@ -18,6 +19,9 @@ class RedisSessionStore < ActionController::Session::AbstractStore
def initialize(app, options = {})
super

options = options.symbolize_keys
options[:redis] = options[:redis].symbolize_keys if options[:redis]

redis_options = options[:redis] || {}

@default_options.merge!(:namespace => 'rack:session')
Expand Down
40 changes: 40 additions & 0 deletions test/redis_session_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,46 @@ def options
end
end

describe 'when initializing with the redis sub-hash options with string keys' do
def options
{
'key' => random_string,
'secret' => random_string,
'redis' => {
'host' => 'hosty.local',
'port' => 16379,
'db' => 2,
'key_prefix' => 'myapp:session:',
'expire_after' => 60 * 120
}
}
end

it 'creates a redis instance' do
store.instance_variable_get(:@redis).wont_equal nil
end

it 'assigns the :host option to @default_options' do
default_options[:host].must_equal 'hosty.local'
end

it 'assigns the :port option to @default_options' do
default_options[:port].must_equal 16379
end

it 'assigns the :db option to @default_options' do
default_options[:db].must_equal 2
end

it 'assigns the :key_prefix option to @default_options' do
default_options[:key_prefix].must_equal 'myapp:session:'
end

it 'assigns the :expire_after option to @default_options' do
default_options[:expire_after].must_equal 60 * 120
end
end

describe 'when initializing with top-level redis options' do
def options
{
Expand Down