-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rails main / 7.1.0.alpha introduced a change to improve typography by default, by converting all apostrophes to be single quotation marks. rails/rails#45463 The change caused all our text based matching to fail, this updates the tests to ensure compatibility. Model tests were changed to test against the error type & information rather than the translated string, which I think is an improvement overall that should make them a little less brittle. I thought of using [of_kind?] but that isn't available on all Rails versions we currently support, while `added?` is. The drawback is that `added?` require full details like the `:confirmation` example which requires the related attribute that is being confirmed, but that's a small price to pay. Integration tests were changed to match on a regexp that accepts both quotes. I could've used a simple `.` to match anything there, but thought I'd just keep it specific for clarity on what it is really expected to match there. Plus, since it's integration testing against a rendered response body, it's better to match the actual text rather than resort on other ways. (like using I18n directly, etc.) [of_kind?] https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-of_kind-3F
- Loading branch information
1 parent
afec665
commit 232c855
Showing
9 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,12 @@ class AuthenticatableTest < ActiveSupport::TestCase | |
|
||
test 'find_or_initialize_with_errors adds blank error' do | ||
user_with_error = User.find_or_initialize_with_errors([:email], { email: "" }) | ||
assert_equal ["Email can't be blank"], user_with_error.errors.full_messages_for(:email) | ||
assert user_with_error.errors.added?(:email, :blank) | ||
end | ||
|
||
test 'find_or_initialize_with_errors adds invalid error' do | ||
user_with_error = User.find_or_initialize_with_errors([:email], { email: "[email protected]" }) | ||
assert_equal ["Email is invalid"], user_with_error.errors.full_messages_for(:email) | ||
assert user_with_error.errors.added?(:email, :invalid) | ||
end | ||
|
||
if defined?(ActionController::Parameters) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters