aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attribute_decorators_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-25/+25
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* `type_cast_from_user` -> `cast`Sean Griffin2015-02-171-4/+4
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-2/+2
|
* Allow a symbol to be passed to `attribute`, in place of a type objectSean Griffin2015-02-061-3/+3
| | | | | | | | | | | | | | | | | | The same is not true of `define_attribute`, which is meant to be the low level no-magic API that sits underneath. The differences between the two APIs are: - `attribute` - Lazy (the attribute will be defined after the schema has loaded) - Allows either a type object or a symbol - `define_attribute` - Runs immediately (might get trampled by schema loading) - Requires a type object This was the last blocker in terms of public interface requirements originally discussed for this feature back in May. All the implementation blockers have been cleared, so this feature is probably ready for release (pending one more look-over by me).
* tests, use `drop_table if_exists: true` in our test suite.Yves Senn2015-01-201-1/+1
|
* Replace drop sql statement to drop_table methodYasuo Honda2014-09-111-1/+1
| | | | to drop sequences at the same time each tables dropped for Oracle
* Remove 'if exists' from drop table statement then use `table_exists?`Yasuo Honda2014-09-031-1/+1
| | | | | Since 'drop table if exists' statement does not always work with some databases such as Oracle.
* Revert "Merge pull request #16254 from ↵Yves Senn2014-08-291-0/+1
| | | | | | | | | | | | | zuhao/refactor_activerecord_attribute_decorators_test" This reverts commit 16fe19831548f108c113094d106663497fc190d5, reversing changes made to 4c81c8ce533896be28bdc0b055ff30bb9dee1316. The call to `Model.reset_column_information` was to express the intent of the test. `reset_column_information` itself can trigger SQL queries because it checks for a tables existance. Let's move it outside of the block. /cc @sgrif
* Remove redundant that already happened in teardown.Zuhao Wan2014-07-221-1/+0
|
* Don't type cast the default on the columnSean Griffin2014-06-171-11/+1
| | | | | | | If we want to have type decorators mess with the attribute, but not the column, we need to stop type casting on the column. Where possible, we changed the tests to test the value of `column_defaults`, which is public API. `Column#default` is not.
* Promote time zone aware attributes to a first class type decoratorSean Griffin2014-06-161-0/+21
| | | | | | | | | | | | | This refactoring revealed the need for another form of decoration, which takes a proc to select which it applies to (There's a *lot* of cases where this form can be used). To avoid duplication, we can re-implement the old decoration in terms of the proc-based decoration. The reason we're `instance_exec`ing the matcher is for cases such as time zone aware attributes, where a decorator is defined in a parent class, and a method called in the matcher is overridden by a child class. The matcher will close over the parent, and evaluate in its context, which is not the behavior we want.
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-2/+2
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* Make `_before_type_cast` actually be before type castSean Griffin2014-06-091-0/+2
| | | | | | | | | | | | | - The following is now true for all types, all the time - `model.attribute_before_type_cast == given_value` - `model.attribute == model.save_and_reload.attribute` - `model.attribute == model.dup.attribute` - `model.attribute == YAML.load(YAML.dump(model)).attribute` - Removes the remaining types implementing `type_cast_for_write` - Simplifies the implementation of time zone aware attributes - Brings tz aware attributes closer to being implemented as an attribute decorator - Adds additional point of control for custom types
* fix test cases after #15558 merge to master.Kuldeep Aggarwal2014-06-071-3/+3
|
* Don't query the database schema when calling `serialize`Sean Griffin2014-06-071-0/+112
We need to decorate the types lazily. This is extracted to a separate API, as there are other refactorings that will be able to make use of it, and to allow unit testing the finer points more granularly.