Commit Graph

1870 Commits

Author SHA1 Message Date
Akira Matsuda
5473e390d3 self. is not needed when calling its own instance method
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
2017-01-05 19:58:52 +09:00
Kasper Timm Hansen
e42cbb7d31 Revert "Merge pull request #27528 from kamipo/extract_casted_booleans"
As pointed out by @matthewd this change makes ImmutableString aware
of MysqlString's existence whereas previously MysqlString was only
overriding public API.

cc @kamipo

This reverts commit e632c2fa4cb60072a778ce95c952a0fa95e5b074, reversing
changes made to 334a7dcf107cd3ff1697163d331d289d6d65dcd7.
2017-01-01 14:34:04 +01:00
Ryuta Kamizono
d8e5751a1d Extract casted_true/casted_false for Type::ImmutableString
The only difference between `Type::ImmutableString` and its subclasses
is the representation of the casted booleans. Prefer extracting
`casted_true`/`casted_false` and override these by subclasses.
2017-01-01 04:01:17 +09:00
Kasper Timm Hansen
621d063f6b [ci skip] Update Active Model copyright years.
Missed in 37d956f. Fixes #27524.

[ MSathieu & Kasper Timm Hansen ]
2016-12-31 17:38:13 +01:00
Akira Matsuda
e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
Akira Matsuda
cdb9d7f481 Privatize unneededly protected methods in Active Model 2016-12-24 12:18:16 +09:00
Akira Matsuda
53f537d1f8 No need to :nodoc: private methods 2016-12-24 12:11:06 +09:00
Akira Matsuda
21e5fd4a2a Describe what we are protecting 2016-12-23 23:48:54 +09:00
MSP-Greg
e41c6ec888 Change ActiveModel::Type::Helpers to :nodoc: [ci skip] 2016-12-16 13:35:37 -06:00
Akira Matsuda
414484f68d Missing require "yaml" 2016-12-12 22:32:04 +09:00
Rafael Mendonça França
0951306ca5
Make ActiveModel::Errors backward compatible with 4.2
If a Error object was serialized in the database as YAML in the Rails
4.2 version, if we load in the Rails 5.0 version it will miss the
@details instance variable so methods like #clear and #add will start to
fail.
2016-12-08 16:27:47 -05:00
Sean Griffin
ef76f83f4c Merge pull request #26696 from iainbeeston/only-ruby-types-in-activemodel
Moved database-specific ActiveModel types into ActiveRecord
2016-12-08 13:45:47 -05:00
Sean Griffin
55ebf6c1ac Merge pull request #27185 from kamipo/fix_apply_seconds_precision
Fix `apply_seconds_precision` not to be affected by `mathn`
2016-12-08 13:04:39 -05:00
Gabi Stefanini
b970ade252 Add Action View to Active Model API documentation
In Rails 4.1, Action View was extracted from Action Pack, but this
change was not reflected in the API documentation of ActiveModel::Model.
This commits makes it explicit in the documentation that Active Model
also interacts with Action View as well as Action Pack.

[ci skip]
2016-12-06 22:37:25 -05:00
Gabi Stefanini
f3d0762d6c Fixes API wording to match API conventions
In ActiveModel::Model API documentation, referrences to Rails
components were tagged with fixed-width font and named as if
they were modules.This fixes the inconsistency to match API
documentation conventions.

[ci skip]
2016-12-06 22:36:49 -05:00
Ryuta Kamizono
6700f85726 Fix apply_seconds_precision not to be affected by mathn
Currently `apply_seconds_precision` cannnot round usec
when after `require 'mathn'`.

```
irb(main):001:0> 1234 / 1000 * 1000
=> 1000
irb(main):002:0> 1234 - 1234 % 1000
=> 1000
irb(main):003:0> require 'mathn'
=> true
irb(main):004:0> 1234 / 1000 * 1000
=> 1234
irb(main):005:0> 1234 - 1234 % 1000
=> 1000
```
2016-11-27 08:22:38 +09:00
Kenichi Kamiya
9f566aba32 Allow indifferent access in ActiveModel::Errors
`#[]` has already applied indifferent access, but some methods does not.

  `#include?`, `#has_key?`, `#key?`, `#delete` and `#full_messages_for`.
2016-11-22 04:10:41 +09:00
Yves Senn
2b4a9735d8 update bin/test scripts to prevent double runs.
The test runner was updated to make use of autorun. This caused the
`bin/test` scripts to run Minitest twice.
2016-11-21 17:25:12 +01:00
Kir Shatrov
5abf662959 Do not rely on Ruby implementation in AM test
Now a few tests in ActiveModel rely on Ruby implementation and the fact
that in MRI `97.18` as a float is greater than `97.18` as a BigDecimal.

This is only relevant for MRI. On JRuby, comparing float to BigDecimal
would be conversion of them to the same type and they will be equal.

I'd like the ActiveModel test suite to be Ruby implementation-agnostic.
Here we test ActiveModel, not the Ruby internals.
This PR fixes a couple more JRuby tests.
2016-11-19 21:02:29 -05:00
Andrew White
0ef5b6c163 Merge pull request #26905 from bogdanvlviv/docs
Add missing `+` around a some literals.
2016-11-13 14:09:30 +00:00
Andrew White
7305ac20b4 Merge pull request #26935 from y-yagi/fix_ruby_warning
remove warning from big integer test
2016-10-31 07:01:55 +00:00
yuuji.yaginuma
c33c03e80c remove warning from big integer test
This removes the following warnings.

```
activemodel/test/cases/type/big_integer_test.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```
2016-10-31 09:10:51 +09:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria
7506f33906 removes requires already present in active_support/rails 2016-10-27 09:45:20 +02:00
Xavier Noria
56832e791f let Regexp#match? be globally available
Regexp#match? should be considered to be part of the Ruby core library. We are
emulating it for < 2.4, but not having to require the extension is part of the
illusion of the emulation.
2016-10-27 09:13:55 +02:00
bogdanvlviv
5faa9a235c Add missing + around a some literals.
Mainly around `nil`

[ci skip]
2016-10-27 00:27:47 +03:00
Akira Matsuda
be623bf55f Missing require extract_options 2016-10-25 09:35:21 +09:00
Rafael França
8447f8d01c Merge pull request #26790 from iainbeeston/type-tests-in-their-own-files
Refactored ActiveModel::Type tests into their own files
2016-10-22 01:26:51 -03:00
Vijay Dev
5741e87eea Merge branch 'master' of github.com:rails/docrails 2016-10-20 17:28:48 +00:00
Iain Beeston
894c033843 Refactored ActiveModel::Type tests into their own files 2016-10-15 07:33:22 +01:00
Iain Beeston
994ce87bbd Moved database-specific ActiveModel types into ActiveRecord
ie. DecimalWithoutScale, Text and UnsignedInteger
2016-10-14 20:21:20 +01:00
Rafael Mendonça França
6a78e0ecd6
Removed deprecated :tokenizer in the length validator 2016-10-10 20:29:24 -03:00
Rafael Mendonça França
9de6457ab0
Removed deprecated methods in ActiveModel::Errors
`#get`, `#set`, `[]=`, `add_on_empty` and `add_on_blank`.
2016-10-10 20:22:15 -03:00
Sean Griffin
de9a56b66a Merge pull request #24571 from raimo/patch-1
Print the proper ::Float::INFINITY value when used as a default value
2016-10-04 17:37:04 -04:00
Iain Beeston
1e6aab94d5 Corrected comments referring to ActiveModel::Attributes
Should be ActiveRecord::Attributes (ActiveModel::Attributes does not exist)
2016-10-03 08:56:01 +01:00
Jean Boussier
33fd23e077 Do not leak the Errors default proc when calling to_hash or as_json 2016-09-27 14:33:16 +02:00
Andrey Molchanov
2003381bbb [ci skip] Fix bad examples in rdoc 2016-09-17 14:21:38 +03:00
Rafael França
84650022d5 Merge pull request #26516 from grosser/grosser/assert
improve error message when include assertions fail
2016-09-16 16:34:36 -03:00
Michael Grosser
a9aed2ac94
improve error message when include assertions fail
assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message

assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
2016-09-16 12:03:37 -07:00
Louis-Michel Couture
57e90ef5b1 Update ActiveModel::Dirty Doc [ci skip] 2016-09-16 10:57:04 -04:00
Louis-Michel Couture
da0532d9d1 Update ActiveModel::Dirty Doc [ci skip]
Fix potentially misleading example.
2016-09-15 17:34:42 -04:00
Ryuta Kamizono
3464cd5c28 Fix broken comments indentation caused by rubocop auto-correct [ci skip]
All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772.
But comments was still kept absolute position. This commit aligns
comments with method definitions for consistency.
2016-09-14 18:26:32 +09:00
Alex Kitchens
fbccae4d19 Fix Remaining Case-In-Assignment Statement Formatting
Recently, the Rails team made an effort to keep the source code consistent, using Ruboco
(bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case
statements were missed.

This changes the case statements' formatting and is consistent with changes
in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
2016-09-06 09:34:09 -05:00
Xavier Noria
db63406cb0 apply case-in-assignment pattern 2016-09-02 01:34:43 +02:00
Xavier Noria
810dff7c9f RuboCop is 100% green 🎉 2016-09-02 00:43:33 +02:00
Xavier Noria
bb1ecdcc67 fixes remaining RuboCop issues [Vipul A M, Xavier Noria] 2016-09-01 23:41:49 +02:00
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