mongo_session_store-rails3 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/Gemfile +26 -20
  2. data/lib/mongo_session_store-rails3.rb +6 -4
  3. data/lib/mongo_session_store/mongo_mapper_store.rb +18 -14
  4. data/lib/mongo_session_store/mongoid_store.rb +26 -23
  5. data/lib/mongo_session_store/version.rb +1 -1
  6. data/spec/rails_3.0_app/app/models/user.rb +1 -2
  7. data/spec/rails_3.0_app/config/application.rb +1 -1
  8. data/spec/rails_3.0_app/config/database.yml +11 -0
  9. data/spec/rails_3.0_app/config/initializers/devise.rb +1 -1
  10. data/spec/rails_3.0_app/config/initializers/session_store.rb +1 -0
  11. data/spec/rails_3.0_app/db/migrate/20120222195914_create_users_table.rb +19 -0
  12. data/spec/rails_3.0_app/db/schema.rb +20 -0
  13. data/spec/rails_3.1_app/app/models/user.rb +1 -39
  14. data/spec/rails_3.1_app/config/application.rb +1 -1
  15. data/spec/rails_3.1_app/config/database.yml +11 -0
  16. data/spec/rails_3.1_app/config/initializers/devise.rb +1 -1
  17. data/spec/rails_3.1_app/config/initializers/session_store.rb +1 -0
  18. data/spec/rails_3.1_app/db/migrate/20120222195914_create_users_table.rb +12 -0
  19. data/spec/rails_3.1_app/db/schema.rb +20 -0
  20. data/spec/rails_3.2_app/Rakefile +1 -1
  21. data/spec/rails_3.2_app/app/models/user.rb +1 -39
  22. data/spec/rails_3.2_app/app/views/layouts/application.html.erb +1 -1
  23. data/spec/rails_3.2_app/config.ru +1 -1
  24. data/spec/rails_3.2_app/config/application.rb +2 -2
  25. data/spec/rails_3.2_app/config/database.yml +11 -0
  26. data/spec/rails_3.2_app/config/environment.rb +1 -1
  27. data/spec/rails_3.2_app/config/environments/development.rb +1 -1
  28. data/spec/rails_3.2_app/config/environments/production.rb +1 -1
  29. data/spec/rails_3.2_app/config/environments/test.rb +1 -1
  30. data/spec/rails_3.2_app/config/initializers/devise.rb +1 -1
  31. data/spec/rails_3.2_app/config/initializers/secret_token.rb +1 -1
  32. data/spec/rails_3.2_app/config/initializers/session_store.rb +3 -2
  33. data/spec/rails_3.2_app/config/mongo.yml +3 -3
  34. data/spec/rails_3.2_app/config/mongoid.yml +2 -2
  35. data/spec/rails_3.2_app/config/routes.rb +1 -1
  36. data/spec/rails_3.2_app/db/migrate/20120222195914_create_users_table.rb +12 -0
  37. data/spec/rails_3.2_app/db/schema.rb +20 -0
  38. data/spec/spec_helper.rb +7 -0
  39. metadata +22 -4
data/Gemfile CHANGED
@@ -19,36 +19,42 @@ gemspec
19
19
 
20
20
  group :development, :test do
21
21
  gem 'rake'
22
- gem 'mongo_mapper', '>= 0.10.1'
22
+ if !ENV['MONGO_SESSION_STORE_ORM'] || ENV['MONGO_SESSION_STORE_ORM'] == 'mongo_mapper'
23
+ gem 'mongo_mapper', '>= 0.10.1'
24
+ end
23
25
 
24
- # this is hack-tastic :{
25
- # ENV['RAILS_VERS'] is only provided when we run
26
- # bundle update, but not when running the specs proper
27
- # we need an older version of mongoid for Rails 3.0
28
- # and bundler won't cherry-pick a matching gem version
29
- # out of a git repo like it will out of the rubygems repo
30
- if ENV['RAILS_VERS'] == '3.0' || RUBY_VERSION[0..2] == "1.8"
31
- # bundle updating for Rails 3.0
32
- # OR we're still on Ruby 1.8
33
- gem 'mongoid', '>= 2.2.5'
34
- elsif ENV['RAILS_VERS']
35
- # bundle updating for Rails 3.1 or 3.2 on Ruby 1.9
36
- gem 'mongoid', '>= 2.2.5', :git => 'git://github.com/mongoid/mongoid.git'
37
- elsif File.read('Gemfile.lock') =~ /^ rails \(3.0.\d+\)/
38
- # we're running tests on Rails 3.0 on Ruby 1.9
39
- gem 'mongoid', '>= 2.2.5'
40
- else
41
- # we're running tests on Rails 3.1 or 3.2 on Ruby 1.9
42
- gem 'mongoid', '>= 2.2.5', :git => 'git://github.com/mongoid/mongoid.git'
26
+ if !ENV['MONGO_SESSION_STORE_ORM'] || ENV['MONGO_SESSION_STORE_ORM'] == 'mongoid'
27
+ # this is hack-tastic :{
28
+ # ENV['RAILS_VERS'] is only provided when we run
29
+ # bundle update, but not when running the specs proper
30
+ # we need an older version of mongoid for Rails 3.0
31
+ # and bundler won't cherry-pick a matching gem version
32
+ # out of a git repo like it will out of the rubygems repo
33
+ if ENV['RAILS_VERS'] == '3.0' || RUBY_VERSION[0..2] == "1.8"
34
+ # bundle updating for Rails 3.0
35
+ # OR we're still on Ruby 1.8
36
+ gem 'mongoid', '>= 2.2.5'
37
+ elsif ENV['RAILS_VERS']
38
+ # bundle updating for Rails 3.1 or 3.2 on Ruby 1.9
39
+ gem 'mongoid', '>= 2.2.5', :git => 'git://github.com/mongoid/mongoid.git'
40
+ elsif File.read('Gemfile.lock') =~ /^ rails \(3.0.\d+\)/
41
+ # we're running tests on Rails 3.0 on Ruby 1.9
42
+ gem 'mongoid', '>= 2.2.5'
43
+ else
44
+ # we're running tests on Rails 3.1 or 3.2 on Ruby 1.9
45
+ gem 'mongoid', '>= 2.2.5', :git => 'git://github.com/mongoid/mongoid.git'
46
+ end
43
47
  end
44
48
 
45
49
  gem 'mongo', MONGO_VERS
46
50
  gem 'bson_ext', MONGO_VERS
47
51
 
48
52
  gem 'system_timer', :platforms => :ruby_18
53
+ gem 'rbx-require-relative', '0.0.5', :platforms => :ruby_18
49
54
  gem 'ruby-debug', :platforms => :ruby_18
50
55
  gem 'ruby-debug19', :platforms => :ruby_19
51
56
 
57
+ gem 'sqlite3' # for devise User storage
52
58
  RAILS_VERS ? gem('rails', RAILS_VERS) : gem('rails')
53
59
  gem 'rspec-rails'
54
60
  gem 'devise'
@@ -3,7 +3,7 @@ require 'securerandom'
3
3
  $:.unshift File.dirname(__FILE__)
4
4
 
5
5
  module MongoSessionStore
6
- autoload :VERSION, 'mongo_session_store/version'
6
+ autoload :VERSION, 'mongo_session_store/version'
7
7
 
8
8
  def self.collection_name=(name)
9
9
  @collection_name = name
@@ -19,6 +19,8 @@ module MongoSessionStore
19
19
  if defined?(MongoidStore::Session)
20
20
  MongoidStore::Session.store_in(name)
21
21
  end
22
+
23
+ @collection_name
22
24
  end
23
25
 
24
26
  def self.collection_name
@@ -29,6 +31,6 @@ module MongoSessionStore
29
31
  self.collection_name = "sessions"
30
32
  end
31
33
 
32
- autoload :MongoMapperStore, 'mongo_session_store/mongo_mapper_store'
33
- autoload :MongoidStore, 'mongo_session_store/mongoid_store'
34
- autoload :MongoStore, 'mongo_session_store/mongo_store'
34
+ require 'mongo_session_store/mongo_mapper_store'
35
+ require 'mongo_session_store/mongoid_store'
36
+ require 'mongo_session_store/mongo_store'
@@ -1,22 +1,26 @@
1
- require 'mongo_mapper'
2
- require 'mongo_session_store/mongo_store_base'
1
+ begin
2
+ require 'mongo_mapper'
3
+ require 'mongo_session_store/mongo_store_base'
3
4
 
4
- module ActionDispatch
5
- module Session
6
- class MongoMapperStore < MongoStoreBase
5
+ module ActionDispatch
6
+ module Session
7
+ class MongoMapperStore < MongoStoreBase
7
8
 
8
- class Session
9
- include MongoMapper::Document
10
- set_collection_name MongoSessionStore.collection_name
9
+ class Session
10
+ include MongoMapper::Document
11
+ set_collection_name MongoSessionStore.collection_name
11
12
 
12
- key :_id, String
13
- key :data, Binary, :default => Marshal.dump({})
13
+ key :_id, String
14
+ key :data, Binary, :default => Marshal.dump({})
14
15
 
15
- timestamps!
16
- end
16
+ timestamps!
17
+ end
17
18
 
19
+ end
18
20
  end
19
21
  end
20
- end
21
22
 
22
- MongoMapperStore = ActionDispatch::Session::MongoMapperStore
23
+ MongoMapperStore = ActionDispatch::Session::MongoMapperStore
24
+
25
+ rescue LoadError
26
+ end
@@ -1,32 +1,35 @@
1
- require 'mongoid'
2
- require 'mongo_session_store/mongo_store_base'
1
+ begin
2
+ require 'mongoid'
3
+ require 'mongo_session_store/mongo_store_base'
3
4
 
4
- module ActionDispatch
5
- module Session
6
- class MongoidStore < MongoStoreBase
5
+ module ActionDispatch
6
+ module Session
7
+ class MongoidStore < MongoStoreBase
7
8
 
8
- class Session
9
- include Mongoid::Document
10
- include Mongoid::Timestamps
11
- self.collection_name = MongoSessionStore.collection_name
9
+ class Session
10
+ include Mongoid::Document
11
+ include Mongoid::Timestamps
12
+ self.collection_name = MongoSessionStore.collection_name
12
13
 
13
- if respond_to?(:identity)
14
- # pre-Mongoid 3
15
- identity :type => String
16
- else
17
- field :_id, :type => String
18
- end
14
+ if respond_to?(:identity)
15
+ # pre-Mongoid 3
16
+ identity :type => String
17
+ else
18
+ field :_id, :type => String
19
+ end
19
20
 
20
- field :data, :type => BSON::Binary, :default => BSON::Binary.new(Marshal.dump({}))
21
- end
21
+ field :data, :type => BSON::Binary, :default => BSON::Binary.new(Marshal.dump({}))
22
+ end
22
23
 
23
- private
24
- def pack(data)
25
- BSON::Binary.new(Marshal.dump(data))
24
+ private
25
+ def pack(data)
26
+ BSON::Binary.new(Marshal.dump(data))
27
+ end
26
28
  end
27
-
28
29
  end
29
30
  end
30
- end
31
31
 
32
- MongoidStore = ActionDispatch::Session::MongoidStore
32
+ MongoidStore = ActionDispatch::Session::MongoidStore
33
+
34
+ rescue LoadError
35
+ end
@@ -1,3 +1,3 @@
1
1
  module MongoSessionStore
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
@@ -1,5 +1,4 @@
1
- class User
2
- include Mongoid::Document
1
+ class User < ActiveRecord::Base
3
2
  # Include default devise modules. Others available are:
4
3
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
5
4
  devise :database_authenticatable, :registerable, :validatable
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- # require "active_record/railtie"
4
+ require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_mailer/railtie"
7
7
  require "active_resource/railtie"
@@ -0,0 +1,11 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ development:
8
+ adapter: sqlite3
9
+ database: db/development.sqlite3
10
+ pool: 5
11
+ timeout: 5000
@@ -12,7 +12,7 @@ Devise.setup do |config|
12
12
  # Load and configure the ORM. Supports :active_record (default) and
13
13
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
14
14
  # available as additional gems.
15
- require "devise/orm/mongoid"
15
+ require "devise/orm/active_record"
16
16
 
17
17
  # ==> Configuration for any authentication mechanism
18
18
  # Configure which keys are used when authenticating a user. The default is
@@ -5,4 +5,5 @@
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
7
7
  # (create the session table with "rails generate session_migration")
8
+ MongoStore::Session.database = Mongo::Connection.new.db("rails30_app_#{Rails.env}") if ENV['MONGO_SESSION_STORE_ORM'] == "mongo"
8
9
  Rails30App::Application.config.session_store :"#{ENV['MONGO_SESSION_STORE_ORM']}_store"
@@ -0,0 +1,19 @@
1
+ class CreateUsersTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.database_authenticatable :null => false
5
+ # t.recoverable
6
+ # t.rememberable
7
+ # t.trackable
8
+
9
+ # t.encryptable
10
+ # t.confirmable
11
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12
+ # t.token_authenticatable
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :users
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20120222195914) do
14
+
15
+ create_table "users", :force => true do |t|
16
+ t.string "email", :default => "", :null => false
17
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
18
+ end
19
+
20
+ end
@@ -1,44 +1,6 @@
1
- class User
2
- include Mongoid::Document
1
+ class User < ActiveRecord::Base
3
2
  # Include default devise modules. Others available are:
4
3
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
5
4
  devise :database_authenticatable, :registerable, :validatable
6
5
  #:recoverable, :rememberable, :trackable, :validatable
7
-
8
- # see https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
9
-
10
- ## Database authenticatable
11
- field :email, :type => String, :null => false
12
- field :encrypted_password, :type => String, :null => false
13
-
14
- ## Recoverable
15
- # field :reset_password_token, :type => String
16
- # field :reset_password_sent_at, :type => Time
17
-
18
- ## Rememberable
19
- # field :remember_created_at, :type => Time
20
-
21
- ## Trackable
22
- # field :sign_in_count, :type => Integer
23
- # field :current_sign_in_at, :type => Time
24
- # field :last_sign_in_at, :type => Time
25
- # field :current_sign_in_ip, :type => String
26
- # field :last_sign_in_ip, :type => String
27
-
28
- ## Encryptable
29
- # field :password_salt, :type => String
30
-
31
- ## Confirmable
32
- # field :confirmation_token, :type => String
33
- # field :confirmed_at, :type => Time
34
- # field :confirmation_sent_at, :type => Time
35
- # field :unconfirmed_email, :type => String # Only if using reconfirmable
36
-
37
- ## Lockable
38
- # field :failed_attempts, :type => Integer # Only if lock strategy is :failed_attempts
39
- # field :unlock_token, :type => String # Only if unlock strategy is :email or :both
40
- # field :locked_at, :type => Time
41
-
42
- # Token authenticatable
43
- # field :authentication_token, :type => String
44
6
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- # require "active_record/railtie"
4
+ require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_mailer/railtie"
7
7
  require "active_resource/railtie"
@@ -0,0 +1,11 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ development:
8
+ adapter: sqlite3
9
+ database: db/development.sqlite3
10
+ pool: 5
11
+ timeout: 5000
@@ -15,7 +15,7 @@ Devise.setup do |config|
15
15
  # Load and configure the ORM. Supports :active_record (default) and
16
16
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
17
17
  # available as additional gems.
18
- require "devise/orm/mongoid"
18
+ require "devise/orm/active_record"
19
19
 
20
20
  # ==> Configuration for any authentication mechanism
21
21
  # Configure which keys are used when authenticating a user. The default is
@@ -5,4 +5,5 @@
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
7
7
  # (create the session table with "rails generate session_migration")
8
+ MongoStore::Session.database = Mongo::Connection.new.db("rails31_app_#{Rails.env}") if ENV['MONGO_SESSION_STORE_ORM'] == "mongo"
8
9
  Rails31App::Application.config.session_store :"#{ENV['MONGO_SESSION_STORE_ORM']}_store"
@@ -0,0 +1,12 @@
1
+ class CreateUsersTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :email, :null => false, :default => ""
5
+ t.string :encrypted_password, :null => false, :default => ""
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ drop_table :users
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20120222195914) do
14
+
15
+ create_table "users", :force => true do |t|
16
+ t.string "email", :default => "", :null => false
17
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
18
+ end
19
+
20
+ end
@@ -4,4 +4,4 @@
4
4
 
5
5
  require File.expand_path('../config/application', __FILE__)
6
6
 
7
- Rails31App::Application.load_tasks
7
+ Rails32App::Application.load_tasks
@@ -1,44 +1,6 @@
1
- class User
2
- include Mongoid::Document
1
+ class User < ActiveRecord::Base
3
2
  # Include default devise modules. Others available are:
4
3
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
5
4
  devise :database_authenticatable, :registerable, :validatable
6
5
  #:recoverable, :rememberable, :trackable, :validatable
7
-
8
- # see https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style
9
-
10
- ## Database authenticatable
11
- field :email, :type => String, :null => false
12
- field :encrypted_password, :type => String, :null => false
13
-
14
- ## Recoverable
15
- # field :reset_password_token, :type => String
16
- # field :reset_password_sent_at, :type => Time
17
-
18
- ## Rememberable
19
- # field :remember_created_at, :type => Time
20
-
21
- ## Trackable
22
- # field :sign_in_count, :type => Integer
23
- # field :current_sign_in_at, :type => Time
24
- # field :last_sign_in_at, :type => Time
25
- # field :current_sign_in_ip, :type => String
26
- # field :last_sign_in_ip, :type => String
27
-
28
- ## Encryptable
29
- # field :password_salt, :type => String
30
-
31
- ## Confirmable
32
- # field :confirmation_token, :type => String
33
- # field :confirmed_at, :type => Time
34
- # field :confirmation_sent_at, :type => Time
35
- # field :unconfirmed_email, :type => String # Only if using reconfirmable
36
-
37
- ## Lockable
38
- # field :failed_attempts, :type => Integer # Only if lock strategy is :failed_attempts
39
- # field :unlock_token, :type => String # Only if unlock strategy is :email or :both
40
- # field :locked_at, :type => Time
41
-
42
- # Token authenticatable
43
- # field :authentication_token, :type => String
44
6
  end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Rails31App</title>
4
+ <title>Rails32App</title>
5
5
  <%= csrf_meta_tags %>
6
6
  </head>
7
7
  <body>
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
3
  require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails31App::Application
4
+ run Rails32App::Application
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- # require "active_record/railtie"
4
+ require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_mailer/railtie"
7
7
  require "active_resource/railtie"
@@ -11,7 +11,7 @@ require "active_resource/railtie"
11
11
  # you've limited to :test, :development, or :production.
12
12
  Bundler.require(:default, :test) if defined?(Bundler)
13
13
 
14
- module Rails31App
14
+ module Rails32App
15
15
  class Application < Rails::Application
16
16
  # Settings in config/environments/* take precedence over those specified here.
17
17
  # Application configuration should go into files in config/initializers
@@ -0,0 +1,11 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
4
+ pool: 5
5
+ timeout: 5000
6
+
7
+ development:
8
+ adapter: sqlite3
9
+ database: db/development.sqlite3
10
+ pool: 5
11
+ timeout: 5000
@@ -2,4 +2,4 @@
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
- Rails31App::Application.initialize!
5
+ Rails32App::Application.initialize!
@@ -1,4 +1,4 @@
1
- Rails31App::Application.configure do
1
+ Rails32App::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # In the development environment your application's code is reloaded on
@@ -1,4 +1,4 @@
1
- Rails31App::Application.configure do
1
+ Rails32App::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # Code is not reloaded between requests
@@ -1,4 +1,4 @@
1
- Rails31App::Application.configure do
1
+ Rails32App::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # The test environment is used exclusively to run your application's
@@ -15,7 +15,7 @@ Devise.setup do |config|
15
15
  # Load and configure the ORM. Supports :active_record (default) and
16
16
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
17
17
  # available as additional gems.
18
- require "devise/orm/mongoid"
18
+ require "devise/orm/active_record"
19
19
 
20
20
  # ==> Configuration for any authentication mechanism
21
21
  # Configure which keys are used when authenticating a user. The default is
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Rails31App::Application.config.secret_token = '8e4d927033255ebff9a7b712eed68e65fb80196861bc31a3ba5d814f6e5ad94d7be61ac535fc0f646a1fbe0f67a9ea6af0a8085fff0964936a066f144f9caf25'
7
+ Rails32App::Application.config.secret_token = '8e4d927033255ebff9a7b712eed68e65fb80196861bc31a3ba5d814f6e5ad94d7be61ac535fc0f646a1fbe0f67a9ea6af0a8085fff0964936a066f144f9caf25'
@@ -1,8 +1,9 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Rails31App::Application.config.session_store :cookie_store, :key => '_rails_3.1_app_session'
3
+ # Rails32App::Application.config.session_store :cookie_store, :key => '_rails_3.2_app_session'
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
7
7
  # (create the session table with "rails generate session_migration")
8
- Rails31App::Application.config.session_store :"#{ENV['MONGO_SESSION_STORE_ORM']}_store"
8
+ MongoStore::Session.database = Mongo::Connection.new.db("rails32_app_#{Rails.env}") if ENV['MONGO_SESSION_STORE_ORM'] == "mongo"
9
+ Rails32App::Application.config.session_store :"#{ENV['MONGO_SESSION_STORE_ORM']}_store"
@@ -4,15 +4,15 @@ defaults: &defaults
4
4
 
5
5
  development:
6
6
  <<: *defaults
7
- database: rails31_app_development
7
+ database: rails32_app_development
8
8
 
9
9
  test:
10
10
  <<: *defaults
11
- database: rails31_app_test
11
+ database: rails32_app_test
12
12
 
13
13
  # set these environment variables on your prod server
14
14
  production:
15
15
  <<: *defaults
16
- database: rails31_app
16
+ database: rails32_app
17
17
  username: <%= ENV['MONGO_USERNAME'] %>
18
18
  password: <%= ENV['MONGO_PASSWORD'] %>
@@ -1,10 +1,10 @@
1
1
  development:
2
2
  host: localhost
3
- database: rails31_app_development
3
+ database: rails32_app_development
4
4
 
5
5
  test:
6
6
  host: localhost
7
- database: rails31_app_test
7
+ database: rails32_app_test
8
8
 
9
9
  # set these environment variables on your prod server
10
10
  production:
@@ -1,4 +1,4 @@
1
- Rails31App::Application.routes.draw do
1
+ Rails32App::Application.routes.draw do
2
2
  devise_for :users
3
3
  root :to => "home#index"
4
4
  end
@@ -0,0 +1,12 @@
1
+ class CreateUsersTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :email, :null => false, :default => ""
5
+ t.string :encrypted_password, :null => false, :default => ""
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ drop_table :users
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20120222195914) do
14
+
15
+ create_table "users", :force => true do |t|
16
+ t.string "email", :default => "", :null => false
17
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
18
+ end
19
+
20
+ end
data/spec/spec_helper.rb CHANGED
@@ -23,10 +23,17 @@ def drop_collections_in(database)
23
23
  end
24
24
 
25
25
  RSpec.configure do |config|
26
+ config.before :all do
27
+ unless User.table_exists?
28
+ load Rails.root.join('db', 'schema.rb')
29
+ end
30
+ end
31
+
26
32
  config.before :each do
27
33
  drop_collections_in(Mongoid.database) if defined?(Mongoid)
28
34
  drop_collections_in(MongoMapper.database) if defined?(MongoMapper)
29
35
  drop_collections_in(db)
36
+ User.delete_all
30
37
  end
31
38
  end
32
39
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_session_store-rails3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 4
10
- version: 3.0.4
9
+ - 5
10
+ version: 3.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Hempel
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2012-02-04 00:00:00 Z
21
+ date: 2012-02-24 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: mongo
@@ -96,6 +96,7 @@ files:
96
96
  - spec/rails_3.0_app/config.ru
97
97
  - spec/rails_3.0_app/config/application.rb
98
98
  - spec/rails_3.0_app/config/boot.rb
99
+ - spec/rails_3.0_app/config/database.yml
99
100
  - spec/rails_3.0_app/config/environment.rb
100
101
  - spec/rails_3.0_app/config/environments/development.rb
101
102
  - spec/rails_3.0_app/config/environments/production.rb
@@ -111,6 +112,8 @@ files:
111
112
  - spec/rails_3.0_app/config/mongo.yml
112
113
  - spec/rails_3.0_app/config/mongoid.yml
113
114
  - spec/rails_3.0_app/config/routes.rb
115
+ - spec/rails_3.0_app/db/migrate/20120222195914_create_users_table.rb
116
+ - spec/rails_3.0_app/db/schema.rb
114
117
  - spec/rails_3.0_app/lib/tasks/.gitkeep
115
118
  - spec/rails_3.0_app/public/404.html
116
119
  - spec/rails_3.0_app/public/422.html
@@ -149,6 +152,7 @@ files:
149
152
  - spec/rails_3.1_app/config.ru
150
153
  - spec/rails_3.1_app/config/application.rb
151
154
  - spec/rails_3.1_app/config/boot.rb
155
+ - spec/rails_3.1_app/config/database.yml
152
156
  - spec/rails_3.1_app/config/environment.rb
153
157
  - spec/rails_3.1_app/config/environments/development.rb
154
158
  - spec/rails_3.1_app/config/environments/production.rb
@@ -165,6 +169,8 @@ files:
165
169
  - spec/rails_3.1_app/config/mongo.yml
166
170
  - spec/rails_3.1_app/config/mongoid.yml
167
171
  - spec/rails_3.1_app/config/routes.rb
172
+ - spec/rails_3.1_app/db/migrate/20120222195914_create_users_table.rb
173
+ - spec/rails_3.1_app/db/schema.rb
168
174
  - spec/rails_3.1_app/lib/tasks/.gitkeep
169
175
  - spec/rails_3.1_app/log/.gitkeep
170
176
  - spec/rails_3.1_app/public/404.html
@@ -202,6 +208,7 @@ files:
202
208
  - spec/rails_3.2_app/config.ru
203
209
  - spec/rails_3.2_app/config/application.rb
204
210
  - spec/rails_3.2_app/config/boot.rb
211
+ - spec/rails_3.2_app/config/database.yml
205
212
  - spec/rails_3.2_app/config/environment.rb
206
213
  - spec/rails_3.2_app/config/environments/development.rb
207
214
  - spec/rails_3.2_app/config/environments/production.rb
@@ -218,6 +225,8 @@ files:
218
225
  - spec/rails_3.2_app/config/mongo.yml
219
226
  - spec/rails_3.2_app/config/mongoid.yml
220
227
  - spec/rails_3.2_app/config/routes.rb
228
+ - spec/rails_3.2_app/db/migrate/20120222195914_create_users_table.rb
229
+ - spec/rails_3.2_app/db/schema.rb
221
230
  - spec/rails_3.2_app/lib/tasks/.gitkeep
222
231
  - spec/rails_3.2_app/log/.gitkeep
223
232
  - spec/rails_3.2_app/public/404.html
@@ -288,6 +297,7 @@ test_files:
288
297
  - spec/rails_3.0_app/config.ru
289
298
  - spec/rails_3.0_app/config/application.rb
290
299
  - spec/rails_3.0_app/config/boot.rb
300
+ - spec/rails_3.0_app/config/database.yml
291
301
  - spec/rails_3.0_app/config/environment.rb
292
302
  - spec/rails_3.0_app/config/environments/development.rb
293
303
  - spec/rails_3.0_app/config/environments/production.rb
@@ -303,6 +313,8 @@ test_files:
303
313
  - spec/rails_3.0_app/config/mongo.yml
304
314
  - spec/rails_3.0_app/config/mongoid.yml
305
315
  - spec/rails_3.0_app/config/routes.rb
316
+ - spec/rails_3.0_app/db/migrate/20120222195914_create_users_table.rb
317
+ - spec/rails_3.0_app/db/schema.rb
306
318
  - spec/rails_3.0_app/lib/tasks/.gitkeep
307
319
  - spec/rails_3.0_app/public/404.html
308
320
  - spec/rails_3.0_app/public/422.html
@@ -341,6 +353,7 @@ test_files:
341
353
  - spec/rails_3.1_app/config.ru
342
354
  - spec/rails_3.1_app/config/application.rb
343
355
  - spec/rails_3.1_app/config/boot.rb
356
+ - spec/rails_3.1_app/config/database.yml
344
357
  - spec/rails_3.1_app/config/environment.rb
345
358
  - spec/rails_3.1_app/config/environments/development.rb
346
359
  - spec/rails_3.1_app/config/environments/production.rb
@@ -357,6 +370,8 @@ test_files:
357
370
  - spec/rails_3.1_app/config/mongo.yml
358
371
  - spec/rails_3.1_app/config/mongoid.yml
359
372
  - spec/rails_3.1_app/config/routes.rb
373
+ - spec/rails_3.1_app/db/migrate/20120222195914_create_users_table.rb
374
+ - spec/rails_3.1_app/db/schema.rb
360
375
  - spec/rails_3.1_app/lib/tasks/.gitkeep
361
376
  - spec/rails_3.1_app/log/.gitkeep
362
377
  - spec/rails_3.1_app/public/404.html
@@ -394,6 +409,7 @@ test_files:
394
409
  - spec/rails_3.2_app/config.ru
395
410
  - spec/rails_3.2_app/config/application.rb
396
411
  - spec/rails_3.2_app/config/boot.rb
412
+ - spec/rails_3.2_app/config/database.yml
397
413
  - spec/rails_3.2_app/config/environment.rb
398
414
  - spec/rails_3.2_app/config/environments/development.rb
399
415
  - spec/rails_3.2_app/config/environments/production.rb
@@ -410,6 +426,8 @@ test_files:
410
426
  - spec/rails_3.2_app/config/mongo.yml
411
427
  - spec/rails_3.2_app/config/mongoid.yml
412
428
  - spec/rails_3.2_app/config/routes.rb
429
+ - spec/rails_3.2_app/db/migrate/20120222195914_create_users_table.rb
430
+ - spec/rails_3.2_app/db/schema.rb
413
431
  - spec/rails_3.2_app/lib/tasks/.gitkeep
414
432
  - spec/rails_3.2_app/log/.gitkeep
415
433
  - spec/rails_3.2_app/public/404.html