Commit 8d56636
committed
Fix full error message test on Rails 6
Before Rails 6, `#human_attribute_name` was called with an symbol as the
first argument (`:name`) which made the switch case execute the `else`
branch (calling `attribute.to_s.humanize`). Ref: https://github.com/rails/rails/blob/5-2-stable/activemodel/lib/active_model/errors.rb#L370
On Rails 6, `#human_attribute_name` is always called with a String
(`"name"`) which made our switch case to execute the first branch.
Since the attribute name was not the most important part of the test -
the full error message is what we care about - I decided to change the
test in order to make it work on both versions.
References:
- https://github.com/rails/rails/blob/6-0-stable/activemodel/lib/active_model/errors.rb#L414
- https://github.com/rails/rails/blob/6-0-stable/activemodel/lib/active_model/errors.rb#L4481 parent 13d0341 commit 8d56636
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
0 commit comments