devise 3.5.10 → 4.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +265 -1129
- data/MIT-LICENSE +2 -1
- data/README.md +291 -96
- data/app/controllers/devise/confirmations_controller.rb +3 -1
- data/app/controllers/devise/omniauth_callbacks_controller.rb +8 -6
- data/app/controllers/devise/passwords_controller.rb +7 -4
- data/app/controllers/devise/registrations_controller.rb +39 -18
- data/app/controllers/devise/sessions_controller.rb +9 -7
- data/app/controllers/devise/unlocks_controller.rb +4 -2
- data/app/controllers/devise_controller.rb +25 -12
- data/app/helpers/devise_helper.rb +23 -18
- data/app/mailers/devise/mailer.rb +10 -4
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/mailer/email_changed.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +9 -5
- data/app/views/devise/registrations/new.html.erb +4 -4
- data/app/views/devise/sessions/new.html.erb +4 -4
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/_links.html.erb +7 -7
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +5 -2
- data/lib/devise/controllers/helpers.rb +30 -27
- data/lib/devise/controllers/rememberable.rb +3 -1
- data/lib/devise/controllers/scoped_views.rb +2 -0
- data/lib/devise/controllers/sign_in_out.rb +37 -14
- data/lib/devise/controllers/store_location.rb +25 -7
- data/lib/devise/controllers/url_helpers.rb +3 -1
- data/lib/devise/delegator.rb +2 -0
- data/lib/devise/encryptor.rb +6 -4
- data/lib/devise/failure_app.rb +75 -38
- data/lib/devise/hooks/activatable.rb +2 -0
- data/lib/devise/hooks/csrf_cleaner.rb +2 -0
- data/lib/devise/hooks/forgetable.rb +2 -0
- data/lib/devise/hooks/lockable.rb +6 -1
- data/lib/devise/hooks/proxy.rb +3 -1
- data/lib/devise/hooks/rememberable.rb +2 -0
- data/lib/devise/hooks/timeoutable.rb +4 -2
- data/lib/devise/hooks/trackable.rb +2 -0
- data/lib/devise/mailers/helpers.rb +7 -4
- data/lib/devise/mapping.rb +3 -1
- data/lib/devise/models/authenticatable.rb +57 -31
- data/lib/devise/models/confirmable.rb +90 -29
- data/lib/devise/models/database_authenticatable.rb +93 -22
- data/lib/devise/models/lockable.rb +11 -5
- data/lib/devise/models/omniauthable.rb +2 -0
- data/lib/devise/models/recoverable.rb +33 -21
- data/lib/devise/models/registerable.rb +4 -0
- data/lib/devise/models/rememberable.rb +6 -11
- data/lib/devise/models/timeoutable.rb +2 -0
- data/lib/devise/models/trackable.rb +15 -1
- data/lib/devise/models/validatable.rb +10 -3
- data/lib/devise/models.rb +3 -1
- data/lib/devise/modules.rb +2 -0
- data/lib/devise/omniauth/config.rb +2 -0
- data/lib/devise/omniauth/url_helpers.rb +14 -5
- data/lib/devise/omniauth.rb +2 -0
- data/lib/devise/orm/active_record.rb +5 -1
- data/lib/devise/orm/mongoid.rb +6 -2
- data/lib/devise/parameter_filter.rb +4 -0
- data/lib/devise/parameter_sanitizer.rb +139 -65
- data/lib/devise/rails/routes.rb +48 -37
- data/lib/devise/rails/warden_compat.rb +3 -10
- data/lib/devise/rails.rb +7 -16
- data/lib/devise/secret_key_finder.rb +27 -0
- data/lib/devise/strategies/authenticatable.rb +3 -1
- data/lib/devise/strategies/base.rb +2 -0
- data/lib/devise/strategies/database_authenticatable.rb +11 -4
- data/lib/devise/strategies/rememberable.rb +2 -0
- data/lib/devise/test/controller_helpers.rb +167 -0
- data/lib/devise/test/integration_helpers.rb +63 -0
- data/lib/devise/test_helpers.rb +7 -124
- data/lib/devise/time_inflector.rb +2 -0
- data/lib/devise/token_generator.rb +3 -41
- data/lib/devise/version.rb +3 -1
- data/lib/devise.rb +57 -40
- data/lib/generators/active_record/devise_generator.rb +29 -10
- data/lib/generators/active_record/templates/migration.rb +4 -2
- data/lib/generators/active_record/templates/migration_existing.rb +4 -2
- data/lib/generators/devise/controllers_generator.rb +3 -1
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +18 -5
- data/lib/generators/devise/orm_helpers.rb +10 -21
- data/lib/generators/devise/views_generator.rb +8 -9
- data/lib/generators/mongoid/devise_generator.rb +7 -5
- data/lib/generators/templates/README +9 -8
- data/lib/generators/templates/controllers/confirmations_controller.rb +2 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +3 -1
- data/lib/generators/templates/controllers/passwords_controller.rb +2 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +6 -4
- data/lib/generators/templates/controllers/sessions_controller.rb +4 -2
- data/lib/generators/templates/controllers/unlocks_controller.rb +2 -0
- data/lib/generators/templates/devise.rb +63 -21
- data/lib/generators/templates/markerb/email_changed.markerb +7 -0
- data/lib/generators/templates/markerb/password_change.markerb +2 -2
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +5 -1
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +10 -2
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +4 -1
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +11 -3
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +11 -3
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +7 -2
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +4 -1
- metadata +15 -314
- data/.gitignore +0 -10
- data/.travis.yml +0 -44
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -22
- data/CONTRIBUTING.md +0 -16
- data/Gemfile +0 -30
- data/Gemfile.lock +0 -187
- data/Rakefile +0 -36
- data/devise.gemspec +0 -27
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2-stable +0 -29
- data/gemfiles/Gemfile.rails-3.2-stable.lock +0 -172
- data/gemfiles/Gemfile.rails-4.0-stable +0 -30
- data/gemfiles/Gemfile.rails-4.0-stable.lock +0 -166
- data/gemfiles/Gemfile.rails-4.1-stable +0 -30
- data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
- data/gemfiles/Gemfile.rails-4.2-stable +0 -30
- data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -193
- data/script/cached-bundle +0 -49
- data/script/s3-put +0 -71
- data/test/controllers/custom_registrations_controller_test.rb +0 -40
- data/test/controllers/custom_strategy_test.rb +0 -62
- data/test/controllers/helper_methods_test.rb +0 -21
- data/test/controllers/helpers_test.rb +0 -316
- data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -51
- data/test/controllers/internal_helpers_test.rb +0 -129
- data/test/controllers/load_hooks_controller_test.rb +0 -19
- data/test/controllers/passwords_controller_test.rb +0 -31
- data/test/controllers/sessions_controller_test.rb +0 -103
- data/test/controllers/url_helpers_test.rb +0 -65
- data/test/delegator_test.rb +0 -19
- data/test/devise_test.rb +0 -107
- data/test/failure_app_test.rb +0 -315
- data/test/generators/active_record_generator_test.rb +0 -109
- data/test/generators/controllers_generator_test.rb +0 -48
- data/test/generators/devise_generator_test.rb +0 -39
- data/test/generators/install_generator_test.rb +0 -13
- data/test/generators/mongoid_generator_test.rb +0 -23
- data/test/generators/views_generator_test.rb +0 -103
- data/test/helpers/devise_helper_test.rb +0 -49
- data/test/integration/authenticatable_test.rb +0 -729
- data/test/integration/confirmable_test.rb +0 -324
- data/test/integration/database_authenticatable_test.rb +0 -95
- data/test/integration/http_authenticatable_test.rb +0 -105
- data/test/integration/lockable_test.rb +0 -239
- data/test/integration/omniauthable_test.rb +0 -135
- data/test/integration/recoverable_test.rb +0 -347
- data/test/integration/registerable_test.rb +0 -359
- data/test/integration/rememberable_test.rb +0 -214
- data/test/integration/timeoutable_test.rb +0 -184
- data/test/integration/trackable_test.rb +0 -92
- data/test/mailers/confirmation_instructions_test.rb +0 -115
- data/test/mailers/reset_password_instructions_test.rb +0 -96
- data/test/mailers/unlock_instructions_test.rb +0 -91
- data/test/mapping_test.rb +0 -134
- data/test/models/authenticatable_test.rb +0 -23
- data/test/models/confirmable_test.rb +0 -511
- data/test/models/database_authenticatable_test.rb +0 -269
- data/test/models/lockable_test.rb +0 -350
- data/test/models/omniauthable_test.rb +0 -7
- data/test/models/recoverable_test.rb +0 -251
- data/test/models/registerable_test.rb +0 -7
- data/test/models/rememberable_test.rb +0 -169
- data/test/models/serializable_test.rb +0 -49
- data/test/models/timeoutable_test.rb +0 -51
- data/test/models/trackable_test.rb +0 -41
- data/test/models/validatable_test.rb +0 -127
- data/test/models_test.rb +0 -153
- data/test/omniauth/config_test.rb +0 -57
- data/test/omniauth/url_helpers_test.rb +0 -54
- data/test/orm/active_record.rb +0 -10
- data/test/orm/mongoid.rb +0 -13
- data/test/parameter_sanitizer_test.rb +0 -81
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -6
- data/test/rails_app/app/active_record/shim.rb +0 -2
- data/test/rails_app/app/active_record/user.rb +0 -6
- data/test/rails_app/app/active_record/user_on_engine.rb +0 -7
- data/test/rails_app/app/active_record/user_on_main_app.rb +0 -7
- data/test/rails_app/app/active_record/user_without_email.rb +0 -8
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -6
- data/test/rails_app/app/controllers/admins_controller.rb +0 -6
- data/test/rails_app/app/controllers/application_controller.rb +0 -12
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -30
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -31
- data/test/rails_app/app/controllers/home_controller.rb +0 -25
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -2
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -2
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -14
- data/test/rails_app/app/controllers/users_controller.rb +0 -31
- data/test/rails_app/app/helpers/application_helper.rb +0 -3
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -3
- data/test/rails_app/app/mailers/users/mailer.rb +0 -3
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -4
- data/test/rails_app/app/mongoid/admin.rb +0 -29
- data/test/rails_app/app/mongoid/shim.rb +0 -23
- data/test/rails_app/app/mongoid/user.rb +0 -39
- data/test/rails_app/app/mongoid/user_on_engine.rb +0 -39
- data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -39
- data/test/rails_app/app/mongoid/user_without_email.rb +0 -33
- data/test/rails_app/app/views/admins/index.html.erb +0 -1
- data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/home/index.html.erb +0 -1
- data/test/rails_app/app/views/home/join.html.erb +0 -1
- data/test/rails_app/app/views/home/private.html.erb +0 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/layouts/application.html.erb +0 -24
- data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
- data/test/rails_app/app/views/users/index.html.erb +0 -1
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
- data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -4
- data/test/rails_app/bin/rake +0 -4
- data/test/rails_app/config/application.rb +0 -40
- data/test/rails_app/config/boot.rb +0 -14
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -5
- data/test/rails_app/config/environments/development.rb +0 -30
- data/test/rails_app/config/environments/production.rb +0 -84
- data/test/rails_app/config/environments/test.rb +0 -41
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails_app/config/initializers/devise.rb +0 -180
- data/test/rails_app/config/initializers/inflections.rb +0 -2
- data/test/rails_app/config/initializers/secret_token.rb +0 -8
- data/test/rails_app/config/initializers/session_store.rb +0 -1
- data/test/rails_app/config/routes.rb +0 -125
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -71
- data/test/rails_app/db/schema.rb +0 -55
- data/test/rails_app/lib/shared_admin.rb +0 -17
- data/test/rails_app/lib/shared_user.rb +0 -29
- data/test/rails_app/lib/shared_user_without_email.rb +0 -26
- data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -13
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_test.rb +0 -9
- data/test/routes_test.rb +0 -264
- data/test/support/action_controller/record_identifier.rb +0 -10
- data/test/support/assertions.rb +0 -39
- data/test/support/helpers.rb +0 -77
- data/test/support/integration.rb +0 -92
- data/test/support/locale/en.yml +0 -8
- data/test/support/mongoid.yml +0 -6
- data/test/support/webrat/integrations/rails.rb +0 -24
- data/test/test_helper.rb +0 -34
- data/test/test_helpers_test.rb +0 -178
- data/test/test_models.rb +0 -33
- data/test/time_helpers.rb +0 -137
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RoutesTest < ActionController::TestCase
|
4
|
-
tests ApplicationController
|
5
|
-
|
6
|
-
def assert_path_and_url(name, prepend_path=nil)
|
7
|
-
@request.path = '/users/session'
|
8
|
-
prepend_path = "#{prepend_path}_" if prepend_path
|
9
|
-
|
10
|
-
# Resource param
|
11
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user),
|
12
|
-
send(:"#{prepend_path}user_#{name}_path")
|
13
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
|
14
|
-
send(:"#{prepend_path}user_#{name}_url")
|
15
|
-
|
16
|
-
# With string
|
17
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_path", "user"),
|
18
|
-
send(:"#{prepend_path}user_#{name}_path")
|
19
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_url", "user"),
|
20
|
-
send(:"#{prepend_path}user_#{name}_url")
|
21
|
-
|
22
|
-
# Default url params
|
23
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, param: 123),
|
24
|
-
send(:"#{prepend_path}user_#{name}_path", param: 123)
|
25
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user, param: 123),
|
26
|
-
send(:"#{prepend_path}user_#{name}_url", param: 123)
|
27
|
-
|
28
|
-
@request.path = nil
|
29
|
-
# With an object
|
30
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_path", User.new),
|
31
|
-
send(:"#{prepend_path}user_#{name}_path")
|
32
|
-
assert_equal @controller.send(:"#{prepend_path}#{name}_url", User.new),
|
33
|
-
send(:"#{prepend_path}user_#{name}_url")
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
test 'should alias session to mapped user session' do
|
38
|
-
assert_path_and_url :session
|
39
|
-
assert_path_and_url :session, :new
|
40
|
-
assert_path_and_url :session, :destroy
|
41
|
-
end
|
42
|
-
|
43
|
-
test 'should alias password to mapped user password' do
|
44
|
-
assert_path_and_url :password
|
45
|
-
assert_path_and_url :password, :new
|
46
|
-
assert_path_and_url :password, :edit
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'should alias confirmation to mapped user confirmation' do
|
50
|
-
assert_path_and_url :confirmation
|
51
|
-
assert_path_and_url :confirmation, :new
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'should alias unlock to mapped user unlock' do
|
55
|
-
assert_path_and_url :unlock
|
56
|
-
assert_path_and_url :unlock, :new
|
57
|
-
end
|
58
|
-
|
59
|
-
test 'should alias registration to mapped user registration' do
|
60
|
-
assert_path_and_url :registration
|
61
|
-
assert_path_and_url :registration, :new
|
62
|
-
assert_path_and_url :registration, :edit
|
63
|
-
assert_path_and_url :registration, :cancel
|
64
|
-
end
|
65
|
-
end
|
data/test/delegator_test.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DelegatorTest < ActiveSupport::TestCase
|
4
|
-
def delegator
|
5
|
-
Devise::Delegator.new
|
6
|
-
end
|
7
|
-
|
8
|
-
test 'failure_app returns default failure app if no warden options in env' do
|
9
|
-
assert_equal Devise::FailureApp, delegator.failure_app({})
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'failure_app returns default failure app if no scope in warden options' do
|
13
|
-
assert_equal Devise::FailureApp, delegator.failure_app({"warden.options" => {}})
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'failure_app returns associated failure app by scope in the given environment' do
|
17
|
-
assert_kind_of Proc, delegator.failure_app({"warden.options" => {scope: "manager"}})
|
18
|
-
end
|
19
|
-
end
|
data/test/devise_test.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Devise
|
4
|
-
def self.yield_and_restore
|
5
|
-
@@warden_configured = nil
|
6
|
-
c, b = @@warden_config, @@warden_config_blocks
|
7
|
-
yield
|
8
|
-
ensure
|
9
|
-
@@warden_config, @@warden_config_blocks = c, b
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class DeviseTest < ActiveSupport::TestCase
|
14
|
-
test 'bcrypt on the class' do
|
15
|
-
password = "super secret"
|
16
|
-
klass = Struct.new(:pepper, :stretches).new("blahblah", 2)
|
17
|
-
hash = Devise::Encryptor.digest(klass, password)
|
18
|
-
assert_equal ::BCrypt::Password.create(hash), hash
|
19
|
-
|
20
|
-
klass = Struct.new(:pepper, :stretches).new("bla", 2)
|
21
|
-
hash = Devise::Encryptor.digest(klass, password)
|
22
|
-
assert_not_equal ::BCrypt::Password.new(hash), hash
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'model options can be configured through Devise' do
|
26
|
-
swap Devise, allow_unconfirmed_access_for: 113, pepper: "foo" do
|
27
|
-
assert_equal 113, Devise.allow_unconfirmed_access_for
|
28
|
-
assert_equal "foo", Devise.pepper
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'setup block yields self' do
|
33
|
-
Devise.setup do |config|
|
34
|
-
assert_equal Devise, config
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
test 'stores warden configuration' do
|
39
|
-
assert_kind_of Devise::Delegator, Devise.warden_config.failure_app
|
40
|
-
assert_equal :user, Devise.warden_config.default_scope
|
41
|
-
end
|
42
|
-
|
43
|
-
test 'warden manager user configuration through a block' do
|
44
|
-
Devise.yield_and_restore do
|
45
|
-
executed = false
|
46
|
-
Devise.warden do |config|
|
47
|
-
executed = true
|
48
|
-
assert_kind_of Warden::Config, config
|
49
|
-
end
|
50
|
-
|
51
|
-
Devise.configure_warden!
|
52
|
-
assert executed
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
test 'warden manager user configuration through multiple blocks' do
|
57
|
-
Devise.yield_and_restore do
|
58
|
-
executed = 0
|
59
|
-
|
60
|
-
3.times do
|
61
|
-
Devise.warden { |config| executed += 1 }
|
62
|
-
end
|
63
|
-
|
64
|
-
Devise.configure_warden!
|
65
|
-
assert_equal 3, executed
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
test 'add new module using the helper method' do
|
70
|
-
assert_nothing_raised(Exception) { Devise.add_module(:coconut) }
|
71
|
-
assert_equal 1, Devise::ALL.select { |v| v == :coconut }.size
|
72
|
-
assert_not Devise::STRATEGIES.include?(:coconut)
|
73
|
-
assert_not defined?(Devise::Models::Coconut)
|
74
|
-
Devise::ALL.delete(:coconut)
|
75
|
-
|
76
|
-
assert_nothing_raised(Exception) { Devise.add_module(:banana, strategy: :fruits) }
|
77
|
-
assert_equal :fruits, Devise::STRATEGIES[:banana]
|
78
|
-
Devise::ALL.delete(:banana)
|
79
|
-
Devise::STRATEGIES.delete(:banana)
|
80
|
-
|
81
|
-
assert_nothing_raised(Exception) { Devise.add_module(:kivi, controller: :fruits) }
|
82
|
-
assert_equal :fruits, Devise::CONTROLLERS[:kivi]
|
83
|
-
Devise::ALL.delete(:kivi)
|
84
|
-
Devise::CONTROLLERS.delete(:kivi)
|
85
|
-
end
|
86
|
-
|
87
|
-
test 'should complain when comparing empty or different sized passes' do
|
88
|
-
[nil, ""].each do |empty|
|
89
|
-
assert_not Devise.secure_compare(empty, "something")
|
90
|
-
assert_not Devise.secure_compare("something", empty)
|
91
|
-
assert_not Devise.secure_compare(empty, empty)
|
92
|
-
end
|
93
|
-
assert_not Devise.secure_compare("size_1", "size_four")
|
94
|
-
end
|
95
|
-
|
96
|
-
test 'Devise.email_regexp should match valid email addresses' do
|
97
|
-
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
|
98
|
-
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com", "test_user@example.com."]
|
99
|
-
|
100
|
-
valid_emails.each do |email|
|
101
|
-
assert_match Devise.email_regexp, email
|
102
|
-
end
|
103
|
-
non_valid_emails.each do |email|
|
104
|
-
assert_no_match Devise.email_regexp, email
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
data/test/failure_app_test.rb
DELETED
@@ -1,315 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class FailureTest < ActiveSupport::TestCase
|
5
|
-
class RootFailureApp < Devise::FailureApp
|
6
|
-
def fake_app
|
7
|
-
Object.new
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class FailureWithSubdomain < RootFailureApp
|
12
|
-
routes = ActionDispatch::Routing::RouteSet.new
|
13
|
-
|
14
|
-
routes.draw do
|
15
|
-
scope subdomain: 'sub' do
|
16
|
-
root to: 'foo#bar'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
include routes.url_helpers
|
21
|
-
end
|
22
|
-
|
23
|
-
class FailureWithI18nOptions < Devise::FailureApp
|
24
|
-
def i18n_options(options)
|
25
|
-
options.merge(name: 'Steve')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class FakeEngineApp < Devise::FailureApp
|
30
|
-
class FakeEngine
|
31
|
-
def new_user_on_engine_session_url _
|
32
|
-
'/user_on_engines/sign_in'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def main_app
|
37
|
-
raise 'main_app router called instead of fake_engine'
|
38
|
-
end
|
39
|
-
|
40
|
-
def fake_engine
|
41
|
-
@fake_engine ||= FakeEngine.new
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.context(name, &block)
|
46
|
-
instance_eval(&block)
|
47
|
-
end
|
48
|
-
|
49
|
-
def call_failure(env_params={})
|
50
|
-
env = {
|
51
|
-
'REQUEST_URI' => 'http://test.host/',
|
52
|
-
'HTTP_HOST' => 'test.host',
|
53
|
-
'REQUEST_METHOD' => 'GET',
|
54
|
-
'warden.options' => { scope: :user },
|
55
|
-
'rack.session' => {},
|
56
|
-
'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime::HTML),
|
57
|
-
'rack.input' => "",
|
58
|
-
'warden' => OpenStruct.new(message: nil)
|
59
|
-
}.merge!(env_params)
|
60
|
-
|
61
|
-
@response = (env.delete(:app) || Devise::FailureApp).call(env).to_a
|
62
|
-
@request = ActionDispatch::Request.new(env)
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'When redirecting' do
|
66
|
-
test 'returns to the default redirect location' do
|
67
|
-
call_failure
|
68
|
-
assert_equal 302, @response.first
|
69
|
-
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
70
|
-
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
71
|
-
end
|
72
|
-
|
73
|
-
test 'returns to the default redirect location considering subdomain' do
|
74
|
-
call_failure('warden.options' => { scope: :subdomain_user })
|
75
|
-
assert_equal 302, @response.first
|
76
|
-
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
77
|
-
assert_equal 'http://sub.test.host/subdomain_users/sign_in', @response.second['Location']
|
78
|
-
end
|
79
|
-
|
80
|
-
test 'returns to the default redirect location for wildcard requests' do
|
81
|
-
call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
|
82
|
-
assert_equal 302, @response.first
|
83
|
-
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
84
|
-
end
|
85
|
-
|
86
|
-
test 'returns to the root path if no session path is available' do
|
87
|
-
swap Devise, router_name: :fake_app do
|
88
|
-
call_failure app: RootFailureApp
|
89
|
-
assert_equal 302, @response.first
|
90
|
-
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
91
|
-
assert_equal 'http://test.host/', @response.second['Location']
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
test 'returns to the root path considering subdomain if no session path is available' do
|
96
|
-
swap Devise, router_name: :fake_app do
|
97
|
-
call_failure app: FailureWithSubdomain
|
98
|
-
assert_equal 302, @response.first
|
99
|
-
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
100
|
-
assert_equal 'http://sub.test.host/', @response.second['Location']
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
test 'returns to the default redirect location considering the router for supplied scope' do
|
105
|
-
call_failure app: FakeEngineApp, 'warden.options' => { scope: :user_on_engine }
|
106
|
-
assert_equal 302, @response.first
|
107
|
-
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
108
|
-
assert_equal 'http://test.host/user_on_engines/sign_in', @response.second['Location']
|
109
|
-
end
|
110
|
-
|
111
|
-
if Rails.application.config.respond_to?(:relative_url_root)
|
112
|
-
test 'returns to the default redirect location considering the relative url root' do
|
113
|
-
swap Rails.application.config, relative_url_root: "/sample" do
|
114
|
-
call_failure
|
115
|
-
assert_equal 302, @response.first
|
116
|
-
assert_equal 'http://test.host/sample/users/sign_in', @response.second['Location']
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
test 'returns to the default redirect location considering the relative url root and subdomain' do
|
121
|
-
swap Rails.application.config, relative_url_root: "/sample" do
|
122
|
-
call_failure('warden.options' => { scope: :subdomain_user })
|
123
|
-
assert_equal 302, @response.first
|
124
|
-
assert_equal 'http://sub.test.host/sample/subdomain_users/sign_in', @response.second['Location']
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
test 'uses the proxy failure message as symbol' do
|
130
|
-
call_failure('warden' => OpenStruct.new(message: :invalid))
|
131
|
-
assert_equal 'Invalid email or password.', @request.flash[:alert]
|
132
|
-
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
133
|
-
end
|
134
|
-
|
135
|
-
test 'supports authentication_keys as a Hash for the flash message' do
|
136
|
-
swap Devise, authentication_keys: { email: true, login: true } do
|
137
|
-
call_failure('warden' => OpenStruct.new(message: :invalid))
|
138
|
-
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
test 'uses custom i18n options' do
|
143
|
-
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
|
144
|
-
assert_equal 'User Steve does not exist', @request.flash[:alert]
|
145
|
-
end
|
146
|
-
|
147
|
-
test 'uses the proxy failure message as string' do
|
148
|
-
call_failure('warden' => OpenStruct.new(message: 'Hello world'))
|
149
|
-
assert_equal 'Hello world', @request.flash[:alert]
|
150
|
-
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
151
|
-
end
|
152
|
-
|
153
|
-
test 'set content type to default text/html' do
|
154
|
-
call_failure
|
155
|
-
assert_equal 'text/html; charset=utf-8', @response.second['Content-Type']
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'setup a default message' do
|
159
|
-
call_failure
|
160
|
-
assert_match(/You are being/, @response.last.body)
|
161
|
-
assert_match(/redirected/, @response.last.body)
|
162
|
-
assert_match(/users\/sign_in/, @response.last.body)
|
163
|
-
end
|
164
|
-
|
165
|
-
test 'works for any navigational format' do
|
166
|
-
swap Devise, navigational_formats: [:xml] do
|
167
|
-
call_failure('formats' => Mime::XML)
|
168
|
-
assert_equal 302, @response.first
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
test 'redirects the correct format if it is a non-html format request' do
|
173
|
-
swap Devise, navigational_formats: [:js] do
|
174
|
-
call_failure('formats' => Mime::JS)
|
175
|
-
assert_equal 'http://test.host/users/sign_in.js', @response.second["Location"]
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'For HTTP request' do
|
181
|
-
test 'return 401 status' do
|
182
|
-
call_failure('formats' => Mime::XML)
|
183
|
-
assert_equal 401, @response.first
|
184
|
-
end
|
185
|
-
|
186
|
-
test 'return appropriate body for xml' do
|
187
|
-
call_failure('formats' => Mime::XML)
|
188
|
-
result = %(<?xml version="1.0" encoding="UTF-8"?>\n<errors>\n <error>You need to sign in or sign up before continuing.</error>\n</errors>\n)
|
189
|
-
assert_equal result, @response.last.body
|
190
|
-
end
|
191
|
-
|
192
|
-
test 'return appropriate body for json' do
|
193
|
-
call_failure('formats' => Mime::JSON)
|
194
|
-
result = %({"error":"You need to sign in or sign up before continuing."})
|
195
|
-
assert_equal result, @response.last.body
|
196
|
-
end
|
197
|
-
|
198
|
-
test 'return 401 status for unknown formats' do
|
199
|
-
call_failure 'formats' => []
|
200
|
-
assert_equal 401, @response.first
|
201
|
-
end
|
202
|
-
|
203
|
-
test 'return WWW-authenticate headers if model allows' do
|
204
|
-
call_failure('formats' => Mime::XML)
|
205
|
-
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
206
|
-
end
|
207
|
-
|
208
|
-
test 'does not return WWW-authenticate headers if model does not allow' do
|
209
|
-
swap Devise, http_authenticatable: false do
|
210
|
-
call_failure('formats' => Mime::XML)
|
211
|
-
assert_nil @response.second["WWW-Authenticate"]
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
test 'works for any non navigational format' do
|
216
|
-
swap Devise, navigational_formats: [] do
|
217
|
-
call_failure('formats' => Mime::HTML)
|
218
|
-
assert_equal 401, @response.first
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
test 'uses the failure message as response body' do
|
223
|
-
call_failure('formats' => Mime::XML, 'warden' => OpenStruct.new(message: :invalid))
|
224
|
-
assert_match '<error>Invalid email or password.</error>', @response.third.body
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'on ajax call' do
|
228
|
-
context 'when http_authenticatable_on_xhr is false' do
|
229
|
-
test 'dont return 401 with navigational formats' do
|
230
|
-
swap Devise, http_authenticatable_on_xhr: false do
|
231
|
-
call_failure('formats' => Mime::HTML, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
232
|
-
assert_equal 302, @response.first
|
233
|
-
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
test 'dont return 401 with non navigational formats' do
|
238
|
-
swap Devise, http_authenticatable_on_xhr: false do
|
239
|
-
call_failure('formats' => Mime::JSON, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
240
|
-
assert_equal 302, @response.first
|
241
|
-
assert_equal 'http://test.host/users/sign_in.json', @response.second["Location"]
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
context 'when http_authenticatable_on_xhr is true' do
|
247
|
-
test 'return 401' do
|
248
|
-
swap Devise, http_authenticatable_on_xhr: true do
|
249
|
-
call_failure('formats' => Mime::HTML, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
250
|
-
assert_equal 401, @response.first
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
test 'skip WWW-Authenticate header' do
|
255
|
-
swap Devise, http_authenticatable_on_xhr: true do
|
256
|
-
call_failure('formats' => Mime::HTML, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
257
|
-
assert_nil @response.second['WWW-Authenticate']
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
context 'With recall' do
|
265
|
-
test 'calls the original controller if invalid email or password' do
|
266
|
-
env = {
|
267
|
-
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
|
268
|
-
"devise.mapping" => Devise.mappings[:user],
|
269
|
-
"warden" => stub_everything
|
270
|
-
}
|
271
|
-
call_failure(env)
|
272
|
-
assert @response.third.body.include?('<h2>Log in</h2>')
|
273
|
-
assert @response.third.body.include?('Invalid email or password.')
|
274
|
-
end
|
275
|
-
|
276
|
-
test 'calls the original controller if not confirmed email' do
|
277
|
-
env = {
|
278
|
-
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in", message: :unconfirmed },
|
279
|
-
"devise.mapping" => Devise.mappings[:user],
|
280
|
-
"warden" => stub_everything
|
281
|
-
}
|
282
|
-
call_failure(env)
|
283
|
-
assert @response.third.body.include?('<h2>Log in</h2>')
|
284
|
-
assert @response.third.body.include?('You have to confirm your email address before continuing.')
|
285
|
-
end
|
286
|
-
|
287
|
-
test 'calls the original controller if inactive account' do
|
288
|
-
env = {
|
289
|
-
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in", message: :inactive },
|
290
|
-
"devise.mapping" => Devise.mappings[:user],
|
291
|
-
"warden" => stub_everything
|
292
|
-
}
|
293
|
-
call_failure(env)
|
294
|
-
assert @response.third.body.include?('<h2>Log in</h2>')
|
295
|
-
assert @response.third.body.include?('Your account is not activated yet.')
|
296
|
-
end
|
297
|
-
|
298
|
-
if Rails.application.config.respond_to?(:relative_url_root)
|
299
|
-
test 'calls the original controller with the proper environment considering the relative url root' do
|
300
|
-
swap Rails.application.config, relative_url_root: "/sample" do
|
301
|
-
env = {
|
302
|
-
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/sample/users/sign_in"},
|
303
|
-
"devise.mapping" => Devise.mappings[:user],
|
304
|
-
"warden" => stub_everything
|
305
|
-
}
|
306
|
-
call_failure(env)
|
307
|
-
assert @response.third.body.include?('<h2>Log in</h2>')
|
308
|
-
assert @response.third.body.include?('Invalid email or password.')
|
309
|
-
assert_equal @request.env["SCRIPT_NAME"], '/sample'
|
310
|
-
assert_equal @request.env["PATH_INFO"], '/users/sign_in'
|
311
|
-
end
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
if DEVISE_ORM == :active_record
|
4
|
-
require "generators/active_record/devise_generator"
|
5
|
-
|
6
|
-
class ActiveRecordGeneratorTest < Rails::Generators::TestCase
|
7
|
-
tests ActiveRecord::Generators::DeviseGenerator
|
8
|
-
destination File.expand_path("../../tmp", __FILE__)
|
9
|
-
setup :prepare_destination
|
10
|
-
|
11
|
-
test "all files are properly created with rails31 migration syntax" do
|
12
|
-
run_generator %w(monster)
|
13
|
-
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
|
14
|
-
end
|
15
|
-
|
16
|
-
test "all files for namespaced model are properly created" do
|
17
|
-
run_generator %w(admin/monster)
|
18
|
-
assert_migration "db/migrate/devise_create_admin_monsters.rb", /def change/
|
19
|
-
end
|
20
|
-
|
21
|
-
test "update model migration when model exists" do
|
22
|
-
run_generator %w(monster)
|
23
|
-
assert_file "app/models/monster.rb"
|
24
|
-
run_generator %w(monster)
|
25
|
-
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
26
|
-
end
|
27
|
-
|
28
|
-
test "all files are properly deleted" do
|
29
|
-
run_generator %w(monster)
|
30
|
-
run_generator %w(monster)
|
31
|
-
assert_migration "db/migrate/devise_create_monsters.rb"
|
32
|
-
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
33
|
-
run_generator %w(monster), behavior: :revoke
|
34
|
-
assert_no_migration "db/migrate/add_devise_to_monsters.rb"
|
35
|
-
assert_migration "db/migrate/devise_create_monsters.rb"
|
36
|
-
run_generator %w(monster), behavior: :revoke
|
37
|
-
assert_no_file "app/models/monster.rb"
|
38
|
-
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
39
|
-
end
|
40
|
-
|
41
|
-
test "use string column type for ip addresses" do
|
42
|
-
run_generator %w(monster)
|
43
|
-
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :current_sign_in_ip/
|
44
|
-
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :last_sign_in_ip/
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
module RailsEngine
|
49
|
-
class Engine < Rails::Engine
|
50
|
-
isolate_namespace RailsEngine
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def simulate_inside_engine(engine, namespace)
|
55
|
-
if Rails::Generators.respond_to?(:namespace=)
|
56
|
-
swap Rails::Generators, namespace: namespace do
|
57
|
-
yield
|
58
|
-
end
|
59
|
-
else
|
60
|
-
swap Rails, application: engine.instance do
|
61
|
-
yield
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class ActiveRecordEngineGeneratorTest < Rails::Generators::TestCase
|
67
|
-
tests ActiveRecord::Generators::DeviseGenerator
|
68
|
-
destination File.expand_path("../../tmp", __FILE__)
|
69
|
-
setup :prepare_destination
|
70
|
-
|
71
|
-
test "all files are properly created in rails 4.0" do
|
72
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(false)
|
73
|
-
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
74
|
-
run_generator ["monster"]
|
75
|
-
|
76
|
-
assert_file "app/models/rails_engine/monster.rb", /devise/
|
77
|
-
assert_file "app/models/rails_engine/monster.rb" do |content|
|
78
|
-
assert_no_match /attr_accessible :email/, content
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
test "all files are properly created in rails 3.2 when strong_parameters gem is not installed" do
|
84
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(true)
|
85
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:strong_parameters_enabled?).returns(false)
|
86
|
-
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
87
|
-
run_generator ["monster"]
|
88
|
-
|
89
|
-
assert_file "app/models/rails_engine/monster.rb", /devise/
|
90
|
-
assert_file "app/models/rails_engine/monster.rb" do |content|
|
91
|
-
assert_match /attr_accessible :email/, content
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
test "all files are properly created in rails 3.2 when strong_parameters gem is installed" do
|
97
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(true)
|
98
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:strong_parameters_enabled?).returns(true)
|
99
|
-
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
100
|
-
run_generator ["monster"]
|
101
|
-
|
102
|
-
assert_file "app/models/rails_engine/monster.rb", /devise/
|
103
|
-
assert_file "app/models/rails_engine/monster.rb" do |content|
|
104
|
-
assert_no_match /attr_accessible :email/, content
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class ControllersGeneratorTest < Rails::Generators::TestCase
|
4
|
-
tests Devise::Generators::ControllersGenerator
|
5
|
-
destination File.expand_path("../../tmp", __FILE__)
|
6
|
-
setup :prepare_destination
|
7
|
-
|
8
|
-
test "Assert no controllers are created with no params" do
|
9
|
-
capture(:stderr) { run_generator }
|
10
|
-
assert_no_file "app/controllers/sessions_controller.rb"
|
11
|
-
assert_no_file "app/controllers/registrations_controller.rb"
|
12
|
-
assert_no_file "app/controllers/confirmations_controller.rb"
|
13
|
-
assert_no_file "app/controllers/passwords_controller.rb"
|
14
|
-
assert_no_file "app/controllers/unlocks_controller.rb"
|
15
|
-
assert_no_file "app/controllers/omniauth_callbacks_controller.rb"
|
16
|
-
end
|
17
|
-
|
18
|
-
test "Assert all controllers are properly created with scope param" do
|
19
|
-
run_generator %w(users)
|
20
|
-
assert_class_names 'users'
|
21
|
-
|
22
|
-
run_generator %w(admins)
|
23
|
-
assert_class_names 'admins'
|
24
|
-
end
|
25
|
-
|
26
|
-
test "Assert specified controllers with scope" do
|
27
|
-
run_generator %w(users -c sessions)
|
28
|
-
assert_file "app/controllers/users/sessions_controller.rb"
|
29
|
-
assert_no_file "app/controllers/users/registrations_controller.rb"
|
30
|
-
assert_no_file "app/controllers/users/confirmations_controller.rb"
|
31
|
-
assert_no_file "app/controllers/users/passwords_controller.rb"
|
32
|
-
assert_no_file "app/controllers/users/unlocks_controller.rb"
|
33
|
-
assert_no_file "app/controllers/users/omniauth_callbacks_controller.rb"
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def assert_class_names(scope, options = {})
|
39
|
-
base_dir = "app/controllers#{scope.blank? ? '' : ('/' + scope)}"
|
40
|
-
scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
|
41
|
-
controllers = options[:controllers] ||
|
42
|
-
%w(confirmations passwords registrations sessions unlocks omniauth_callbacks)
|
43
|
-
|
44
|
-
controllers.each do |c|
|
45
|
-
assert_file "#{base_dir}/#{c}_controller.rb", /#{scope_prefix + c.camelize}/
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|