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,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
class ControllersGeneratorTest < Rails::Generators::TestCase
|
6
|
-
tests Devise::Generators::ControllersGenerator
|
7
|
-
destination File.expand_path("../../tmp", __FILE__)
|
8
|
-
setup :prepare_destination
|
9
|
-
|
10
|
-
test "Assert no controllers are created with no params" do
|
11
|
-
capture(:stderr) { run_generator }
|
12
|
-
assert_no_file "app/controllers/sessions_controller.rb"
|
13
|
-
assert_no_file "app/controllers/registrations_controller.rb"
|
14
|
-
assert_no_file "app/controllers/confirmations_controller.rb"
|
15
|
-
assert_no_file "app/controllers/passwords_controller.rb"
|
16
|
-
assert_no_file "app/controllers/unlocks_controller.rb"
|
17
|
-
assert_no_file "app/controllers/omniauth_callbacks_controller.rb"
|
18
|
-
end
|
19
|
-
|
20
|
-
test "Assert all controllers are properly created with scope param" do
|
21
|
-
run_generator %w(users)
|
22
|
-
assert_class_names 'users'
|
23
|
-
|
24
|
-
run_generator %w(admins)
|
25
|
-
assert_class_names 'admins'
|
26
|
-
end
|
27
|
-
|
28
|
-
test "Assert specified controllers with scope" do
|
29
|
-
run_generator %w(users -c sessions)
|
30
|
-
assert_file "app/controllers/users/sessions_controller.rb"
|
31
|
-
assert_no_file "app/controllers/users/registrations_controller.rb"
|
32
|
-
assert_no_file "app/controllers/users/confirmations_controller.rb"
|
33
|
-
assert_no_file "app/controllers/users/passwords_controller.rb"
|
34
|
-
assert_no_file "app/controllers/users/unlocks_controller.rb"
|
35
|
-
assert_no_file "app/controllers/users/omniauth_callbacks_controller.rb"
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def assert_class_names(scope, options = {})
|
41
|
-
base_dir = "app/controllers#{scope.blank? ? '' : ('/' + scope)}"
|
42
|
-
scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
|
43
|
-
controllers = options[:controllers] ||
|
44
|
-
%w(confirmations passwords registrations sessions unlocks omniauth_callbacks)
|
45
|
-
|
46
|
-
controllers.each do |c|
|
47
|
-
assert_file "#{base_dir}/#{c}_controller.rb", /#{scope_prefix + c.camelize}/
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
require "generators/devise/devise_generator"
|
6
|
-
|
7
|
-
class DeviseGeneratorTest < Rails::Generators::TestCase
|
8
|
-
tests Devise::Generators::DeviseGenerator
|
9
|
-
destination File.expand_path("../../tmp", __FILE__)
|
10
|
-
|
11
|
-
setup do
|
12
|
-
prepare_destination
|
13
|
-
copy_routes
|
14
|
-
end
|
15
|
-
|
16
|
-
test "route generation for simple model names" do
|
17
|
-
run_generator %w(monster name:string)
|
18
|
-
assert_file "config/routes.rb", /devise_for :monsters/
|
19
|
-
end
|
20
|
-
|
21
|
-
test "route generation for namespaced model names" do
|
22
|
-
run_generator %w(monster/goblin name:string)
|
23
|
-
match = /devise_for :goblins, class_name: "Monster::Goblin"/
|
24
|
-
assert_file "config/routes.rb", match
|
25
|
-
end
|
26
|
-
|
27
|
-
test "route generation with skip routes" do
|
28
|
-
run_generator %w(monster name:string --skip-routes)
|
29
|
-
match = /devise_for :monsters, skip: :all/
|
30
|
-
assert_file "config/routes.rb", match
|
31
|
-
end
|
32
|
-
|
33
|
-
def copy_routes
|
34
|
-
routes = File.expand_path("../../rails_app/config/routes.rb", __FILE__)
|
35
|
-
destination = File.join(destination_root, "config")
|
36
|
-
|
37
|
-
FileUtils.mkdir_p(destination)
|
38
|
-
FileUtils.cp routes, destination
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
class InstallGeneratorTest < Rails::Generators::TestCase
|
6
|
-
tests Devise::Generators::InstallGenerator
|
7
|
-
destination File.expand_path("../../tmp", __FILE__)
|
8
|
-
setup :prepare_destination
|
9
|
-
|
10
|
-
test "assert all files are properly created" do
|
11
|
-
run_generator(["--orm=active_record"])
|
12
|
-
assert_file "config/initializers/devise.rb", /devise\/orm\/active_record/
|
13
|
-
assert_file "config/locales/devise.en.yml"
|
14
|
-
end
|
15
|
-
|
16
|
-
test "fails if no ORM is specified" do
|
17
|
-
stderr = capture(:stderr) do
|
18
|
-
run_generator
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_match %r{An ORM must be set to install Devise}, stderr
|
22
|
-
|
23
|
-
assert_no_file "config/initializers/devise.rb"
|
24
|
-
assert_no_file "config/locales/devise.en.yml"
|
25
|
-
end
|
26
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
if DEVISE_ORM == :mongoid
|
6
|
-
require "generators/mongoid/devise_generator"
|
7
|
-
|
8
|
-
class MongoidGeneratorTest < Rails::Generators::TestCase
|
9
|
-
tests Mongoid::Generators::DeviseGenerator
|
10
|
-
destination File.expand_path("../../tmp", __FILE__)
|
11
|
-
setup :prepare_destination
|
12
|
-
|
13
|
-
test "all files are properly created" do
|
14
|
-
run_generator %w(monster)
|
15
|
-
assert_file "app/models/monster.rb", /devise/
|
16
|
-
end
|
17
|
-
|
18
|
-
test "all files are properly deleted" do
|
19
|
-
run_generator %w(monster)
|
20
|
-
run_generator %w(monster), behavior: :revoke
|
21
|
-
assert_no_file "app/models/monster.rb"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
class ViewsGeneratorTest < Rails::Generators::TestCase
|
6
|
-
tests Devise::Generators::ViewsGenerator
|
7
|
-
destination File.expand_path("../../tmp", __FILE__)
|
8
|
-
setup :prepare_destination
|
9
|
-
|
10
|
-
test "Assert all views are properly created with no params" do
|
11
|
-
run_generator
|
12
|
-
assert_files
|
13
|
-
assert_shared_links
|
14
|
-
end
|
15
|
-
|
16
|
-
test "Assert all views are properly created with scope param" do
|
17
|
-
run_generator %w(users)
|
18
|
-
assert_files "users"
|
19
|
-
assert_shared_links "users"
|
20
|
-
|
21
|
-
run_generator %w(admins)
|
22
|
-
assert_files "admins"
|
23
|
-
assert_shared_links "admins"
|
24
|
-
end
|
25
|
-
|
26
|
-
test "Assert views with simple form" do
|
27
|
-
run_generator %w(-b simple_form_for)
|
28
|
-
assert_files
|
29
|
-
assert_file "app/views/devise/confirmations/new.html.erb", /simple_form_for/
|
30
|
-
|
31
|
-
run_generator %w(users -b simple_form_for)
|
32
|
-
assert_files "users"
|
33
|
-
assert_file "app/views/users/confirmations/new.html.erb", /simple_form_for/
|
34
|
-
end
|
35
|
-
|
36
|
-
test "Assert views with markerb" do
|
37
|
-
run_generator %w(--markerb)
|
38
|
-
assert_files nil, mail_template_engine: "markerb"
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
test "Assert only views within specified directories" do
|
43
|
-
run_generator %w(-v sessions registrations)
|
44
|
-
assert_file "app/views/devise/sessions/new.html.erb"
|
45
|
-
assert_file "app/views/devise/registrations/new.html.erb"
|
46
|
-
assert_file "app/views/devise/registrations/edit.html.erb"
|
47
|
-
assert_no_file "app/views/devise/confirmations/new.html.erb"
|
48
|
-
assert_no_file "app/views/devise/mailer/confirmation_instructions.html.erb"
|
49
|
-
end
|
50
|
-
|
51
|
-
test "Assert mailer specific directory with simple form" do
|
52
|
-
run_generator %w(-v mailer -b simple_form_for)
|
53
|
-
assert_file "app/views/devise/mailer/confirmation_instructions.html.erb"
|
54
|
-
assert_file "app/views/devise/mailer/reset_password_instructions.html.erb"
|
55
|
-
assert_file "app/views/devise/mailer/unlock_instructions.html.erb"
|
56
|
-
end
|
57
|
-
|
58
|
-
test "Assert specified directories with scope" do
|
59
|
-
run_generator %w(users -v sessions)
|
60
|
-
assert_file "app/views/users/sessions/new.html.erb"
|
61
|
-
assert_no_file "app/views/users/confirmations/new.html.erb"
|
62
|
-
end
|
63
|
-
|
64
|
-
test "Assert specified directories with simple form" do
|
65
|
-
run_generator %w(-v registrations -b simple_form_for)
|
66
|
-
assert_file "app/views/devise/registrations/new.html.erb", /simple_form_for/
|
67
|
-
assert_no_file "app/views/devise/confirmations/new.html.erb"
|
68
|
-
end
|
69
|
-
|
70
|
-
test "Assert specified directories with markerb" do
|
71
|
-
run_generator %w(--markerb -v passwords mailer)
|
72
|
-
assert_file "app/views/devise/passwords/new.html.erb"
|
73
|
-
assert_no_file "app/views/devise/confirmations/new.html.erb"
|
74
|
-
assert_file "app/views/devise/mailer/reset_password_instructions.markerb"
|
75
|
-
end
|
76
|
-
|
77
|
-
def assert_files(scope = nil, options={})
|
78
|
-
scope = "devise" if scope.nil?
|
79
|
-
mail_template_engine = options[:mail_template_engine] || "html.erb"
|
80
|
-
|
81
|
-
assert_file "app/views/#{scope}/confirmations/new.html.erb"
|
82
|
-
assert_file "app/views/#{scope}/mailer/confirmation_instructions.#{mail_template_engine}"
|
83
|
-
assert_file "app/views/#{scope}/mailer/reset_password_instructions.#{mail_template_engine}"
|
84
|
-
assert_file "app/views/#{scope}/mailer/unlock_instructions.#{mail_template_engine}"
|
85
|
-
assert_file "app/views/#{scope}/passwords/edit.html.erb"
|
86
|
-
assert_file "app/views/#{scope}/passwords/new.html.erb"
|
87
|
-
assert_file "app/views/#{scope}/registrations/new.html.erb"
|
88
|
-
assert_file "app/views/#{scope}/registrations/edit.html.erb"
|
89
|
-
assert_file "app/views/#{scope}/sessions/new.html.erb"
|
90
|
-
assert_file "app/views/#{scope}/shared/_links.html.erb"
|
91
|
-
assert_file "app/views/#{scope}/unlocks/new.html.erb"
|
92
|
-
end
|
93
|
-
|
94
|
-
def assert_shared_links(scope = nil)
|
95
|
-
scope = "devise" if scope.nil?
|
96
|
-
link = /<%= render \"#{scope}\/shared\/links\" %>/
|
97
|
-
|
98
|
-
assert_file "app/views/#{scope}/passwords/edit.html.erb", link
|
99
|
-
assert_file "app/views/#{scope}/passwords/new.html.erb", link
|
100
|
-
assert_file "app/views/#{scope}/confirmations/new.html.erb", link
|
101
|
-
assert_file "app/views/#{scope}/registrations/new.html.erb", link
|
102
|
-
assert_file "app/views/#{scope}/sessions/new.html.erb", link
|
103
|
-
assert_file "app/views/#{scope}/unlocks/new.html.erb", link
|
104
|
-
end
|
105
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class DeviseHelperTest < Devise::IntegrationTest
|
6
|
-
setup do
|
7
|
-
model_labels = { models: { user: "the user" } }
|
8
|
-
translations = {
|
9
|
-
errors: { messages: { not_saved: {
|
10
|
-
one: "Can't save %{resource} because of 1 error",
|
11
|
-
other: "Can't save %{resource} because of %{count} errors",
|
12
|
-
} } },
|
13
|
-
activerecord: model_labels,
|
14
|
-
mongoid: model_labels
|
15
|
-
}
|
16
|
-
|
17
|
-
I18n.available_locales
|
18
|
-
I18n.backend.store_translations(:en, translations)
|
19
|
-
end
|
20
|
-
|
21
|
-
teardown do
|
22
|
-
I18n.reload!
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'test errors.messages.not_saved with single error from i18n' do
|
26
|
-
get new_user_registration_path
|
27
|
-
|
28
|
-
fill_in 'password', with: 'new_user123'
|
29
|
-
fill_in 'password confirmation', with: 'new_user123'
|
30
|
-
click_button 'Sign up'
|
31
|
-
|
32
|
-
assert_have_selector '#error_explanation'
|
33
|
-
assert_contain "Can't save the user because of 1 error"
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'test errors.messages.not_saved with multiple errors from i18n' do
|
37
|
-
# Dirty tracking behavior prevents email validations from being applied:
|
38
|
-
# https://github.com/mongoid/mongoid/issues/756
|
39
|
-
(pending "Fails on Mongoid < 2.1"; break) if defined?(Mongoid) && Mongoid::VERSION.to_f < 2.1
|
40
|
-
|
41
|
-
get new_user_registration_path
|
42
|
-
|
43
|
-
fill_in 'email', with: 'invalid_email'
|
44
|
-
fill_in 'password', with: 'new_user123'
|
45
|
-
fill_in 'password confirmation', with: 'new_user321'
|
46
|
-
click_button 'Sign up'
|
47
|
-
|
48
|
-
assert_have_selector '#error_explanation'
|
49
|
-
assert_contain "Can't save the user because of 2 errors"
|
50
|
-
end
|
51
|
-
end
|