| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|
|
|
| |
Fixes #25410.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now use default procs inside of the errors object, which gets
included by default when marshaling anything that includes
`ActiveModel::Validations`. This means that Active Record objects cannot
be marshalled. We strip and apply the default proc ourselves. This will
ensure the objects are YAML serializable as well, since YAML falls back
to marshal implementations now. This is less important, however, as the
errors aren't included when dumping Active Record objects.
This commit does not include a changelog entry, as 5.0 is still in RC
status at the time of writing, and 5.0.0 will not release with the bug
this fixes.
Fixes #25165
|
|
|
|
| |
Mirror the documented new behavior of including details, when performing errors test.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
From: https://github.com/rails/rails/issues/24279
Problem:
By doing `record.errors.include? :foo`, it adds a new key to the
@messages hash that defaults to an empty array.
This happens because of a combination of these 2 commits:
https://github.com/rails/rails/commit/b97035df64f5b2f912425c4a7fcb6e6bb3ddab8d
(Added in Rails 4.1)
and
https://github.com/rails/rails/commit/6ec8ba16d85d5feaccb993c9756c1edcbbf0ba13#diff-fdcf8b65b5fb954372c6fe1ddf284c78R76
(Rails 5.0)
By adding the default proc that returns an array for non-existing keys,
ruby adds that key to the hash.
Solution:
Change `#include?` to check with `has_key?` and then check if that value is
`present?`.
Add test case for ActiveModels::Errors#include?
|
| |
|
|
|
|
| |
Also fix Minitest constant reference.
|
| |
|
|
|
|
|
| |
I believe this is a use case that was supposed to be supported, and it's
a small fix.
|
|\
| |
| | |
Simplify and alias ActiveModel::Errors methods where possible
|
| | |
|
| |
| |
| |
| | |
The expected value comes first. Related to #19465.
|
|/
|
|
|
|
|
|
|
|
|
|
| |
Rails 5.0 changes to ActiveModel::Errors include addition of `details`
that also accidentally changed the return value of `delete`. Since
there was no test for that behavior it went unnoticed. This commit
adds a test and fixes the regression.
Small improvements to comments have also been made. Since `get` is
getting deprecated it is better to use `[]` in other methods' code
examples. Also, in the module usage example, `def Person.method`
was replaced with a more commonly used `def self.method` code style.
|
|
|
|
| |
without replacement.
|
|
|
|
| |
They have inconsistent behaviour currently.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To be able to return type of validator, one can now call `details`
on Errors instance:
```ruby
class User < ActiveRecord::Base
validates :name, presence: true
end
```
```ruby
user = User.new; user.valid?; user.errors.details
=> {name: [{error: :blank}]}
```
|
|
|
|
| |
Mirror Ruby's Hash#key?
|
| |
|
| |
|
|
|
|
| |
From the doc, this method should return false and not nil if there is no errors for this key
|
| |
|
|
|
|
|
| |
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
|
|
|
|
|
| |
Also remove duplicated tests for Errors#as_json and minor improvements
in some tests.
|
|\
| |
| | |
Add a method full_messages_for to the Errors class
|
| | |
|
|/
|
|
|
| |
Introduce test on Error#full_message for attribute with underscores; Fix
some typos
|
|
|
|
|
| |
with the current tests, if delete the assignment of is_empty in add_on_empty method
the tests not fail. With this test, if we delete is_empty, the test fails
|
| |
|
| |
|
| |
|
|
|
|
|
| |
* move ActiveModel::Errors tests to errors_test.rb
* add spec coverage for add_on_empty and add_on_blank
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
Since ActiveModel::Errors instance keeps all error messages as hash
we should duplicate this object as well.
Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash,
which results in different behavior on `dup`, this may result in regression for
people relying on it.
|
|
|
|
| |
delegation
|
|
|
| |
The #added? method makes it possible to check if a specific error has been added, using the same parameters as for #add.
|
|
|
|
| |
for #add
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
serialization to properly handle multiple errors per attribute [#5615 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
This reverts commit a9b666b51d28b2e74da630c31327dee7cbe96d37.
|
| |
|
|
Signed-off-by: José Valim <jose.valim@gmail.com>
|