Commit Graph

1823 Commits

Author SHA1 Message Date
Guillermo Iguaran cec60d3989 validate_each in NumericalityValidator is never called in this case.
NumericalityValidator#validate_each is never called when allow_nil is true and
the value is nil because it is already skipped in EachValidator#validate.
2016-08-28 00:37:10 -05:00
Nicolai Reuschling 43f1b23a75 Add test for allow_blank in numericality validation
Signed-off-by: Guillermo Iguaran <guilleiguaran@gmail.com>
2016-08-28 00:29:40 -05:00
Georg Ledermann 11f5434a8c Fix typo in deprecation message
This fixes a copy-and-paste-issue slipped in by #18996
2016-08-27 08:42:45 +02:00
Rafael Mendonça França 55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria 432222fae1 prefer __dir__ over __FILE__ in File.expand_path
Thinking .. relative to files is not natural, we are used
to think "parent of a directory", and we have __dir__
nowadays.
2016-08-11 01:03:14 +02:00
Ryuta Kamizono f006de5dc5 Fix broken alignments caused by auto-correct commit 411ccbd
Hash syntax auto-correcting breaks alignments. 411ccbdab2
2016-08-10 06:36:39 +09:00
Xavier Noria a9dc45459a code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass
and removed most of them.

Note that if the method `foo` returns an array, `foo << 1`
is a regular push, nothing to do with assignments, so
no self required.
2016-08-08 01:12:38 +02:00
Xavier Noria b45c9ca9b6 revises most Lint/EndAlignment offenses
Some case expressions remain, need to think about those ones.
2016-08-07 23:41:00 +02:00
Ryuta Kamizono 762e3f05f3 Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty lines 2016-08-07 17:50:59 +09:00
Xavier Noria b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria 80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria 411ccbdab2 remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00
Xavier Noria fa911a74e1 modernizes hash syntax in activemodel 2016-08-06 19:37:12 +02:00
Xavier Noria e6ab70c439 applies new string literal convention to the rest of the project
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:28:46 +02:00
Xavier Noria adca8154c6 applies new string literal convention in the gemspecs
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:27:12 +02:00
Xavier Noria 4c20825457 applies new string literal convention in activemodel/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:38:23 +02:00
Xavier Noria 18a2513729 applies new string literal convention in activemodel/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:38:02 +02:00
Xavier Noria 11b463d8cb use \A and \z when you mean \A and \z
In Ruby ^ and $ mean start and end of *line*.

A regexp that validates an email should not check if
some line of the string looks like an email, and maybe
be surrounded by the entire Joyce's Ulysses. What the
regexp has to check is if the string itself looks like
an email.

This validator is used only in tests, the ^/$ anchors
implied no risk.
2016-07-24 21:42:19 +02:00
Xavier Noria 5a83f05424 systematic revision of =~ usage in AMo 2016-07-24 21:23:23 +02:00
David Elliott 3691c751e9 [ci skip] add class level documentation to ActiveModel::Type::Boolean
add documentation of the behaviors of type coercion at the class level
2016-07-11 07:29:58 -07:00
Rafael França a215642828 Merge pull request #25364 from kamipo/fix_serialize_for_date_type
Fix `Type::Date#serialize` to return a date object correctly
2016-06-28 23:33:31 -03:00
Robin Dupret eb1c0e2283 Tiny documentation fixes [ci skip]
Fix a tiny typo and vertical-align some return results in the
ActiveModel::Errors documentation.
2016-06-25 16:10:04 +02:00
Alex Kitchens 8305a09c5e [ci skip] Add additional documentation to ActiveModel::Errors 2016-06-22 15:45:11 -05:00
Rafael França 1a4474c2c7 Merge pull request #25415 from maclover7/jm-fix-25410
Add test to better demonstrate `ActiveModel::Errors#added?` behavior
2016-06-21 16:47:44 -03:00
Jon Moss 87e8719da3
Add test to better demonstrate `ActiveModel::Errors#added?` behavior
Fixes #25410.
2016-06-21 11:18:02 -04:00
Alex Kitchens 92e8ede6df [ci skip] Remove duplicate alias documentation in ActiveModel::Validations 2016-06-16 09:15:44 -05:00
Ryuta Kamizono 10b81fb51a Fix `Type::Date#serialize` to return a date object correctly
Currently `Type::Date#serialize` does not cast a value to a date object.
It should be cast to a date object for finding by date column correctly
working.

Fixes #25354.
2016-06-16 08:04:16 +09:00
Jon Moss b351061b83
Remove unused require and unused model stub
- The `Project` model should have been removed in 468939297d.
- The superfluous require was added in 605c6455ac.

Closes #25215

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
2016-05-31 11:30:23 -07:00
Sean Griffin b3dfd7d16c Ensure that instances of `ActiveModel::Errors` can be marshalled
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
2016-05-30 14:04:29 -04:00
Javan Makhmali d12209cad2 Remove package:clean task
Introduced in d6f2000a67 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task.
2016-05-24 13:11:28 -04:00
Jeremy Daer 89e2f7e722
Support for unified Integer class in Ruby 2.4+
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005

* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
2016-05-18 21:58:51 -07:00
Mohit Natoo 75c221f10f - removing redundant 'happens' in documentation [ci skip] 2016-05-19 02:02:30 +05:30
Vijay Dev 83ecf3fe56 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/configuring.md
2016-05-14 09:54:23 +00:00
Rafael Mendonça França 8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
Rafael França 1949412a86 Merge pull request #24799 from prathamesh-sonpatki/18439-followup
Active Model: Improve CHANGELOG and documentation for `validates_acceptance_of` [ci skip]
2016-05-05 16:29:20 -05:00
Prathamesh Sonpatki f7d7147ae6
Active Model: Improve CHANGELOG and documentation for `validates_acceptance_of` [ci skip]
- Improve CHANGELOG entry for #18439.
- The documentation is updated as per changes in PR #18439 to the
  `accept` option.
- The explanation about the virtual attribute is moved at the end so
  that the arity of `accept` option is explained first.
- Added a note that `message` can also be passed to `validates_acceptance_of`.
2016-05-05 16:25:47 -05:00
Rafael França 9c86a1804d Merge pull request #24806 from vipulnsward/errors-details-test
Followup of #18322
2016-05-05 16:23:52 -05:00
Rafael Mendonça França ab44e36624 Check for the right exception 2016-05-03 17:21:05 -05:00
Christian Blais 17141481d9 Change RangeError to a more specific ActiveModel::RangeError
The should make it easier for apps to rescue ActiveModel specific
errors without the need to wrap all method calls with a generic
rescue RangeError.
2016-05-03 14:46:49 -04:00
Vipul A M 25f829e43f Add example for UnknownAttributeError
[ci skip]
2016-05-02 03:08:59 +05:30
Vipul A M 4dd7a9d4a5 Followup of #18322
Mirror the documented new behavior of including details, when performing errors test.
2016-05-02 02:39:07 +05:30
Prathamesh Sonpatki 707b5c00ab
Active Model: Messages for strict validation always convert attributes to human readable form [ci skip] 2016-05-01 13:41:57 -05:00
lvl0nax 517cf249c3
Chomp: prefer String#chomp where we can for a clarity boost
Closes #24766, #24767

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
2016-04-29 13:43:15 -07:00
eileencodes f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Mohit Natoo 51d6a59329 - [ci skip] `regardless` is usually followed by `of` and not by `if .. or not`. 2016-04-21 00:04:05 +05:30
Bogdan Gusiev 80b9e5d7bd Fixed bug introduced in #24519. Makes build green again 2016-04-13 21:13:33 +03:00
Bogdan Gusiev afb1f32e79 Use keyword arguments to cleanup without droping performance 2016-04-13 02:03:51 +03:00
Sen-Zhang 051d859880 prevent 'attribute_changed?' from returning nil 2016-04-11 19:33:52 -07:00
Jeremy Daer 20ffb63c2e Merge pull request #24511 from lihanli/activemodel-dirty-attribute-changed
speed up ActiveModel::Dirty#attribute_changed?
2016-04-11 15:14:44 -07:00