devise-jdguyot 1.2.rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. data/.gitignore +10 -0
  2. data/CHANGELOG.rdoc +532 -0
  3. data/Gemfile +29 -0
  4. data/Gemfile.lock +152 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +353 -0
  7. data/Rakefile +36 -0
  8. data/TODO +4 -0
  9. data/app/controllers/devise/confirmations_controller.rb +33 -0
  10. data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
  11. data/app/controllers/devise/passwords_controller.rb +41 -0
  12. data/app/controllers/devise/registrations_controller.rb +110 -0
  13. data/app/controllers/devise/sessions_controller.rb +25 -0
  14. data/app/controllers/devise/unlocks_controller.rb +34 -0
  15. data/app/helpers/devise_helper.rb +19 -0
  16. data/app/mailers/devise/mailer.rb +88 -0
  17. data/app/views/devise/confirmations/new.html.erb +12 -0
  18. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  19. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  20. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  21. data/app/views/devise/passwords/edit.html.erb +16 -0
  22. data/app/views/devise/passwords/new.html.erb +12 -0
  23. data/app/views/devise/registrations/edit.html.erb +25 -0
  24. data/app/views/devise/registrations/new.html.erb +18 -0
  25. data/app/views/devise/sessions/new.html.erb +17 -0
  26. data/app/views/devise/shared/_links.erb +25 -0
  27. data/app/views/devise/unlocks/new.html.erb +12 -0
  28. data/config/locales/en.yml +46 -0
  29. data/devise.gemspec +25 -0
  30. data/lib/devise/controllers/helpers.rb +227 -0
  31. data/lib/devise/controllers/internal_helpers.rb +119 -0
  32. data/lib/devise/controllers/scoped_views.rb +33 -0
  33. data/lib/devise/controllers/url_helpers.rb +39 -0
  34. data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
  35. data/lib/devise/encryptors/base.rb +20 -0
  36. data/lib/devise/encryptors/clearance_sha1.rb +17 -0
  37. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  38. data/lib/devise/encryptors/sha1.rb +25 -0
  39. data/lib/devise/encryptors/sha512.rb +25 -0
  40. data/lib/devise/failure_app.rb +132 -0
  41. data/lib/devise/hooks/activatable.rb +11 -0
  42. data/lib/devise/hooks/forgetable.rb +12 -0
  43. data/lib/devise/hooks/rememberable.rb +48 -0
  44. data/lib/devise/hooks/timeoutable.rb +22 -0
  45. data/lib/devise/hooks/trackable.rb +9 -0
  46. data/lib/devise/mapping.rb +110 -0
  47. data/lib/devise/models/authenticatable.rb +146 -0
  48. data/lib/devise/models/confirmable.rb +160 -0
  49. data/lib/devise/models/database_authenticatable.rb +100 -0
  50. data/lib/devise/models/encryptable.rb +72 -0
  51. data/lib/devise/models/lockable.rb +169 -0
  52. data/lib/devise/models/omniauthable.rb +23 -0
  53. data/lib/devise/models/recoverable.rb +123 -0
  54. data/lib/devise/models/registerable.rb +21 -0
  55. data/lib/devise/models/rememberable.rb +130 -0
  56. data/lib/devise/models/timeoutable.rb +43 -0
  57. data/lib/devise/models/token_authenticatable.rb +72 -0
  58. data/lib/devise/models/trackable.rb +30 -0
  59. data/lib/devise/models/validatable.rb +65 -0
  60. data/lib/devise/models.rb +68 -0
  61. data/lib/devise/modules.rb +30 -0
  62. data/lib/devise/omniauth/config.rb +30 -0
  63. data/lib/devise/omniauth/test_helpers.rb +57 -0
  64. data/lib/devise/omniauth/url_helpers.rb +29 -0
  65. data/lib/devise/omniauth.rb +47 -0
  66. data/lib/devise/orm/active_record.rb +38 -0
  67. data/lib/devise/orm/mongoid.rb +31 -0
  68. data/lib/devise/path_checker.rb +18 -0
  69. data/lib/devise/rails/routes.rb +292 -0
  70. data/lib/devise/rails/warden_compat.rb +125 -0
  71. data/lib/devise/rails.rb +50 -0
  72. data/lib/devise/schema.rb +97 -0
  73. data/lib/devise/strategies/authenticatable.rb +150 -0
  74. data/lib/devise/strategies/base.rb +15 -0
  75. data/lib/devise/strategies/database_authenticatable.rb +21 -0
  76. data/lib/devise/strategies/rememberable.rb +51 -0
  77. data/lib/devise/strategies/token_authenticatable.rb +53 -0
  78. data/lib/devise/test_helpers.rb +100 -0
  79. data/lib/devise/version.rb +3 -0
  80. data/lib/devise.rb +381 -0
  81. data/lib/generators/active_record/devise_generator.rb +28 -0
  82. data/lib/generators/active_record/templates/migration.rb +31 -0
  83. data/lib/generators/devise/devise_generator.rb +17 -0
  84. data/lib/generators/devise/install_generator.rb +24 -0
  85. data/lib/generators/devise/orm_helpers.rb +23 -0
  86. data/lib/generators/devise/views_generator.rb +106 -0
  87. data/lib/generators/mongoid/devise_generator.rb +17 -0
  88. data/lib/generators/templates/README +25 -0
  89. data/lib/generators/templates/devise.rb +186 -0
  90. data/test/controllers/helpers_test.rb +237 -0
  91. data/test/controllers/internal_helpers_test.rb +72 -0
  92. data/test/controllers/url_helpers_test.rb +59 -0
  93. data/test/devise_test.rb +65 -0
  94. data/test/encryptors_test.rb +30 -0
  95. data/test/failure_app_test.rb +187 -0
  96. data/test/generators/active_record_generator_test.rb +24 -0
  97. data/test/generators/install_generator_test.rb +13 -0
  98. data/test/generators/mongoid_generator_test.rb +22 -0
  99. data/test/generators/views_generator_test.rb +35 -0
  100. data/test/indifferent_hash.rb +33 -0
  101. data/test/integration/authenticatable_test.rb +447 -0
  102. data/test/integration/confirmable_test.rb +104 -0
  103. data/test/integration/database_authenticatable_test.rb +60 -0
  104. data/test/integration/http_authenticatable_test.rb +74 -0
  105. data/test/integration/lockable_test.rb +109 -0
  106. data/test/integration/omniauthable_test.rb +107 -0
  107. data/test/integration/recoverable_test.rb +160 -0
  108. data/test/integration/registerable_test.rb +179 -0
  109. data/test/integration/rememberable_test.rb +180 -0
  110. data/test/integration/timeoutable_test.rb +89 -0
  111. data/test/integration/token_authenticatable_test.rb +99 -0
  112. data/test/integration/trackable_test.rb +64 -0
  113. data/test/mailers/confirmation_instructions_test.rb +84 -0
  114. data/test/mailers/reset_password_instructions_test.rb +72 -0
  115. data/test/mailers/unlock_instructions_test.rb +66 -0
  116. data/test/mapping_test.rb +119 -0
  117. data/test/models/confirmable_test.rb +221 -0
  118. data/test/models/database_authenticatable_test.rb +98 -0
  119. data/test/models/encryptable_test.rb +65 -0
  120. data/test/models/lockable_test.rb +204 -0
  121. data/test/models/recoverable_test.rb +190 -0
  122. data/test/models/rememberable_test.rb +279 -0
  123. data/test/models/timeoutable_test.rb +28 -0
  124. data/test/models/token_authenticatable_test.rb +37 -0
  125. data/test/models/trackable_test.rb +5 -0
  126. data/test/models/validatable_test.rb +99 -0
  127. data/test/models_test.rb +84 -0
  128. data/test/omniauth/url_helpers_test.rb +47 -0
  129. data/test/orm/active_record.rb +9 -0
  130. data/test/orm/mongoid.rb +11 -0
  131. data/test/rails_app/Rakefile +10 -0
  132. data/test/rails_app/app/active_record/admin.rb +6 -0
  133. data/test/rails_app/app/active_record/shim.rb +2 -0
  134. data/test/rails_app/app/active_record/user.rb +8 -0
  135. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  136. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  137. data/test/rails_app/app/controllers/application_controller.rb +8 -0
  138. data/test/rails_app/app/controllers/home_controller.rb +16 -0
  139. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  140. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  141. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +7 -0
  142. data/test/rails_app/app/controllers/users_controller.rb +18 -0
  143. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  144. data/test/rails_app/app/mongoid/admin.rb +9 -0
  145. data/test/rails_app/app/mongoid/shim.rb +29 -0
  146. data/test/rails_app/app/mongoid/user.rb +10 -0
  147. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  148. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  149. data/test/rails_app/app/views/home/index.html.erb +1 -0
  150. data/test/rails_app/app/views/home/private.html.erb +1 -0
  151. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  152. data/test/rails_app/app/views/users/index.html.erb +1 -0
  153. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  154. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  155. data/test/rails_app/config/application.rb +40 -0
  156. data/test/rails_app/config/boot.rb +13 -0
  157. data/test/rails_app/config/database.yml +18 -0
  158. data/test/rails_app/config/environment.rb +5 -0
  159. data/test/rails_app/config/environments/development.rb +19 -0
  160. data/test/rails_app/config/environments/production.rb +33 -0
  161. data/test/rails_app/config/environments/test.rb +33 -0
  162. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  163. data/test/rails_app/config/initializers/devise.rb +176 -0
  164. data/test/rails_app/config/initializers/inflections.rb +2 -0
  165. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  166. data/test/rails_app/config/routes.rb +55 -0
  167. data/test/rails_app/config.ru +4 -0
  168. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +31 -0
  169. data/test/rails_app/db/schema.rb +52 -0
  170. data/test/rails_app/lib/shared_admin.rb +9 -0
  171. data/test/rails_app/lib/shared_user.rb +23 -0
  172. data/test/rails_app/public/404.html +26 -0
  173. data/test/rails_app/public/422.html +26 -0
  174. data/test/rails_app/public/500.html +26 -0
  175. data/test/rails_app/public/favicon.ico +0 -0
  176. data/test/rails_app/script/rails +10 -0
  177. data/test/routes_test.rb +179 -0
  178. data/test/support/assertions.rb +24 -0
  179. data/test/support/helpers.rb +60 -0
  180. data/test/support/integration.rb +88 -0
  181. data/test/support/locale/en.yml +4 -0
  182. data/test/support/webrat/integrations/rails.rb +24 -0
  183. data/test/test_helper.rb +29 -0
  184. data/test/test_helpers_test.rb +118 -0
  185. metadata +388 -0
@@ -0,0 +1,84 @@
1
+ require 'test_helper'
2
+
3
+ class Configurable < User
4
+ devise :database_authenticatable, :encryptable, :confirmable, :rememberable, :timeoutable, :lockable,
5
+ :stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
6
+ :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
7
+ end
8
+
9
+ class Inheritable < Admin
10
+ end
11
+
12
+ class ActiveRecordTest < ActiveSupport::TestCase
13
+ def include_module?(klass, mod)
14
+ klass.devise_modules.include?(mod) &&
15
+ klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
16
+ end
17
+
18
+ def assert_include_modules(klass, *modules)
19
+ modules.each do |mod|
20
+ assert include_module?(klass, mod)
21
+ end
22
+
23
+ (Devise::ALL - modules).each do |mod|
24
+ assert_not include_module?(klass, mod)
25
+ end
26
+ end
27
+
28
+ test 'can cherry pick modules' do
29
+ assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :rememberable, :encryptable
30
+ end
31
+
32
+ test 'chosen modules are inheritable' do
33
+ assert_include_modules Inheritable, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :rememberable, :encryptable
34
+ end
35
+
36
+ test 'order of module inclusion' do
37
+ correct_module_order = [:database_authenticatable, :rememberable, :encryptable, :recoverable, :registerable, :lockable, :timeoutable]
38
+ incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :encryptable, :rememberable]
39
+
40
+ assert_include_modules Admin, *incorrect_module_order
41
+
42
+ # get module constants from symbol list
43
+ module_constants = correct_module_order.collect { |mod| Devise::Models::const_get(mod.to_s.classify) }
44
+
45
+ # confirm that they adhere to the order in ALL
46
+ # get included modules, filter out the noise, and reverse the order
47
+ assert_equal module_constants, (Admin.included_modules & module_constants).reverse
48
+ end
49
+
50
+ test 'raise error on invalid module' do
51
+ assert_raise NameError do
52
+ # Mix valid an invalid modules.
53
+ Configurable.class_eval { devise :database_authenticatable, :doesnotexit }
54
+ end
55
+ end
56
+
57
+ test 'set a default value for stretches' do
58
+ assert_equal 15, Configurable.stretches
59
+ end
60
+
61
+ test 'set a default value for pepper' do
62
+ assert_equal 'abcdef', Configurable.pepper
63
+ end
64
+
65
+ test 'set a default value for confirm_within' do
66
+ assert_equal 5.days, Configurable.confirm_within
67
+ end
68
+
69
+ test 'set a default value for remember_for' do
70
+ assert_equal 7.days, Configurable.remember_for
71
+ end
72
+
73
+ test 'set a default value for timeout_in' do
74
+ assert_equal 15.minutes, Configurable.timeout_in
75
+ end
76
+
77
+ test 'set a default value for unlock_in' do
78
+ assert_equal 10.days, Configurable.unlock_in
79
+ end
80
+
81
+ test 'set null fields on migrations' do
82
+ Admin.create!
83
+ end
84
+ end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class OmniAuthRoutesTest < ActionController::TestCase
4
+ tests ApplicationController
5
+
6
+ def assert_path(action, provider, with_param=true)
7
+ # Resource param
8
+ assert_equal @controller.send(action, :user, provider),
9
+ @controller.send("user_#{action}", provider)
10
+
11
+ # With an object
12
+ assert_equal @controller.send(action, User.new, provider),
13
+ @controller.send("user_#{action}", provider)
14
+
15
+ if with_param
16
+ # Default url params
17
+ assert_equal @controller.send(action, :user, provider, :param => 123),
18
+ @controller.send("user_#{action}", provider, :param => 123)
19
+ end
20
+ end
21
+
22
+ test 'should alias omniauth_callback to mapped user auth_callback' do
23
+ assert_path :omniauth_callback_path, :facebook
24
+ end
25
+
26
+ test 'should alias omniauth_authorize to mapped user auth_authorize' do
27
+ assert_path :omniauth_authorize_path, :facebook, false
28
+ end
29
+
30
+ test 'should generate authorization path' do
31
+ assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
32
+
33
+ assert_raise ArgumentError do
34
+ @controller.omniauth_authorize_path(:user, :github)
35
+ end
36
+ end
37
+
38
+ test 'should generate authorization path with params' do
39
+ assert_match "/users/auth/open_id?openid_url=http%3A%2F%2Fyahoo.com",
40
+ @controller.omniauth_authorize_path(:user, :open_id, :openid_url => "http://yahoo.com")
41
+ end
42
+
43
+ test 'should not add a "?" if no param was sent' do
44
+ assert_equal "/users/auth/open_id",
45
+ @controller.omniauth_authorize_path(:user, :open_id)
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Migration.verbose = false
2
+ ActiveRecord::Base.logger = Logger.new(nil)
3
+
4
+ ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
5
+
6
+ class ActiveSupport::TestCase
7
+ self.use_transactional_fixtures = true
8
+ self.use_instantiated_fixtures = false
9
+ end
@@ -0,0 +1,11 @@
1
+ Mongoid.configure do |config|
2
+ config.master = Mongo::Connection.new('127.0.0.1', 27017).db("devise-test-suite")
3
+ config.use_utc = true
4
+ end
5
+
6
+ class ActiveSupport::TestCase
7
+ setup do
8
+ User.delete_all
9
+ Admin.delete_all
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ Rails.application.load_tasks
@@ -0,0 +1,6 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin < ActiveRecord::Base
4
+ include Shim
5
+ include SharedAdmin
6
+ end
@@ -0,0 +1,2 @@
1
+ module Shim
2
+ end
@@ -0,0 +1,8 @@
1
+ require 'shared_user'
2
+
3
+ class User < ActiveRecord::Base
4
+ include Shim
5
+ include SharedUser
6
+
7
+ attr_accessible :username, :email, :password, :password_confirmation, :remember_me
8
+ end
@@ -0,0 +1,6 @@
1
+ class Admins::SessionsController < Devise::SessionsController
2
+ def new
3
+ flash[:special] = "Welcome to #{controller_path.inspect} controller!"
4
+ super
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AdminsController < ApplicationController
2
+ before_filter :authenticate_admin!
3
+
4
+ def index
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery
6
+ before_filter :current_user
7
+ before_filter :authenticate_user!, :if => :devise_controller?
8
+ end
@@ -0,0 +1,16 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def private
6
+ end
7
+
8
+ def set
9
+ session["devise.foo_bar"] = "something"
10
+ head :ok
11
+ end
12
+
13
+ def unauthenticated
14
+ render :text => "unauthenticated", :status => :unauthorized
15
+ end
16
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::RegistrationsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::SessionsController < ApplicationController
2
+ end
@@ -0,0 +1,7 @@
1
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ def facebook
3
+ data = env["omniauth.auth"]
4
+ session["devise.facebook_data"] = data["extra"]["user_hash"]
5
+ render :json => data
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ class UsersController < ApplicationController
2
+ before_filter :authenticate_user!, :except => :accept
3
+ respond_to :html, :xml
4
+
5
+ def index
6
+ user_session[:cart] = "Cart"
7
+ respond_with(current_user)
8
+ end
9
+
10
+ def accept
11
+ @current_user = current_user
12
+ end
13
+
14
+ def expire
15
+ user_session['last_request_at'] = 31.minutes.ago.utc
16
+ render :text => 'User will be expired on next request'
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedAdmin
7
+
8
+ field :remember_token, :type => String
9
+ end
@@ -0,0 +1,29 @@
1
+ module Shim
2
+ extend ::ActiveSupport::Concern
3
+
4
+ included do
5
+ include ::Mongoid::Timestamps
6
+ field :created_at, :type => DateTime
7
+ end
8
+
9
+ module ClassMethods
10
+ def last(options={})
11
+ options.delete(:order) if options[:order] == "id"
12
+ super(options)
13
+ end
14
+
15
+ def find_by_email(email)
16
+ first(:conditions => { :email => email })
17
+ end
18
+ end
19
+
20
+ # overwrite equality (because some devise tests use this for asserting model equality)
21
+ def ==(other)
22
+ other.is_a?(self.class) && _id == other._id
23
+ end
24
+
25
+ # Mongoid does not have this method in the current beta version (2.0.0.beta.20)
26
+ def update_attribute(attribute, value)
27
+ update_attributes(attribute => value)
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ require 'shared_user'
2
+
3
+ class User
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedUser
7
+
8
+ field :username, :type => String
9
+ field :facebook_token, :type => String
10
+ end
@@ -0,0 +1 @@
1
+ Welcome Admin!
@@ -0,0 +1,2 @@
1
+ Welcome to "sessions/new" view!
2
+ <%= render :file => "devise/sessions/new" %>
@@ -0,0 +1 @@
1
+ Home!
@@ -0,0 +1 @@
1
+ Private!
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Devise Test App</title>
6
+ </head>
7
+ <body>
8
+ <div id="container">
9
+ <%- flash.each do |name, msg| -%>
10
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
11
+ <%- end -%>
12
+
13
+ <% if user_signed_in? -%>
14
+ <p>Hello User <%= current_user.email %>! You are signed in!</p>
15
+ <% end -%>
16
+
17
+ <% if admin_signed_in? -%>
18
+ <p>Hello Admin <%= current_admin.email %>! You are signed in!</p>
19
+ <% end -%>
20
+
21
+ <%= yield %>
22
+ </div>
23
+ </body>
24
+ </html>
@@ -0,0 +1 @@
1
+ Welcome User #<%= current_user.id %>!
@@ -0,0 +1 @@
1
+ <%= @resource.email %>
@@ -0,0 +1 @@
1
+ Special user view
@@ -0,0 +1,40 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "action_mailer/railtie"
5
+ require "active_resource/railtie"
6
+ require "rails/test_unit/railtie"
7
+
8
+ Bundler.require :default, DEVISE_ORM
9
+
10
+ begin
11
+ require "#{DEVISE_ORM}/railtie"
12
+ rescue LoadError
13
+ end
14
+
15
+ require "devise"
16
+
17
+ module RailsApp
18
+ class Application < Rails::Application
19
+ # Add additional load paths for your own custom dirs
20
+ config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
21
+ config.autoload_paths += [ "#{config.root}/app/#{DEVISE_ORM}" ]
22
+
23
+ # Configure generators values. Many other options are available, be sure to check the documentation.
24
+ # config.generators do |g|
25
+ # g.orm :active_record
26
+ # g.template_engine :erb
27
+ # g.test_framework :test_unit, :fixture => true
28
+ # end
29
+
30
+ # Configure sensitive parameters which will be filtered from the log file.
31
+ config.filter_parameters << :password
32
+
33
+ config.action_mailer.default_url_options = { :host => "localhost:3000" }
34
+
35
+ # This was used to break devise in some situations
36
+ config.to_prepare do
37
+ Devise::SessionsController.layout "application"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ unless defined?(DEVISE_ORM)
2
+ DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
3
+ end
4
+
5
+ begin
6
+ require File.expand_path("../../../../.bundle/environment", __FILE__)
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ require 'bundler'
10
+ Bundler.setup :default, :test, DEVISE_ORM
11
+ end
12
+
13
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,18 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: ":memory:"
15
+
16
+ production:
17
+ adapter: sqlite3
18
+ database: ":memory:"
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,19 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+ end
@@ -0,0 +1,33 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Disable Rails's static asset server
22
+ # In production, Apache or nginx will already do this
23
+ config.serve_static_assets = false
24
+
25
+ # Enable serving of images, stylesheets, and javascripts from an asset server
26
+ # config.action_controller.asset_host = "http://assets.example.com"
27
+
28
+ # Disable delivery errors, bad email addresses will be ignored
29
+ # config.action_mailer.raise_delivery_errors = false
30
+
31
+ # Enable threaded mode
32
+ # config.threadsafe!
33
+ end
@@ -0,0 +1,33 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.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 = true
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
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
29
+
30
+ config.action_dispatch.show_exceptions = false
31
+
32
+ config.active_support.deprecation = :stderr
33
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ Rails.backtrace_cleaner.remove_silencers!