aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
Commit message (Collapse)AuthorAgeFilesLines
* Don't pollute Object with rubinius_skip and jruby_skipAkira Matsuda2017-01-171-9/+9
| | | | we call them only in the tests
* Missing require for strip_heredocAkira Matsuda2017-01-171-0/+1
|
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-255-13/+13
|
* Describe what we are protectingAkira Matsuda2016-12-231-0/+2
|
* Missing require "yaml"Akira Matsuda2016-12-121-0/+1
|
* Make ActiveModel::Errors backward compatible with 4.2Rafael Mendonça França2016-12-081-0/+20
| | | | | | | 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.
* Merge pull request #26696 from iainbeeston/only-ruby-types-in-activemodelSean Griffin2016-12-081-18/+0
|\ | | | | | | Moved database-specific ActiveModel types into ActiveRecord
| * Moved database-specific ActiveModel types into ActiveRecordIain Beeston2016-10-141-18/+0
| | | | | | | | ie. DecimalWithoutScale, Text and UnsignedInteger
* | Allow indifferent access in ActiveModel::ErrorsKenichi Kamiya2016-11-221-3/+8
| | | | | | | | | | | | `#[]` has already applied indifferent access, but some methods does not. `#include?`, `#has_key?`, `#key?`, `#delete` and `#full_messages_for`.
* | Do not rely on Ruby implementation in AM testKir Shatrov2016-11-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #26935 from y-yagi/fix_ruby_warningAndrew White2016-10-311-1/+1
|\ \ | | | | | | remove warning from big integer test
| * | remove warning from big integer testyuuji.yaginuma2016-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* | | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-299-55/+55
|/ /
* | let Regexp#match? be globally availableXavier Noria2016-10-271-1/+0
| | | | | | | | | | | | 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.
* | Refactored ActiveModel::Type tests into their own filesIain Beeston2016-10-1513-168/+266
|/
* Removed deprecated :tokenizer in the length validatorRafael Mendonça França2016-10-102-40/+0
|
* Removed deprecated methods in ActiveModel::ErrorsRafael Mendonça França2016-10-101-92/+0
| | | | `#get`, `#set`, `[]=`, `add_on_empty` and `add_on_blank`.
* Do not leak the Errors default proc when calling to_hash or as_jsonJean Boussier2016-09-271-0/+10
|
* improve error message when include assertions failMichael Grosser2016-09-165-25/+25
| | | | | | 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
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-1/+1
| | | | | | 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.
* Add test for allow_blank in numericality validationNicolai Reuschling2016-08-281-0/+7
| | | | Signed-off-by: Guillermo Iguaran <guilleiguaran@gmail.com>
* Add three new rubocop rulesRafael Mendonça França2016-08-1611-60/+60
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* code gardening: removes redundant selfsXavier Noria2016-08-082-18/+18
| | | | | | | | | 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.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-072-2/+0
|
* applies remaining conventions across the projectXavier Noria2016-08-0614-16/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-0610-33/+32
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-063-7/+5
|
* modernizes hash syntax in activemodelXavier Noria2016-08-063-6/+6
|
* applies new string literal convention in activemodel/testXavier Noria2016-08-0638-563/+563
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* use \A and \z when you mean \A and \zXavier Noria2016-07-241-1/+1
| | | | | | | | | | | | | 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.
* systematic revision of =~ usage in AMoXavier Noria2016-07-241-2/+4
|
* Add test to better demonstrate `ActiveModel::Errors#added?` behaviorJon Moss2016-06-211-0/+6
| | | | Fixes #25410.
* Remove unused require and unused model stubJon Moss2016-05-312-4/+0
| | | | | | | | | - The `Project` model should have been removed in 468939297db91f8e595a93c94a16e23b26eee61a. - The superfluous require was added in 605c6455ac722ed9679e17458a47cc649cdedab0. Closes #25215 Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Ensure that instances of `ActiveModel::Errors` can be marshalledSean Griffin2016-05-301-0/+9
| | | | | | | | | | | | | | | | 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
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | 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.
* Merge pull request #24806 from vipulnsward/errors-details-testRafael França2016-05-051-1/+1
|\ | | | | Followup of #18322
| * Followup of #18322Vipul A M2016-05-021-1/+1
| | | | | | | | Mirror the documented new behavior of including details, when performing errors test.
* | Check for the right exceptionRafael Mendonça França2016-05-031-1/+1
| |
* | Change RangeError to a more specific ActiveModel::RangeErrorChristian Blais2016-05-031-6/+6
|/ | | | | | 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.
* Add test case for interpolation with passing of data along with record ↵Vipul A M2016-04-051-0/+8
| | | | attribute in error message, where a proc is passed.
* Allow passing record being validated to error message generatorPrathamesh Sonpatki2016-04-051-0/+8
| | | | | | | | | - Pass object to I18n helper so that when calling message proc, it will pass that object as argument to the proc and we can generate custom error messages based on current record being validated. - Based on https://github.com/rails/rails/issues/856. [Łukasz Bandzarewicz, Prathamesh Sonpatki]
* Merge pull request #24299 from kitop/activemodel-errors-include-fixKasper Timm Hansen2016-03-251-0/+7
|\ | | | | Do not create a hash key when calling ActiveModel::Errors#include?
| * Do not create a hash key when calling ActiveModel::Errors#include?Esteban Pastorino2016-03-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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?
* | Apply scale before precision when coercing floats to decimalSean Griffin2016-03-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since precision is always larger than scale, it can actually change rounding behavior. Given a precision of 5 and a scale of 3, when you apply the precision of 5 to `1.25047`, the result is `1.2505`, which when the scale is applied would be `1.251` instead of the expected `1.250`. This issue appears to only occur with floats, as scale doesn't apply to other numeric types, and the bigdecimal constructor actually ignores precision entirely when working with strings. There's no way we could handle this for the "unknown object which responds to `to_d`" case, as we can't assume an interface for applying the scale. Fixes #24235
* | Add edge cases to Time/Date/DateTime inclusion validation testsojab2016-03-241-3/+17
|/
* Remove load_paths fileArthur Neves2016-02-271-2/+0
|
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-222-4/+4
|
* Take UTC offset into account when assigning string value to time attribute.Andrey Novikov2016-01-051-0/+3
|
* Failing Tests for Validating String NumbericalityRobert Eshleman2015-12-221-0/+42
| | | | | | | | | | | Covers Regressions: * <= * < * == * > * >= * other than