1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test
Edouard CHIN 06756290d5 Fix AM::Errors.added? trying to generate a message:
- When a ActiveRecord record get saved and validated as part of a
  collection association, the errors attribute are changed to reflect
  the children names. You end up with an error attribute that will
  look like this:

  `author.errors # {:'books.title' => [:blank]}`

  2fe20cb55c/activerecord/lib/active_record/autosave_association.rb (L331-L340)

  We then can't check if the `books.title` errors was added using
  `ActiveModel::Errors#added?` because it tries to generate a message
  to make the match and end up calling the "books.title" method
  on the Author.

  ```
  author.errors.added?(:'books.title', :blank) => NoMethodError: undefined method `books.title'
  ```

  This patch modify the behaviour of `strict_match?` to not generate
  a message to make the comparison but instead make a strict
  comparison with the `options` from the error.
2019-07-10 23:33:32 +02:00
..
cases Fix AM::Errors.added? trying to generate a message: 2019-07-10 23:33:32 +02:00
models Merge pull request #32313 from lulalala/model_error_as_object 2019-04-24 16:16:00 -04:00
validators Raise deprecation for calling [:f] = 'b' or [:f] << 'b' 2019-03-31 22:59:12 +08:00