aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/type
Commit message (Collapse)AuthorAgeFilesLines
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-254-12/+12
|
* 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
* | 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-291-2/+2
|/ /
* / Refactored ActiveModel::Type tests into their own filesIain Beeston2016-10-1512-43/+266
|/
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activemodel/testXavier Noria2016-08-062-12/+12
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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.
* 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 an immutable string type to opt out of string dupingSean Griffin2015-10-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This type adds an escape hatch to apps for which string duping causes unacceptable memory growth. The reason we are duping them is in order to detect mutation, which was a feature added to 4.2 in #15674. The string type was modified to support this behavior in #15788. Memory growth is really only a concern for string types, as it's the only mutable type where the act of coersion does not create a new object regardless (as we're usually returning an object of a different class). I do feel strongly that if we are going to support detecting mutation, we should do it universally for any type which is mutable. While it is less common and ideomatic to mutate strings than arrays or hashes, there shouldn't be rules or gotchas to understanding our behavior. However, I also appreciate that for apps which are using a lot of string columns, this would increase the number of allocations by a large factor. To ensure that we keep our contract, if you'd like to opt out of mutation detection on strings, you'll also be option out of mutation of those strings. I'm not completely married to the thought that strings coming out of this actually need to be frozen -- and I think the name is correct either way, as the purpose of this is to provide a string type which does not detect mutation. In the new implementation, I'm only overriding `cast_value`. I did not port over the duping in `serialize`. I cannot think of a reason we'd need to dup the string there, and the tests pass without it. Unfortunately that line was introduced at a time where I was not nearly as good about writing my commit messages, so I have no context as to why I added it. Thanks past Sean. You are a jerk.
* Move the appropriate type tests to the Active Model suiteSean Griffin2015-09-214-0/+203
| | | | | | | | | Any tests for a type which is not overridden by Active Record, and does not test the specifics of the attributes API interacting in more complex ways have no reason to be in the Active Record suite. Doing this revealed that the implementation of the date and time types in AM was actually completely broken, and incapable of returning any value other than `nil`.
* Simplify the implementation of Active Model's type registrySean Griffin2015-09-211-0/+39
Things like decorations, overrides, and priorities only matter for Active Record, so the Active Model registry can be implemented much more simply. At this point, I wonder if having Active Record's registry inherit from Active Model's is even worth the trouble? The Active Model class was also missing test cases, which have been backfilled. This removes the error when two types are registered with the same name, but given that Active Model is meant to be significantly more generic, I do not think this is an issue for now. If we want, we can raise an error at the point that someone tries to register it.