devise 4.4.3 → 4.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +174 -4
- data/MIT-LICENSE +2 -1
- data/README.md +129 -65
- data/app/controllers/devise/confirmations_controller.rb +1 -0
- data/app/controllers/devise/passwords_controller.rb +3 -2
- data/app/controllers/devise/registrations_controller.rb +27 -9
- data/app/controllers/devise/sessions_controller.rb +2 -2
- data/app/controllers/devise/unlocks_controller.rb +1 -0
- data/app/controllers/devise_controller.rb +17 -3
- data/app/helpers/devise_helper.rb +21 -18
- data/app/mailers/devise/mailer.rb +5 -5
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +5 -5
- data/app/views/devise/registrations/new.html.erb +3 -3
- data/app/views/devise/sessions/new.html.erb +3 -3
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/_links.html.erb +8 -8
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +3 -2
- data/lib/devise/controllers/helpers.rb +10 -8
- data/lib/devise/controllers/responder.rb +35 -0
- data/lib/devise/controllers/sign_in_out.rb +9 -4
- data/lib/devise/controllers/url_helpers.rb +1 -1
- data/lib/devise/failure_app.rb +41 -8
- data/lib/devise/hooks/csrf_cleaner.rb +6 -1
- data/lib/devise/hooks/lockable.rb +2 -5
- data/lib/devise/hooks/timeoutable.rb +2 -2
- data/lib/devise/mapping.rb +1 -1
- data/lib/devise/models/authenticatable.rb +51 -48
- data/lib/devise/models/confirmable.rb +34 -40
- data/lib/devise/models/database_authenticatable.rb +54 -35
- data/lib/devise/models/lockable.rb +13 -5
- data/lib/devise/models/omniauthable.rb +2 -2
- data/lib/devise/models/recoverable.rb +8 -19
- data/lib/devise/models/registerable.rb +2 -0
- data/lib/devise/models/rememberable.rb +2 -2
- data/lib/devise/models/timeoutable.rb +1 -1
- data/lib/devise/models/trackable.rb +9 -2
- data/lib/devise/models/validatable.rb +4 -9
- data/lib/devise/models.rb +1 -0
- data/lib/devise/omniauth.rb +2 -5
- data/lib/devise/orm.rb +71 -0
- data/lib/devise/parameter_filter.rb +2 -0
- data/lib/devise/parameter_sanitizer.rb +13 -1
- data/lib/devise/rails/deprecated_constant_accessor.rb +39 -0
- data/lib/devise/rails/routes.rb +6 -6
- data/lib/devise/rails.rb +4 -0
- data/lib/devise/secret_key_finder.rb +2 -0
- data/lib/devise/strategies/authenticatable.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +6 -1
- data/lib/devise/test/controller_helpers.rb +5 -3
- data/lib/devise/test/integration_helpers.rb +1 -1
- data/lib/devise/test_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +38 -11
- data/lib/generators/active_record/devise_generator.rb +26 -11
- data/lib/generators/devise/controllers_generator.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/install_generator.rb +1 -5
- data/lib/generators/devise/orm_helpers.rb +2 -2
- data/lib/generators/devise/views_generator.rb +1 -1
- data/lib/generators/mongoid/devise_generator.rb +5 -5
- data/lib/generators/templates/README +9 -1
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/devise.rb +38 -8
- 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 +12 -4
- 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 +23 -316
- data/.gitignore +0 -10
- data/.travis.yml +0 -68
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -22
- data/CONTRIBUTING.md +0 -79
- data/Gemfile +0 -39
- data/Gemfile.lock +0 -193
- data/ISSUE_TEMPLATE.md +0 -19
- data/Rakefile +0 -37
- data/bin/test +0 -13
- data/devise.gemspec +0 -28
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-4.1-stable +0 -32
- data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
- data/gemfiles/Gemfile.rails-4.2-stable +0 -32
- data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.0-stable +0 -33
- data/gemfiles/Gemfile.rails-5.0-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.2-rc1 +0 -26
- data/gemfiles/Gemfile.rails-5.2-rc1.lock +0 -201
- data/guides/bug_report_templates/integration_test.rb +0 -106
- data/test/controllers/custom_registrations_controller_test.rb +0 -42
- data/test/controllers/custom_strategy_test.rb +0 -66
- data/test/controllers/helper_methods_test.rb +0 -24
- data/test/controllers/helpers_test.rb +0 -318
- data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -53
- data/test/controllers/internal_helpers_test.rb +0 -129
- data/test/controllers/load_hooks_controller_test.rb +0 -21
- data/test/controllers/passwords_controller_test.rb +0 -34
- data/test/controllers/sessions_controller_test.rb +0 -108
- data/test/controllers/url_helpers_test.rb +0 -67
- data/test/delegator_test.rb +0 -21
- data/test/devise_test.rb +0 -109
- data/test/failure_app_test.rb +0 -340
- data/test/generators/active_record_generator_test.rb +0 -130
- data/test/generators/controllers_generator_test.rb +0 -50
- data/test/generators/devise_generator_test.rb +0 -41
- data/test/generators/install_generator_test.rb +0 -26
- data/test/generators/mongoid_generator_test.rb +0 -25
- data/test/generators/views_generator_test.rb +0 -105
- data/test/helpers/devise_helper_test.rb +0 -51
- data/test/integration/authenticatable_test.rb +0 -706
- data/test/integration/confirmable_test.rb +0 -326
- data/test/integration/database_authenticatable_test.rb +0 -97
- data/test/integration/http_authenticatable_test.rb +0 -114
- data/test/integration/lockable_test.rb +0 -242
- data/test/integration/mounted_engine_test.rb +0 -38
- data/test/integration/omniauthable_test.rb +0 -148
- data/test/integration/recoverable_test.rb +0 -349
- data/test/integration/registerable_test.rb +0 -365
- data/test/integration/rememberable_test.rb +0 -219
- data/test/integration/timeoutable_test.rb +0 -186
- data/test/integration/trackable_test.rb +0 -99
- data/test/mailers/confirmation_instructions_test.rb +0 -117
- data/test/mailers/email_changed_test.rb +0 -132
- data/test/mailers/mailer_test.rb +0 -20
- data/test/mailers/reset_password_instructions_test.rb +0 -98
- data/test/mailers/unlock_instructions_test.rb +0 -93
- data/test/mapping_test.rb +0 -136
- data/test/models/authenticatable_test.rb +0 -25
- data/test/models/confirmable_test.rb +0 -549
- data/test/models/database_authenticatable_test.rb +0 -283
- data/test/models/lockable_test.rb +0 -352
- data/test/models/omniauthable_test.rb +0 -9
- data/test/models/recoverable_test.rb +0 -263
- data/test/models/registerable_test.rb +0 -9
- data/test/models/rememberable_test.rb +0 -184
- data/test/models/serializable_test.rb +0 -60
- data/test/models/timeoutable_test.rb +0 -53
- data/test/models/trackable_test.rb +0 -62
- data/test/models/validatable_test.rb +0 -121
- data/test/models_test.rb +0 -155
- data/test/omniauth/config_test.rb +0 -61
- data/test/omniauth/url_helpers_test.rb +0 -53
- data/test/orm/active_record.rb +0 -24
- data/test/orm/mongoid.rb +0 -15
- data/test/parameter_sanitizer_test.rb +0 -77
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -8
- data/test/rails_app/app/active_record/shim.rb +0 -4
- data/test/rails_app/app/active_record/user.rb +0 -20
- data/test/rails_app/app/active_record/user_on_engine.rb +0 -9
- data/test/rails_app/app/active_record/user_on_main_app.rb +0 -9
- data/test/rails_app/app/active_record/user_with_validations.rb +0 -12
- data/test/rails_app/app/active_record/user_without_email.rb +0 -10
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -8
- data/test/rails_app/app/controllers/admins_controller.rb +0 -8
- data/test/rails_app/app/controllers/application_controller.rb +0 -13
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -32
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -33
- data/test/rails_app/app/controllers/home_controller.rb +0 -31
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -4
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -4
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -16
- data/test/rails_app/app/controllers/users_controller.rb +0 -33
- data/test/rails_app/app/helpers/application_helper.rb +0 -5
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -6
- data/test/rails_app/app/mongoid/admin.rb +0 -31
- data/test/rails_app/app/mongoid/shim.rb +0 -25
- data/test/rails_app/app/mongoid/user.rb +0 -50
- data/test/rails_app/app/mongoid/user_on_engine.rb +0 -41
- data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -41
- data/test/rails_app/app/mongoid/user_with_validations.rb +0 -37
- data/test/rails_app/app/mongoid/user_without_email.rb +0 -35
- 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 -48
- data/test/rails_app/config/boot.rb +0 -27
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -7
- data/test/rails_app/config/environments/development.rb +0 -32
- data/test/rails_app/config/environments/production.rb +0 -88
- data/test/rails_app/config/environments/test.rb +0 -47
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -9
- data/test/rails_app/config/initializers/devise.rb +0 -182
- data/test/rails_app/config/initializers/inflections.rb +0 -4
- data/test/rails_app/config/initializers/secret_token.rb +0 -5
- data/test/rails_app/config/initializers/session_store.rb +0 -3
- data/test/rails_app/config/routes.rb +0 -128
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -77
- data/test/rails_app/db/schema.rb +0 -57
- data/test/rails_app/lib/shared_admin.rb +0 -23
- data/test/rails_app/lib/shared_user.rb +0 -32
- data/test/rails_app/lib/shared_user_without_email.rb +0 -28
- data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -15
- 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 -11
- data/test/routes_test.rb +0 -281
- data/test/secret_key_finder_test.rb +0 -97
- data/test/support/action_controller/record_identifier.rb +0 -12
- data/test/support/assertions.rb +0 -30
- data/test/support/helpers.rb +0 -83
- data/test/support/http_method_compatibility.rb +0 -53
- data/test/support/integration.rb +0 -95
- data/test/support/locale/en.yml +0 -8
- data/test/support/mongoid.yml +0 -6
- data/test/support/webrat/integrations/rails.rb +0 -35
- data/test/test/controller_helpers_test.rb +0 -193
- data/test/test/integration_helpers_test.rb +0 -34
- data/test/test_helper.rb +0 -36
- data/test/test_models.rb +0 -35
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SharedUserWithoutEmail
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
# NOTE: This is missing :validatable and :confirmable, as they both require
|
8
|
-
# an email field at the moment. It is also missing :omniauthable because that
|
9
|
-
# adds unnecessary complexity to the setup
|
10
|
-
devise :database_authenticatable, :lockable, :recoverable,
|
11
|
-
:registerable, :rememberable, :timeoutable,
|
12
|
-
:trackable
|
13
|
-
end
|
14
|
-
|
15
|
-
# This test stub is a bit rubbish because it's tied very closely to the
|
16
|
-
# implementation where we care about this one case. However, completely
|
17
|
-
# removing the email field breaks "recoverable" tests completely, so we are
|
18
|
-
# just taking the approach here that "email" is something that is a not an
|
19
|
-
# ActiveRecord field.
|
20
|
-
def email_changed?
|
21
|
-
raise NoMethodError
|
22
|
-
end
|
23
|
-
|
24
|
-
def respond_to?(method_name, include_all=false)
|
25
|
-
return false if method_name.to_sym == :email_changed?
|
26
|
-
super(method_name, include_all)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SharedUserWithoutOmniauth
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
8
|
-
:registerable, :rememberable, :timeoutable,
|
9
|
-
:trackable, :validatable, reconfirmable: false
|
10
|
-
end
|
11
|
-
|
12
|
-
def raw_confirmation_token
|
13
|
-
@raw_confirmation_token
|
14
|
-
end
|
15
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/404.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
File without changes
|
data/test/rails_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class RailsTest < ActiveSupport::TestCase
|
6
|
-
test 'correct initializer position' do
|
7
|
-
initializer = Devise::Engine.initializers.detect { |i| i.name == 'devise.omniauth' }
|
8
|
-
assert_equal :load_config_initializers, initializer.after
|
9
|
-
assert_equal :build_middleware_stack, initializer.before
|
10
|
-
end
|
11
|
-
end
|
data/test/routes_test.rb
DELETED
@@ -1,281 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
ExpectedRoutingError = MiniTest::Assertion
|
6
|
-
|
7
|
-
class DefaultRoutingTest < ActionController::TestCase
|
8
|
-
test 'map new user session' do
|
9
|
-
assert_recognizes({controller: 'devise/sessions', action: 'new'}, {path: 'users/sign_in', method: :get})
|
10
|
-
assert_named_route "/users/sign_in", :new_user_session_path
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'map create user session' do
|
14
|
-
assert_recognizes({controller: 'devise/sessions', action: 'create'}, {path: 'users/sign_in', method: :post})
|
15
|
-
assert_named_route "/users/sign_in", :user_session_path
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'map destroy user session' do
|
19
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: 'users/sign_out', method: :delete})
|
20
|
-
assert_named_route "/users/sign_out", :destroy_user_session_path
|
21
|
-
end
|
22
|
-
|
23
|
-
test 'map new user confirmation' do
|
24
|
-
assert_recognizes({controller: 'devise/confirmations', action: 'new'}, 'users/confirmation/new')
|
25
|
-
assert_named_route "/users/confirmation/new", :new_user_confirmation_path
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'map create user confirmation' do
|
29
|
-
assert_recognizes({controller: 'devise/confirmations', action: 'create'}, {path: 'users/confirmation', method: :post})
|
30
|
-
assert_named_route "/users/confirmation", :user_confirmation_path
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'map show user confirmation' do
|
34
|
-
assert_recognizes({controller: 'devise/confirmations', action: 'show'}, {path: 'users/confirmation', method: :get})
|
35
|
-
end
|
36
|
-
|
37
|
-
test 'map new user password' do
|
38
|
-
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'users/password/new')
|
39
|
-
assert_named_route "/users/password/new", :new_user_password_path
|
40
|
-
end
|
41
|
-
|
42
|
-
test 'map create user password' do
|
43
|
-
assert_recognizes({controller: 'devise/passwords', action: 'create'}, {path: 'users/password', method: :post})
|
44
|
-
assert_named_route "/users/password", :user_password_path
|
45
|
-
end
|
46
|
-
|
47
|
-
test 'map edit user password' do
|
48
|
-
assert_recognizes({controller: 'devise/passwords', action: 'edit'}, 'users/password/edit')
|
49
|
-
assert_named_route "/users/password/edit", :edit_user_password_path
|
50
|
-
end
|
51
|
-
|
52
|
-
test 'map update user password' do
|
53
|
-
assert_recognizes({controller: 'devise/passwords', action: 'update'}, {path: 'users/password', method: :put})
|
54
|
-
end
|
55
|
-
|
56
|
-
test 'map new user unlock' do
|
57
|
-
assert_recognizes({controller: 'devise/unlocks', action: 'new'}, 'users/unlock/new')
|
58
|
-
assert_named_route "/users/unlock/new", :new_user_unlock_path
|
59
|
-
end
|
60
|
-
|
61
|
-
test 'map create user unlock' do
|
62
|
-
assert_recognizes({controller: 'devise/unlocks', action: 'create'}, {path: 'users/unlock', method: :post})
|
63
|
-
assert_named_route "/users/unlock", :user_unlock_path
|
64
|
-
end
|
65
|
-
|
66
|
-
test 'map show user unlock' do
|
67
|
-
assert_recognizes({controller: 'devise/unlocks', action: 'show'}, {path: 'users/unlock', method: :get})
|
68
|
-
end
|
69
|
-
|
70
|
-
test 'map new user registration' do
|
71
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, 'users/sign_up')
|
72
|
-
assert_named_route "/users/sign_up", :new_user_registration_path
|
73
|
-
end
|
74
|
-
|
75
|
-
test 'map create user registration' do
|
76
|
-
assert_recognizes({controller: 'devise/registrations', action: 'create'}, {path: 'users', method: :post})
|
77
|
-
assert_named_route "/users", :user_registration_path
|
78
|
-
end
|
79
|
-
|
80
|
-
test 'map edit user registration' do
|
81
|
-
assert_recognizes({controller: 'devise/registrations', action: 'edit'}, {path: 'users/edit', method: :get})
|
82
|
-
assert_named_route "/users/edit", :edit_user_registration_path
|
83
|
-
end
|
84
|
-
|
85
|
-
test 'map update user registration' do
|
86
|
-
assert_recognizes({controller: 'devise/registrations', action: 'update'}, {path: 'users', method: :put})
|
87
|
-
end
|
88
|
-
|
89
|
-
test 'map destroy user registration' do
|
90
|
-
assert_recognizes({controller: 'devise/registrations', action: 'destroy'}, {path: 'users', method: :delete})
|
91
|
-
end
|
92
|
-
|
93
|
-
test 'map cancel user registration' do
|
94
|
-
assert_recognizes({controller: 'devise/registrations', action: 'cancel'}, {path: 'users/cancel', method: :get})
|
95
|
-
assert_named_route "/users/cancel", :cancel_user_registration_path
|
96
|
-
end
|
97
|
-
|
98
|
-
test 'map omniauth callbacks' do
|
99
|
-
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :get})
|
100
|
-
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :post})
|
101
|
-
assert_named_route "/users/auth/facebook/callback", :user_facebook_omniauth_callback_path
|
102
|
-
|
103
|
-
# named open_id
|
104
|
-
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :get})
|
105
|
-
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :post})
|
106
|
-
assert_named_route "/users/auth/google/callback", :user_google_omniauth_callback_path
|
107
|
-
|
108
|
-
assert_raise ExpectedRoutingError do
|
109
|
-
assert_recognizes({controller: 'ysers/omniauth_callbacks', action: 'twitter'}, {path: 'users/auth/twitter/callback', method: :get})
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
protected
|
114
|
-
|
115
|
-
def assert_named_route(result, *args)
|
116
|
-
assert_equal result, @routes.url_helpers.send(*args)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
class CustomizedRoutingTest < ActionController::TestCase
|
121
|
-
test 'map admin with :path option' do
|
122
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'admin_area/sign_up', method: :get})
|
123
|
-
end
|
124
|
-
|
125
|
-
test 'map admin with :controllers option' do
|
126
|
-
assert_recognizes({controller: 'admins/sessions', action: 'new'}, {path: 'admin_area/sign_in', method: :get})
|
127
|
-
end
|
128
|
-
|
129
|
-
test 'does not map admin password' do
|
130
|
-
assert_raise ExpectedRoutingError do
|
131
|
-
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'admin_area/password/new')
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
test 'subdomain admin' do
|
136
|
-
assert_recognizes({"host"=>"sub.example.com", controller: 'devise/sessions', action: 'new'}, {host: "sub.example.com", path: '/sub_admin/sign_in', method: :get})
|
137
|
-
end
|
138
|
-
|
139
|
-
test 'does only map reader password' do
|
140
|
-
assert_raise ExpectedRoutingError do
|
141
|
-
assert_recognizes({controller: 'devise/sessions', action: 'new'}, 'reader/sessions/new')
|
142
|
-
end
|
143
|
-
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'reader/password/new')
|
144
|
-
end
|
145
|
-
|
146
|
-
test 'map account with custom path name for session sign in' do
|
147
|
-
assert_recognizes({controller: 'devise/sessions', action: 'new', locale: 'en'}, '/en/accounts/login')
|
148
|
-
end
|
149
|
-
|
150
|
-
test 'map account with custom path name for session sign out' do
|
151
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy', locale: 'en'}, {path: '/en/accounts/logout', method: :delete })
|
152
|
-
end
|
153
|
-
|
154
|
-
test 'map account with custom path name for password' do
|
155
|
-
assert_recognizes({controller: 'devise/passwords', action: 'new', locale: 'en'}, '/en/accounts/secret/new')
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'map account with custom path name for registration' do
|
159
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new', locale: 'en'}, '/en/accounts/management/register')
|
160
|
-
end
|
161
|
-
|
162
|
-
test 'map account with custom path name for edit registration' do
|
163
|
-
assert_recognizes({controller: 'devise/registrations', action: 'edit', locale: 'en'}, '/en/accounts/management/edit/profile')
|
164
|
-
end
|
165
|
-
|
166
|
-
test 'map account with custom path name for cancel registration' do
|
167
|
-
assert_recognizes({controller: 'devise/registrations', action: 'cancel', locale: 'en'}, '/en/accounts/management/giveup')
|
168
|
-
end
|
169
|
-
|
170
|
-
test 'map deletes with :sign_out_via option' do
|
171
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :delete})
|
172
|
-
assert_raise ExpectedRoutingError do
|
173
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :get})
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
test 'map posts with :sign_out_via option' do
|
178
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :post})
|
179
|
-
assert_raise ExpectedRoutingError do
|
180
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :get})
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
test 'map delete_or_posts with :sign_out_via option' do
|
185
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :post})
|
186
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :delete})
|
187
|
-
assert_raise ExpectedRoutingError do
|
188
|
-
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :get})
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
test 'map with constraints defined in hash' do
|
193
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/headquarters/sign_up', method: :get})
|
194
|
-
assert_raise ExpectedRoutingError do
|
195
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100/headquarters/sign_up', method: :get})
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
test 'map with constraints defined in block' do
|
200
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/homebase/sign_up', method: :get})
|
201
|
-
assert_raise ExpectedRoutingError do
|
202
|
-
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100//homebase/sign_up', method: :get})
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
test 'map with format false for sessions' do
|
207
|
-
expected_params = {controller: 'devise/sessions', action: 'new'}
|
208
|
-
expected_params[:format] = false if Devise::Test.rails5?
|
209
|
-
|
210
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in', method: :get})
|
211
|
-
assert_raise ExpectedRoutingError do
|
212
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_in.xml', method: :get})
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
test 'map with format false for passwords' do
|
217
|
-
expected_params = {controller: 'devise/passwords', action: 'create'}
|
218
|
-
expected_params[:format] = false if Devise::Test.rails5?
|
219
|
-
|
220
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/password', method: :post})
|
221
|
-
assert_raise ExpectedRoutingError do
|
222
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/password.xml', method: :post})
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
test 'map with format false for registrations' do
|
227
|
-
expected_params = {controller: 'devise/registrations', action: 'new'}
|
228
|
-
expected_params[:format] = false if Devise::Test.rails5?
|
229
|
-
|
230
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up', method: :get})
|
231
|
-
assert_raise ExpectedRoutingError do
|
232
|
-
assert_recognizes(expected_params, {path: '/htmlonly_admin/sign_up.xml', method: :get})
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
test 'map with format false for confirmations' do
|
237
|
-
expected_params = {controller: 'devise/confirmations', action: 'show'}
|
238
|
-
expected_params[:format] = false if Devise::Test.rails5?
|
239
|
-
|
240
|
-
assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation', method: :get})
|
241
|
-
assert_raise ExpectedRoutingError do
|
242
|
-
assert_recognizes(expected_params, {path: '/htmlonly_users/confirmation.xml', method: :get})
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
test 'map with format false for unlocks' do
|
247
|
-
expected_params = {controller: 'devise/unlocks', action: 'show'}
|
248
|
-
expected_params[:format] = false if Devise::Test.rails5?
|
249
|
-
|
250
|
-
assert_recognizes(expected_params, {path: '/htmlonly_users/unlock', method: :get})
|
251
|
-
assert_raise ExpectedRoutingError do
|
252
|
-
assert_recognizes(expected_params, {path: '/htmlonly_users/unlock.xml', method: :get})
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
test 'map with format false is not permanent' do
|
257
|
-
assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
|
258
|
-
end
|
259
|
-
|
260
|
-
test 'checks if mapping has proper configuration for omniauth callback' do
|
261
|
-
e = assert_raise ArgumentError do
|
262
|
-
routes = ActionDispatch::Routing::RouteSet.new
|
263
|
-
routes.draw do
|
264
|
-
devise_for :not_omniauthable, class_name: 'Admin', controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
|
265
|
-
end
|
266
|
-
end
|
267
|
-
assert_match "Mapping omniauth_callbacks on a resource that is not omniauthable", e.message
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
class ScopedRoutingTest < ActionController::TestCase
|
272
|
-
test 'map publisher account' do
|
273
|
-
assert_recognizes({controller: 'publisher/registrations', action: 'new'}, {path: '/publisher/accounts/sign_up', method: :get})
|
274
|
-
assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
|
275
|
-
end
|
276
|
-
|
277
|
-
test 'map publisher account merges path names' do
|
278
|
-
assert_recognizes({controller: 'publisher/sessions', action: 'new'}, {path: '/publisher/accounts/get_in', method: :get})
|
279
|
-
assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
|
280
|
-
end
|
281
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Rails52Credentials
|
6
|
-
def credentials
|
7
|
-
OpenStruct.new(secret_key_base: 'credentials')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Rails52Secrets
|
12
|
-
def credentials
|
13
|
-
OpenStruct.new(secret_key_base: nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
def secrets
|
17
|
-
OpenStruct.new(secret_key_base: 'secrets')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Rails52Config
|
22
|
-
def credentials
|
23
|
-
OpenStruct.new(secret_key_base: nil)
|
24
|
-
end
|
25
|
-
|
26
|
-
def secrets
|
27
|
-
OpenStruct.new(secret_key_base: nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
def config
|
31
|
-
OpenStruct.new(secret_key_base: 'config')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Rails41Secrets
|
36
|
-
def secrets
|
37
|
-
OpenStruct.new(secret_key_base: 'secrets')
|
38
|
-
end
|
39
|
-
|
40
|
-
def config
|
41
|
-
OpenStruct.new(secret_key_base: nil)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class Rails41Config
|
46
|
-
def secrets
|
47
|
-
OpenStruct.new(secret_key_base: nil)
|
48
|
-
end
|
49
|
-
|
50
|
-
def config
|
51
|
-
OpenStruct.new(secret_key_base: 'config')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class Rails40Config
|
56
|
-
def config
|
57
|
-
OpenStruct.new(secret_key_base: 'config')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class SecretKeyFinderTest < ActiveSupport::TestCase
|
62
|
-
test "rails 5.2 uses credentials when they're available" do
|
63
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails52Credentials.new)
|
64
|
-
|
65
|
-
assert_equal 'credentials', secret_key_finder.find
|
66
|
-
end
|
67
|
-
|
68
|
-
test "rails 5.2 uses secrets when credentials are empty" do
|
69
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails52Secrets.new)
|
70
|
-
|
71
|
-
assert_equal 'secrets', secret_key_finder.find
|
72
|
-
end
|
73
|
-
|
74
|
-
test "rails 5.2 uses config when secrets are empty" do
|
75
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails52Config.new)
|
76
|
-
|
77
|
-
assert_equal 'config', secret_key_finder.find
|
78
|
-
end
|
79
|
-
|
80
|
-
test "rails 4.1 uses secrets" do
|
81
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails41Secrets.new)
|
82
|
-
|
83
|
-
assert_equal 'secrets', secret_key_finder.find
|
84
|
-
end
|
85
|
-
|
86
|
-
test "rails 4.1 uses config when secrets are empty" do
|
87
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails41Config.new)
|
88
|
-
|
89
|
-
assert_equal 'config', secret_key_finder.find
|
90
|
-
end
|
91
|
-
|
92
|
-
test "rails 4.0 uses config" do
|
93
|
-
secret_key_finder = Devise::SecretKeyFinder.new(Rails40Config.new)
|
94
|
-
|
95
|
-
assert_equal 'config', secret_key_finder.find
|
96
|
-
end
|
97
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Since webrat uses ActionController::RecordIdentifier class that was moved to
|
4
|
-
# ActionView namespace in Rails 4.1+
|
5
|
-
|
6
|
-
unless defined?(ActionController::RecordIdentifier)
|
7
|
-
require 'action_view/record_identifier'
|
8
|
-
|
9
|
-
module ActionController
|
10
|
-
RecordIdentifier = ActionView::RecordIdentifier
|
11
|
-
end
|
12
|
-
end
|
data/test/support/assertions.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/test_case'
|
4
|
-
|
5
|
-
class ActiveSupport::TestCase
|
6
|
-
def assert_blank(assertion)
|
7
|
-
assert assertion.blank?
|
8
|
-
end
|
9
|
-
|
10
|
-
def assert_present(assertion)
|
11
|
-
assert assertion.present?
|
12
|
-
end
|
13
|
-
|
14
|
-
def assert_email_sent(address = nil, &block)
|
15
|
-
assert_difference('ActionMailer::Base.deliveries.size', &block)
|
16
|
-
if address.present?
|
17
|
-
assert_equal address, ActionMailer::Base.deliveries.last['to'].to_s
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def assert_email_not_sent(&block)
|
22
|
-
assert_no_difference('ActionMailer::Base.deliveries.size', &block)
|
23
|
-
end
|
24
|
-
|
25
|
-
def assert_raise_with_message(exception_klass, message, &block)
|
26
|
-
exception = assert_raise exception_klass, &block
|
27
|
-
assert_equal exception.message, message,
|
28
|
-
"The expected message was #{message} but your exception throwed #{exception.message}"
|
29
|
-
end
|
30
|
-
end
|
data/test/support/helpers.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/test_case'
|
4
|
-
|
5
|
-
class ActiveSupport::TestCase
|
6
|
-
VALID_AUTHENTICATION_TOKEN = 'AbCdEfGhIjKlMnOpQrSt'.freeze
|
7
|
-
|
8
|
-
def setup_mailer
|
9
|
-
ActionMailer::Base.deliveries = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def store_translations(locale, translations, &block)
|
13
|
-
# Calling 'available_locales' before storing the translations to ensure
|
14
|
-
# that the I18n backend will be initialized before we store our custom
|
15
|
-
# translations, so they will always override the translations for the
|
16
|
-
# YML file.
|
17
|
-
I18n.available_locales
|
18
|
-
I18n.backend.store_translations(locale, translations)
|
19
|
-
yield
|
20
|
-
ensure
|
21
|
-
I18n.reload!
|
22
|
-
end
|
23
|
-
|
24
|
-
def generate_unique_email
|
25
|
-
@@email_count ||= 0
|
26
|
-
@@email_count += 1
|
27
|
-
"test#{@@email_count}@example.com"
|
28
|
-
end
|
29
|
-
|
30
|
-
def valid_attributes(attributes={})
|
31
|
-
{ username: "usertest",
|
32
|
-
email: generate_unique_email,
|
33
|
-
password: '12345678',
|
34
|
-
password_confirmation: '12345678' }.update(attributes)
|
35
|
-
end
|
36
|
-
|
37
|
-
def new_user(attributes={})
|
38
|
-
User.new(valid_attributes(attributes))
|
39
|
-
end
|
40
|
-
|
41
|
-
def create_user(attributes={})
|
42
|
-
User.create!(valid_attributes(attributes))
|
43
|
-
end
|
44
|
-
|
45
|
-
def create_admin(attributes={})
|
46
|
-
valid_attributes = valid_attributes(attributes)
|
47
|
-
valid_attributes.delete(:username)
|
48
|
-
Admin.create!(valid_attributes)
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_user_without_email(attributes={})
|
52
|
-
UserWithoutEmail.create!(valid_attributes(attributes))
|
53
|
-
end
|
54
|
-
|
55
|
-
def create_user_with_validations(attributes={})
|
56
|
-
UserWithValidations.create!(valid_attributes(attributes))
|
57
|
-
end
|
58
|
-
|
59
|
-
# Execute the block setting the given values and restoring old values after
|
60
|
-
# the block is executed.
|
61
|
-
def swap(object, new_values)
|
62
|
-
old_values = {}
|
63
|
-
new_values.each do |key, value|
|
64
|
-
old_values[key] = object.send key
|
65
|
-
object.send :"#{key}=", value
|
66
|
-
end
|
67
|
-
clear_cached_variables(new_values)
|
68
|
-
yield
|
69
|
-
ensure
|
70
|
-
clear_cached_variables(new_values)
|
71
|
-
old_values.each do |key, value|
|
72
|
-
object.send :"#{key}=", value
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def clear_cached_variables(options)
|
77
|
-
if options.key?(:case_insensitive_keys) || options.key?(:strip_whitespace_keys)
|
78
|
-
Devise.mappings.each do |_, mapping|
|
79
|
-
mapping.to.instance_variable_set(:@devise_parameter_filter, nil)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|