Add warning about default config change

This change add warnings for these configurations:

* strip_whitespace_keys - It is already explicit on config template, now
it will be the same of the template.
* email_regexp - In the new version this regexp will be more
permissive.
* reconfirmable - It is already explicit on config template, now
it will be the same of the template.
* skip_session_storage - It is already explicit on config template, now
it will be the same of the template.
* sign_out_via - It is already explicit on config template, now
it will be the same of the template.

These ones is important to change, since the configuration says current
explicit value are the default. It can lead to misunderstanging if users
remove the explicit configuration.

It also updates the template explicit values:

* Warns the `config.mailer_sender` is nil by default
* Update `config.password_length` to use the current default
* Make the e-mail configuration explicit
This commit is contained in:
Ulisses Almeida
2016-04-12 16:01:34 -03:00
parent c87d8fda82
commit 164134c78a
3 changed files with 121 additions and 7 deletions

View File

@@ -35,6 +35,33 @@ class DeviseTest < ActiveSupport::TestCase
end
end
test 'setup block warns about defaults changing' do
Devise.app_set_configs = Set.new
ActiveSupport::Deprecation.expects(:warn).with() { |value| value =~ /email_regexp/ }
ActiveSupport::Deprecation.expects(:warn).with() { |value| value =~ /reconfirmable/ }
ActiveSupport::Deprecation.expects(:warn).with() { |value| value =~ /sign_out_via/ }
ActiveSupport::Deprecation.expects(:warn).with() { |value| value =~ /skip_session_storage/ }
ActiveSupport::Deprecation.expects(:warn).with() { |value| value =~ /strip_whitespace_keys/ }
Devise.setup do
end
end
test 'setup block doest not warns when the change is explicit set' do
ActiveSupport::Deprecation.expects(:warn).never
swap Devise,
email_regexp: /@/,
reconfirmable: false,
sign_out_via: :get,
skip_session_storage: [],
strip_whitespace_keys: [] do
Devise.setup do
end
end
end
test 'stores warden configuration' do
assert_kind_of Devise::Delegator, Devise.warden_config.failure_app
assert_equal :user, Devise.warden_config.default_scope