devise_ennder 1.0.1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +397 -0
- data/INSTALL +94 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +272 -0
- data/Rakefile +53 -0
- data/TODO +2 -0
- data/app/controllers/confirmations_controller.rb +33 -0
- data/app/controllers/passwords_controller.rb +41 -0
- data/app/controllers/registrations_controller.rb +62 -0
- data/app/controllers/sessions_controller.rb +42 -0
- data/app/controllers/unlocks_controller.rb +41 -0
- data/app/models/devise_mailer.rb +68 -0
- data/app/models/user.rb +9 -0
- data/app/views/confirmations/new.html.erb +14 -0
- data/app/views/devise_mailer/confirmation_instructions.html.erb +6 -0
- data/app/views/devise_mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise_mailer/unlock_instructions.html.erb +7 -0
- data/app/views/passwords/edit.html.erb +16 -0
- data/app/views/passwords/new.html.erb +12 -0
- data/app/views/registrations/edit.html.erb +25 -0
- data/app/views/registrations/new.html.erb +17 -0
- data/app/views/sessions/new.html.erb +17 -0
- data/app/views/shared/_devise_links.erb +19 -0
- data/app/views/shared/_user_nav.html.erb +15 -0
- data/app/views/unlocks/new.html.erb +12 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/devise.fr.yml +60 -0
- data/config/locales/en.yml +6 -0
- data/config/locales/fr.yml +18 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20100506013336_devise_create_users.rb +23 -0
- data/lib/devise/controllers/helpers.rb +212 -0
- data/lib/devise/controllers/internal_helpers.rb +129 -0
- data/lib/devise/controllers/url_helpers.rb +41 -0
- data/lib/devise/encryptors/authlogic_sha512.rb +21 -0
- data/lib/devise/encryptors/base.rb +20 -0
- data/lib/devise/encryptors/bcrypt.rb +21 -0
- data/lib/devise/encryptors/clearance_sha1.rb +19 -0
- data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
- data/lib/devise/encryptors/sha1.rb +27 -0
- data/lib/devise/encryptors/sha512.rb +27 -0
- data/lib/devise/failure_app.rb +70 -0
- data/lib/devise/hooks/activatable.rb +15 -0
- data/lib/devise/hooks/rememberable.rb +33 -0
- data/lib/devise/hooks/timeoutable.rb +18 -0
- data/lib/devise/hooks/trackable.rb +18 -0
- data/lib/devise/locales/en.yml +35 -0
- data/lib/devise/mapping.rb +130 -0
- data/lib/devise/models/activatable.rb +16 -0
- data/lib/devise/models/confirmable.rb +167 -0
- data/lib/devise/models/database_authenticatable.rb +144 -0
- data/lib/devise/models/http_authenticatable.rb +23 -0
- data/lib/devise/models/lockable.rb +150 -0
- data/lib/devise/models/recoverable.rb +80 -0
- data/lib/devise/models/registerable.rb +8 -0
- data/lib/devise/models/rememberable.rb +92 -0
- data/lib/devise/models/timeoutable.rb +28 -0
- data/lib/devise/models/token_authenticatable.rb +89 -0
- data/lib/devise/models/trackable.rb +16 -0
- data/lib/devise/models/validatable.rb +39 -0
- data/lib/devise/models.rb +117 -0
- data/lib/devise/orm/active_record.rb +41 -0
- data/lib/devise/orm/data_mapper.rb +83 -0
- data/lib/devise/orm/mongo_mapper.rb +52 -0
- data/lib/devise/rails/routes.rb +133 -0
- data/lib/devise/rails/warden_compat.rb +60 -0
- data/lib/devise/rails.rb +14 -0
- data/lib/devise/schema.rb +73 -0
- data/lib/devise/strategies/base.rb +16 -0
- data/lib/devise/strategies/database_authenticatable.rb +36 -0
- data/lib/devise/strategies/http_authenticatable.rb +59 -0
- data/lib/devise/strategies/rememberable.rb +37 -0
- data/lib/devise/strategies/token_authenticatable.rb +37 -0
- data/lib/devise/test_helpers.rb +90 -0
- data/lib/devise/version.rb +3 -0
- data/lib/devise.rb +269 -0
- data/lib/devise_ennder.rb +3 -0
- data/lib/tasks/devise_ennder_tasks.rake +11 -0
- data/test/controllers/helpers_test.rb +184 -0
- data/test/controllers/internal_helpers_test.rb +55 -0
- data/test/controllers/url_helpers_test.rb +47 -0
- data/test/devise_test.rb +74 -0
- data/test/encryptors_test.rb +31 -0
- data/test/failure_app_test.rb +44 -0
- data/test/integration/authenticatable_test.rb +332 -0
- data/test/integration/confirmable_test.rb +97 -0
- data/test/integration/http_authenticatable_test.rb +52 -0
- data/test/integration/lockable_test.rb +102 -0
- data/test/integration/rack_middleware_test.rb +47 -0
- data/test/integration/recoverable_test.rb +141 -0
- data/test/integration/registerable_test.rb +144 -0
- data/test/integration/rememberable_test.rb +72 -0
- data/test/integration/timeoutable_test.rb +68 -0
- data/test/integration/token_authenticatable_test.rb +55 -0
- data/test/integration/trackable_test.rb +64 -0
- data/test/mailers/confirmation_instructions_test.rb +86 -0
- data/test/mailers/reset_password_instructions_test.rb +68 -0
- data/test/mailers/unlock_instructions_test.rb +62 -0
- data/test/mapping_test.rb +158 -0
- data/test/models/authenticatable_test.rb +180 -0
- data/test/models/confirmable_test.rb +228 -0
- data/test/models/lockable_test.rb +202 -0
- data/test/models/recoverable_test.rb +138 -0
- data/test/models/rememberable_test.rb +135 -0
- data/test/models/timeoutable_test.rb +28 -0
- data/test/models/token_authenticatable_test.rb +51 -0
- data/test/models/trackable_test.rb +5 -0
- data/test/models/validatable_test.rb +106 -0
- data/test/models_test.rb +70 -0
- data/test/orm/active_record.rb +31 -0
- data/test/orm/mongo_mapper.rb +20 -0
- data/test/rails_app/app/active_record/admin.rb +7 -0
- data/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/app/controllers/application_controller.rb +12 -0
- data/test/rails_app/app/controllers/home_controller.rb +4 -0
- data/test/rails_app/app/controllers/users_controller.rb +16 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/mongo_mapper/admin.rb +13 -0
- data/test/rails_app/app/mongo_mapper/user.rb +14 -0
- data/test/rails_app/config/boot.rb +110 -0
- data/test/rails_app/config/environment.rb +42 -0
- data/test/rails_app/config/environments/development.rb +17 -0
- data/test/rails_app/config/environments/production.rb +28 -0
- data/test/rails_app/config/environments/test.rb +28 -0
- data/test/rails_app/config/initializers/devise.rb +82 -0
- data/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/config/initializers/new_rails_defaults.rb +24 -0
- data/test/rails_app/config/initializers/session_store.rb +15 -0
- data/test/rails_app/config/routes.rb +25 -0
- data/test/rails_app/vendor/plugins/devise/app/controllers/confirmations_controller.rb +33 -0
- data/test/rails_app/vendor/plugins/devise/app/controllers/passwords_controller.rb +41 -0
- data/test/rails_app/vendor/plugins/devise/app/controllers/registrations_controller.rb +53 -0
- data/test/rails_app/vendor/plugins/devise/app/controllers/sessions_controller.rb +42 -0
- data/test/rails_app/vendor/plugins/devise/app/controllers/unlocks_controller.rb +41 -0
- data/test/rails_app/vendor/plugins/devise/app/models/devise_mailer.rb +68 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise/devise_generator.rb +15 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise/lib/route_devise.rb +32 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise/templates/migration.rb +23 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise/templates/model.rb +9 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise_install/devise_install_generator.rb +15 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise_install/templates/devise.rb +105 -0
- data/test/rails_app/vendor/plugins/devise/generators/devise_views/devise_views_generator.rb +21 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/controllers/helpers.rb +212 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/controllers/internal_helpers.rb +129 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/controllers/url_helpers.rb +41 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/authlogic_sha512.rb +21 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/base.rb +20 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/bcrypt.rb +21 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/clearance_sha1.rb +19 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/sha1.rb +27 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/encryptors/sha512.rb +27 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/failure_app.rb +70 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/hooks/activatable.rb +15 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/hooks/rememberable.rb +33 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/hooks/timeoutable.rb +18 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/hooks/trackable.rb +18 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/mapping.rb +130 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/activatable.rb +16 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/confirmable.rb +167 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/database_authenticatable.rb +144 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/http_authenticatable.rb +23 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/lockable.rb +150 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/recoverable.rb +80 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/registerable.rb +8 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/rememberable.rb +92 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/timeoutable.rb +28 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/token_authenticatable.rb +89 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/trackable.rb +16 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models/validatable.rb +39 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/models.rb +117 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/orm/active_record.rb +41 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/orm/data_mapper.rb +83 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/orm/mongo_mapper.rb +52 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/rails/routes.rb +133 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/rails/warden_compat.rb +60 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/rails.rb +14 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/schema.rb +73 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/strategies/base.rb +16 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/strategies/database_authenticatable.rb +36 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/strategies/http_authenticatable.rb +59 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/strategies/rememberable.rb +37 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/strategies/token_authenticatable.rb +37 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/test_helpers.rb +90 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise/version.rb +3 -0
- data/test/rails_app/vendor/plugins/devise/lib/devise.rb +266 -0
- data/test/rails_app/vendor/plugins/devise/rails/init.rb +2 -0
- data/test/rails_app/vendor/plugins/devise/test/controllers/helpers_test.rb +184 -0
- data/test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb +55 -0
- data/test/rails_app/vendor/plugins/devise/test/controllers/url_helpers_test.rb +47 -0
- data/test/rails_app/vendor/plugins/devise/test/devise_test.rb +74 -0
- data/test/rails_app/vendor/plugins/devise/test/encryptors_test.rb +31 -0
- data/test/rails_app/vendor/plugins/devise/test/failure_app_test.rb +44 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/authenticatable_test.rb +332 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/confirmable_test.rb +97 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/http_authenticatable_test.rb +52 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/lockable_test.rb +102 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/rack_middleware_test.rb +47 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/recoverable_test.rb +141 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/registerable_test.rb +144 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/rememberable_test.rb +72 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/timeoutable_test.rb +68 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/token_authenticatable_test.rb +55 -0
- data/test/rails_app/vendor/plugins/devise/test/integration/trackable_test.rb +64 -0
- data/test/rails_app/vendor/plugins/devise/test/mailers/confirmation_instructions_test.rb +86 -0
- data/test/rails_app/vendor/plugins/devise/test/mailers/reset_password_instructions_test.rb +68 -0
- data/test/rails_app/vendor/plugins/devise/test/mailers/unlock_instructions_test.rb +62 -0
- data/test/rails_app/vendor/plugins/devise/test/mapping_test.rb +158 -0
- data/test/rails_app/vendor/plugins/devise/test/models/authenticatable_test.rb +180 -0
- data/test/rails_app/vendor/plugins/devise/test/models/confirmable_test.rb +228 -0
- data/test/rails_app/vendor/plugins/devise/test/models/lockable_test.rb +202 -0
- data/test/rails_app/vendor/plugins/devise/test/models/recoverable_test.rb +138 -0
- data/test/rails_app/vendor/plugins/devise/test/models/rememberable_test.rb +135 -0
- data/test/rails_app/vendor/plugins/devise/test/models/timeoutable_test.rb +28 -0
- data/test/rails_app/vendor/plugins/devise/test/models/token_authenticatable_test.rb +51 -0
- data/test/rails_app/vendor/plugins/devise/test/models/trackable_test.rb +5 -0
- data/test/rails_app/vendor/plugins/devise/test/models/validatable_test.rb +106 -0
- data/test/rails_app/vendor/plugins/devise/test/models_test.rb +70 -0
- data/test/rails_app/vendor/plugins/devise/test/orm/active_record.rb +31 -0
- data/test/rails_app/vendor/plugins/devise/test/orm/mongo_mapper.rb +20 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/active_record/admin.rb +7 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/controllers/application_controller.rb +12 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/controllers/home_controller.rb +4 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/controllers/users_controller.rb +16 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/mongo_mapper/admin.rb +13 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/app/mongo_mapper/user.rb +14 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/boot.rb +110 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/environment.rb +42 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/environments/development.rb +17 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/environments/production.rb +28 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/environments/test.rb +28 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/initializers/devise.rb +82 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/initializers/new_rails_defaults.rb +24 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/initializers/session_store.rb +15 -0
- data/test/rails_app/vendor/plugins/devise/test/rails_app/config/routes.rb +25 -0
- data/test/rails_app/vendor/plugins/devise/test/routes_test.rb +131 -0
- data/test/rails_app/vendor/plugins/devise/test/support/assertions_helper.rb +37 -0
- data/test/rails_app/vendor/plugins/devise/test/support/integration_tests_helper.rb +71 -0
- data/test/rails_app/vendor/plugins/devise/test/support/test_silencer.rb +5 -0
- data/test/rails_app/vendor/plugins/devise/test/support/tests_helper.rb +39 -0
- data/test/rails_app/vendor/plugins/devise/test/test_helper.rb +21 -0
- data/test/rails_app/vendor/plugins/devise/test/test_helpers_test.rb +57 -0
- data/test/routes_test.rb +131 -0
- data/test/support/assertions_helper.rb +37 -0
- data/test/support/integration_tests_helper.rb +71 -0
- data/test/support/test_silencer.rb +5 -0
- data/test/support/tests_helper.rb +39 -0
- data/test/test_helper.rb +21 -0
- data/test/test_helpers_test.rb +57 -0
- metadata +515 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test/test_helper'
|
2
|
+
|
3
|
+
class Configurable < User
|
4
|
+
devise :database_authenticatable, :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 ActiveRecordTest < ActiveSupport::TestCase
|
10
|
+
def include_module?(klass, mod)
|
11
|
+
klass.devise_modules.include?(mod) &&
|
12
|
+
klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert_include_modules(klass, *modules)
|
16
|
+
modules.each do |mod|
|
17
|
+
assert include_module?(klass, mod)
|
18
|
+
end
|
19
|
+
|
20
|
+
(Devise::ALL - modules).each do |mod|
|
21
|
+
assert_not include_module?(klass, mod)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'add modules cherry pick' do
|
26
|
+
assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'order of module inclusion' do
|
30
|
+
correct_module_order = [:database_authenticatable, :registerable, :timeoutable]
|
31
|
+
incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable]
|
32
|
+
|
33
|
+
assert_include_modules Admin, *incorrect_module_order
|
34
|
+
|
35
|
+
# get module constants from symbol list
|
36
|
+
module_constants = correct_module_order.collect { |mod| Devise::Models::const_get(mod.to_s.classify) }
|
37
|
+
|
38
|
+
# confirm that they adhere to the order in ALL
|
39
|
+
# get included modules, filter out the noise, and reverse the order
|
40
|
+
assert_equal module_constants, (Admin.included_modules & module_constants).reverse
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'set a default value for stretches' do
|
44
|
+
assert_equal 15, Configurable.stretches
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'set a default value for pepper' do
|
48
|
+
assert_equal 'abcdef', Configurable.pepper
|
49
|
+
end
|
50
|
+
|
51
|
+
test 'set a default value for confirm_within' do
|
52
|
+
assert_equal 5.days, Configurable.confirm_within
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'set a default value for remember_for' do
|
56
|
+
assert_equal 7.days, Configurable.remember_for
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'set a default value for timeout_in' do
|
60
|
+
assert_equal 15.minutes, Configurable.timeout_in
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'set a default value for unlock_in' do
|
64
|
+
assert_equal 10.days, Configurable.unlock_in
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'set null fields on migrations' do
|
68
|
+
Admin.create!
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
2
|
+
require 'test_help'
|
3
|
+
|
4
|
+
ActiveRecord::Migration.verbose = false
|
5
|
+
ActiveRecord::Base.logger = Logger.new(nil)
|
6
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
7
|
+
|
8
|
+
ActiveRecord::Schema.define(:version => 1) do
|
9
|
+
[:users, :admins, :accounts].each do |table|
|
10
|
+
create_table table do |t|
|
11
|
+
t.database_authenticatable :null => table == :admins
|
12
|
+
|
13
|
+
if table != :admin
|
14
|
+
t.string :username
|
15
|
+
t.confirmable
|
16
|
+
t.recoverable
|
17
|
+
t.rememberable
|
18
|
+
t.trackable
|
19
|
+
t.lockable
|
20
|
+
t.token_authenticatable
|
21
|
+
end
|
22
|
+
|
23
|
+
t.timestamps
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ActiveSupport::TestCase
|
29
|
+
self.use_transactional_fixtures = true
|
30
|
+
self.use_instantiated_fixtures = false
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'mongo_mapper'
|
2
|
+
MongoMapper.database = "devise-test-suite"
|
3
|
+
MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), '..', 'rails_app', 'config', 'environment')
|
6
|
+
require 'test_help'
|
7
|
+
|
8
|
+
module MongoMapper::Document
|
9
|
+
# TODO This should not be required
|
10
|
+
def invalid?
|
11
|
+
!valid?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class ActiveSupport::TestCase
|
16
|
+
setup do
|
17
|
+
User.delete_all
|
18
|
+
Admin.delete_all
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
devise :database_authenticatable, :http_authenticatable, :confirmable,
|
3
|
+
:lockable, :recoverable, :registerable, :rememberable, :timeoutable,
|
4
|
+
:token_authenticatable, :trackable, :validatable
|
5
|
+
|
6
|
+
attr_accessible :username, :email, :password, :password_confirmation
|
7
|
+
end
|
data/test/rails_app/vendor/plugins/devise/test/rails_app/app/controllers/application_controller.rb
ADDED
@@ -0,0 +1,12 @@
|
|
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
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
filter_parameter_logging :password
|
10
|
+
|
11
|
+
before_filter :current_user
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_filter :authenticate_user!
|
3
|
+
|
4
|
+
def index
|
5
|
+
user_session[:cart] = "Cart"
|
6
|
+
end
|
7
|
+
|
8
|
+
def expire
|
9
|
+
user_session['last_request_at'] = 31.minutes.ago.utc
|
10
|
+
render :text => 'User will be expired on next request'
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
render :text => current_user.id.to_s
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Admin
|
2
|
+
include MongoMapper::Document
|
3
|
+
devise :authenticatable, :registerable, :timeoutable
|
4
|
+
|
5
|
+
def self.find_for_authentication(conditions)
|
6
|
+
last(:conditions => conditions)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.last(options={})
|
10
|
+
options.merge!(:order => 'email')
|
11
|
+
super options
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class User
|
2
|
+
include MongoMapper::Document
|
3
|
+
key :created_at, DateTime
|
4
|
+
devise :authenticatable, :http_authenticatable, :confirmable, :lockable, :recoverable,
|
5
|
+
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
6
|
+
:trackable, :validatable
|
7
|
+
# attr_accessible :username, :email, :password, :password_confirmation
|
8
|
+
|
9
|
+
def self.last(options={})
|
10
|
+
options.merge!(:order => 'email')
|
11
|
+
super options
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
Rails::GemDependency.add_frozen_gem_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class GemBoot < Boot
|
52
|
+
def load_initializer
|
53
|
+
self.class.load_rubygems
|
54
|
+
load_rails_gem
|
55
|
+
require 'initializer'
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_rails_gem
|
59
|
+
if version = self.class.gem_version
|
60
|
+
gem 'rails', version
|
61
|
+
else
|
62
|
+
gem 'rails'
|
63
|
+
end
|
64
|
+
rescue Gem::LoadError => load_error
|
65
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def rubygems_version
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def gem_version
|
75
|
+
if defined? RAILS_GEM_VERSION
|
76
|
+
RAILS_GEM_VERSION
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
79
|
+
else
|
80
|
+
parse_gem_version(read_environment_rb)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_rubygems
|
85
|
+
min_version = '1.3.2'
|
86
|
+
require 'rubygems'
|
87
|
+
unless rubygems_version >= min_version
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
|
92
|
+
rescue LoadError
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_gem_version(text)
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def read_environment_rb
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# All that for this:
|
110
|
+
Rails.boot!
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
4
|
+
RAILS_GEM_VERSION = '2.3.10' unless defined? RAILS_GEM_VERSION
|
5
|
+
DEVISE_ORM = :active_record unless defined? DEVISE_ORM
|
6
|
+
|
7
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
8
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
9
|
+
|
10
|
+
Rails::Initializer.run do |config|
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Add additional load paths for your own custom dirs
|
16
|
+
config.autoload_paths += [ "#{RAILS_ROOT}/app/#{DEVISE_ORM}/" ]
|
17
|
+
|
18
|
+
# Specify gems that this application depends on and have them installed with rake gems:install
|
19
|
+
# config.gem "bj"
|
20
|
+
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
21
|
+
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
22
|
+
# config.gem "aws-s3", :lib => "aws/s3"
|
23
|
+
|
24
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
+
|
28
|
+
# Skip frameworks you're not going to use. To use Rails without a database,
|
29
|
+
# you must remove the Active Record framework.
|
30
|
+
config.frameworks -= [ :active_record ] unless DEVISE_ORM == :active_record
|
31
|
+
|
32
|
+
# Activate observers that should always be running
|
33
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
34
|
+
|
35
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
36
|
+
# Run "rake -D time" for a list of tasks for finding time zone names.
|
37
|
+
config.time_zone = 'UTC'
|
38
|
+
|
39
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
40
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
41
|
+
# config.i18n.default_locale = :en
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# In the development environment your application's code is reloaded on
|
4
|
+
# every request. This slows down response time but is perfect for development
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
6
|
+
config.cache_classes = false
|
7
|
+
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
9
|
+
config.whiny_nils = true
|
10
|
+
|
11
|
+
# Show full error reports and disable caching
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
13
|
+
config.action_view.debug_rjs = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The production environment is meant for finished, "live" apps.
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.action_controller.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
config.action_view.cache_template_loading = 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
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
22
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
23
|
+
|
24
|
+
# Disable delivery errors, bad email addresses will be ignored
|
25
|
+
# config.action_mailer.raise_delivery_errors = false
|
26
|
+
|
27
|
+
# Enable threaded mode
|
28
|
+
# config.threadsafe!
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
config.cache_classes = true
|
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.action_controller.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
config.action_view.cache_template_loading = true
|
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
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
2
|
+
# four configuration values can also be set straight in your models.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# Invoke `rake secret` and use the printed value to setup a pepper to generate
|
5
|
+
# the encrypted password. By default no pepper is used.
|
6
|
+
# config.pepper = "rake secret output"
|
7
|
+
|
8
|
+
# Configure how many times you want the password is reencrypted. Default is 10.
|
9
|
+
# config.stretches = 10
|
10
|
+
|
11
|
+
# Define which will be the encryption algorithm. Supported algorithms are :sha1
|
12
|
+
# (default) and :sha512. Devise also supports encryptors from others authentication
|
13
|
+
# frameworks as :clearance_sha1, :authlogic_sha512 (then you should set stretches
|
14
|
+
# above to 20 for default behavior) and :restful_authentication_sha1 (then you
|
15
|
+
# should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
|
16
|
+
# config.encryptor = :sha1
|
17
|
+
|
18
|
+
# Configure which keys are used when authenticating an user. By default is
|
19
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
20
|
+
# authenticating an user, both parameters are required. Remember that those
|
21
|
+
# parameters are used only when authenticating and not when retrieving from
|
22
|
+
# session. If you need permissions, you should implement that in a before filter.
|
23
|
+
# config.authentication_keys = [ :email ]
|
24
|
+
|
25
|
+
# The time you want give to your user to confirm his account. During this time
|
26
|
+
# he will be able to access your application without confirming. Default is nil.
|
27
|
+
# config.confirm_within = 2.days
|
28
|
+
|
29
|
+
# The time the user will be remembered without asking for credentials again.
|
30
|
+
# config.remember_for = 2.weeks
|
31
|
+
|
32
|
+
# The time you want to timeout the user session without activity. After this
|
33
|
+
# time the user will be asked for credentials again.
|
34
|
+
# config.timeout_in = 10.minutes
|
35
|
+
|
36
|
+
# Configure the e-mail address which will be shown in DeviseMailer.
|
37
|
+
config.mailer_sender = "please-change-me-omg@yourapp.com"
|
38
|
+
|
39
|
+
# Configure the content type of DeviseMailer mails (defaults to text/html")
|
40
|
+
# config.mailer_content_type = "text/plain"
|
41
|
+
|
42
|
+
# Load and configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
|
43
|
+
require "devise/orm/#{DEVISE_ORM}"
|
44
|
+
config.orm = DEVISE_ORM
|
45
|
+
|
46
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
47
|
+
# "sessions/users/new". It's turned off by default because it's slower if you
|
48
|
+
# are using only default views.
|
49
|
+
# config.scoped_views = true
|
50
|
+
|
51
|
+
# Number of authentication tries before locking an account.
|
52
|
+
# config.maximum_attempts = 20
|
53
|
+
|
54
|
+
# Defines which strategy will be used to unlock an account.
|
55
|
+
# :email = Sends an unlock link to the user email
|
56
|
+
# :time = Reanables login after a certain ammount of time (see :unlock_in below)
|
57
|
+
# :both = enables both strategies
|
58
|
+
# config.unlock_strategy = :both
|
59
|
+
|
60
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
61
|
+
# config.unlock_in = 1.hour
|
62
|
+
|
63
|
+
# If you want to use other strategies, that are not (yet) supported by Devise,
|
64
|
+
# you can configure them inside the config.warden block. The example below
|
65
|
+
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
66
|
+
#
|
67
|
+
# config.warden do |manager|
|
68
|
+
# manager.oauth(:twitter) do |twitter|
|
69
|
+
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
|
70
|
+
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
71
|
+
# twitter.options :site => 'http://twitter.com'
|
72
|
+
# end
|
73
|
+
# manager.default_strategies.unshift :twitter_oauth
|
74
|
+
# end
|
75
|
+
|
76
|
+
# Configure default_url_options if you are using dynamic segments in :path_prefix
|
77
|
+
# for devise_for.
|
78
|
+
#
|
79
|
+
# config.default_url_options do
|
80
|
+
# { :locale => I18n.locale }
|
81
|
+
# end
|
82
|
+
end
|
data/test/rails_app/vendor/plugins/devise/test/rails_app/config/initializers/new_rails_defaults.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# These settings change the behavior of Rails 2 apps and will be defaults
|
4
|
+
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
5
|
+
|
6
|
+
if defined?(ActiveRecord)
|
7
|
+
# Include Active Record class name as root for JSON serialized output.
|
8
|
+
ActiveRecord::Base.include_root_in_json = true
|
9
|
+
|
10
|
+
# Store the full class name (including module namespace) in STI type column.
|
11
|
+
ActiveRecord::Base.store_full_sti_class = true
|
12
|
+
end
|
13
|
+
|
14
|
+
ActionController::Routing.generate_best_match = false
|
15
|
+
|
16
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
17
|
+
ActiveSupport.use_standard_json_time_format = true
|
18
|
+
|
19
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
20
|
+
# if you're including raw json in an HTML page.
|
21
|
+
ActiveSupport.escape_html_entities_in_json = false
|
22
|
+
|
23
|
+
# Clean up silencers
|
24
|
+
Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying cookie session data integrity.
|
4
|
+
# If you change this key, all old sessions 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
|
+
ActionController::Base.session = {
|
8
|
+
:key => '_rails_app_session',
|
9
|
+
:secret => '89e8147901a0d7c221ac130e0ded3eeab6dab4a97127255909f08fedaae371918b41dec9d4d75c5b27a55c3772d43c2b6a3cbac232c5cc2ce4b8ec22242f5e60'
|
10
|
+
}
|
11
|
+
|
12
|
+
# Use the database for sessions instead of the cookie-based default,
|
13
|
+
# which shouldn't be used to store highly confidential information
|
14
|
+
# (create the session table with "rake db:sessions:create")
|
15
|
+
# ActionController::Base.session_store = :active_record_store
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
map.devise_for :users
|
3
|
+
map.devise_for :admin, :as => 'admin_area'
|
4
|
+
map.devise_for :accounts, :scope => 'manager', :path_prefix => ':locale',
|
5
|
+
:class_name => "User", :requirements => { :extra => 'value' }, :path_names => {
|
6
|
+
:sign_in => 'login', :sign_out => 'logout',
|
7
|
+
:password => 'secret', :confirmation => 'verification',
|
8
|
+
:unlock => 'unblock', :sign_up => 'register'
|
9
|
+
}
|
10
|
+
|
11
|
+
map.resources :users, :only => [:index], :member => { :expire => :get }
|
12
|
+
map.resources :admins, :only => :index
|
13
|
+
map.root :controller => :home
|
14
|
+
|
15
|
+
map.devise_for :sign_out_via_deletes, :sign_out_via => :delete, :class_name => "User"
|
16
|
+
map.devise_for :sign_out_via_posts, :sign_out_via => :post, :class_name => "User"
|
17
|
+
map.devise_for :sign_out_via_anymethods, :sign_out_via => :any, :class_name => "User"
|
18
|
+
|
19
|
+
map.connect '/admin_area/password/new', :controller => "passwords", :action => "new"
|
20
|
+
map.admin_root '/admin_area/home', :controller => "admins", :action => "index"
|
21
|
+
|
22
|
+
map.connect '/sign_in', :controller => "sessions", :action => "new"
|
23
|
+
map.connect ':controller/:action/:id'
|
24
|
+
map.connect ':controller/:action/:id.:format'
|
25
|
+
end
|