-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downcase authentication keys and humanize error message #4834
Conversation
@@ -103,11 +103,11 @@ def i18n_message(default = nil) | |||
options[:scope] = "devise.failure" | |||
options[:default] = [message] | |||
auth_keys = scope_class.authentication_keys | |||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) } | |||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key).downcase } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add tests for it? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, created the pull request a bit to early!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited the existing tests. They check, that the downcasing are done. There's not really a test to check the added humanize method though, not sure, if that's necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add tests to ensure that it's the expected behavior.
@grantzau What do you think about squash the commits? All of them is about the same change - downcase authentication keys and humanize error message, so for me, just one commit is enough. Here a great blog post about it: https://blog.carbonfive.com/2017/08/28/always-squash-and-rebase-your-git-commits/ |
Great! I will look at it and squash it during the weekend. Was editing
directly on Github from the browser, which wasn't a good idea ..!
fre. 6. apr. 2018 kl. 03.22 skrev Felipe Renan <notifications@github.com>:
… @grantzau <https://github.com/grantzau> What do you think about squash
the commits? All of them is about the same change - downcase authentication
keys and humanize error message, so for me, just one commit is enough.
Here a greate blog post about it:
https://blog.carbonfive.com/2017/08/28/always-squash-and-rebase-your-git-commits/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4834 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWVadtJRbJSR8Tcj5rQuHw3mir16bM5ks5tlsM0gaJpZM4TJIQ7>
.
|
d9372e4
to
cca5a7b
Compare
Added tests and rebased commits. |
test/failure_app_test.rb
Outdated
test 'uses custom i18n options' do | ||
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions) | ||
assert_equal 'User Steve does not exist', @request.flash[:alert] | ||
assert_equal 'User steve does not exist', @request.flash[:alert] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one, I think it should have stayed as it was before. This is a custom message defined here: https://github.com/plataformatec/devise/blob/88724e10adaf9ffd1d8dbfbaadda2b9d40de756a/test/support/locale/en.yml#L5 and we're passing the user's name Steve
in a capitalized form here: https://github.com/grantzau/devise/blob/cca5a7b8e9f699de4299e001d95e3e269470f47f/test/failure_app_test.rb#L27, which gets lost when we call #humanize
[3] pry(main)> "User Steve does not exist".humanize
=> "User steve does not exist"
I'm not sure what's the best solution here. Maybe we should only call #humanize
when the message is :invalid
🤔
Note that you can control i18n of parameters to failure messages by doing something like this: In your models:
and then in
and then in your
Ideally Devise would support an optional Hope this helps! |
@grantzau are you still going to work on this? I'm asking to know if I should assign it to someone else. |
To fix #4095