aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/timestamp_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Further remove reliance on subsecond precision in testsSean Griffin2015-09-231-6/+14
|
* Fix missing index when using timestamps with indexPaul Mucur2015-04-151-0/+11
| | | | | | | | | | | The `index` option used with `timestamps` should be passed to both `column` definitions for `created_at` and `updated_at` rather than just the first. This was happening because `Hash#delete` is used to extract the `index` option passed to `timestamps`, thereby mutating the `options` hash in-place. Now take a copy of the `options` before deleting so that the original is not modified.
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Add `time` option to `#touch`Hyonjee Joo2015-02-181-0/+21
| | | | | | Fixes #18905. `#touch` now takes time as an option. Setting the option saves the record with the updated_at/on attributes set to the current time or the time specified. Updated tests and documentation accordingly.
* Build fix when running in isolationArun Agrawal2014-11-141-0/+1
| | | | | `Computer` class needs to be require See #17217 for more details
* Merge pull request #8813 from ↵Yves Senn2014-08-141-0/+19
|\ | | | | | | | | | | | | | | | | greyblake/dont_write_timestamps_if_they_are_not_attributes Write timestamps only if there are timestamps columns Conflicts: activerecord/CHANGELOG.md
| * Do not try to write timestamps if they are missing #8813Potapov Sergey2014-02-161-0/+22
| |
* | Timestamp values should be present on callbacksRafael Mendonça França2014-06-091-18/+13
| | | | | | | | | | | | | | This reverts commit dd3ea17191e316aeebddaa7b176f6cfeee7a6365 and add a regression test. Fixes #15418
* | `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty ↵Lucas Mazza2014-04-231-1/+20
| | | | | | | | | | | | transactions. Closes #14841.
* | Merge pull request #14469 from tiegz/timestamp_inheritance_fixRafael Mendonça França2014-03-271-0/+18
| | | | | | | | Swap Timestamp/Callbacks order in ActiveRecord::Base
* | ActiveRecord#touch should accept multiple attributes #14423Thiago Pinto2014-03-191-0/+12
|/
* polymorphic belongs_to association with touch: true updates old record correctlySeverin Schoepke2013-12-051-16/+42
| | | | | | | | | Example: Given you have a comments model with a polymorphic commentable association (e.g. books and songs) with the touch option set. Every time you update a comment its commentable should be touched. This was working when you changed attributes on the comment or when you moved the comment from one book to another. However, it was not working when moving a comment from a book to a song. This is now fixed.
* swap arguments for some `assert_equal` statements => `expected, actual`Yves Senn2013-11-201-6/+6
|
* add #no_touching on ActiveRecord modelsDamien Mathieu2013-11-131-0/+48
|
* Removed unused associationsAndrew White2013-04-241-2/+0
|
* added test cases for #10197Adam Gamble2013-04-241-0/+56
|
* Revert "Revert "`belongs_to :touch` behavior now touches old association ↵Andrew White2013-04-241-0/+46
| | | | | | | | | when transitioning to new association" until a proper fix is found for #10197" This reverts commit 7389df139a35436f00876c96d20e81ba23c93f0a. Conflicts: activerecord/test/cases/timestamp_test.rb
* Remove test case also related to the belongs_to touch featureDavid Heinemeier Hansson2013-04-231-20/+0
|
* Revert "`belongs_to :touch` behavior now touches old association when ↵David Heinemeier Hansson2013-04-231-26/+0
| | | | transitioning to new association" until a proper fix is found for #10197
* Improve `belongs_to touch: true` timestamp testAndrew White2013-04-051-7/+21
| | | | | | Round off time to a whole second value to compensate for databases that don't support fractional timestamps. Also add a assertion to check that the old record is touched when the association is cleared.
* Use inspect when writing the foreign key from the reflectionAndrew White2013-04-051-0/+6
| | | | | | If we don't use inspect inside the class_eval block then the foreign key is written without quotes causing us to fetch the foreign key value and not the column name.
* Modifies belong_to touch callback to touch old associations also #9091Adam Gamble2013-03-141-10/+2
|
* + Add test for auto timestamps update of both old & new parent recordsPikachuEXE2013-03-141-0/+34
|
* Fix touching an invalid parent record for belongs_toOlek Janiszewski2013-02-261-0/+12
| | | | | | | | | | | | | | | | | | | | | | If the parent of a `belongs_to` record fails to be saved due to validation errors, `touch` will be called on a new record, which causes an exception (see https://github.com/rails/rails/pull/9320). Example: class Owner < ActiveRecord::Base validates_presence_of :name end class Pet < ActiveRecord::Base belongs_to :owner, touch: true end pet = Pet.new(owner: Owner.new) # Before, this line would raise ActiveRecord::ActiveRecordError # "can not touch on a new record object" pet.save
* Use method compilation for association methodsJon Leighton2012-08-101-13/+15
| | | | | | | | | Method compilation provides better performance and I think the code comes out cleaner as well. A knock on effect is that methods that get redefined produce warnings. I think this is a good thing. I had to deal with a bunch of warnings coming from our tests, though.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-3/+3
| | | | Closes #1190
* Remove update_attribute.Steve Klabnik2012-06-141-2/+2
| | | | | | | | | | | Historically, update_attribute and update_attributes are similar, but with one big difference: update_attribute does not run validations. These two methods are really easy to confuse given their similar names. Therefore, update_attribute is being removed in favor of update_column. See the thread on rails-core here: https://groups.google.com/forum/?fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA
* Allow instances to disable record_timestampsPratik Naik2011-10-261-0/+10
|
* fix typoAlexandr Zykov2011-06-081-1/+1
|
* This way asserting that updated_at was changed in touch look more obvious.Dmitriy Kiriyenko2011-06-071-0/+1
|
* Do not use default_scope in ActiveRecord::Persistence#touch.Dmitriy Kiriyenko2011-06-071-0/+9
|
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Isolated PostgreSQL test into PostgreSQL folderPrem Sichanugrist2011-05-311-20/+0
|
* Reduce test noiseJon Leighton2011-05-311-20/+14
|
* supporting infinity and -infinity for timestamps in PG. fixes #544Aaron Patterson2011-05-131-0/+26
|
* Added new #update_column method.Sebastian Martinez2011-03-271-1/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Revert "Removed #update_attribute method. New #update_column method."Sebastian Martinez2011-03-271-4/+2
| | | | | | This reverts commit 45c233ef819dc7b67e259dd73f24721fec28b8c8. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removed #update_attribute method. New #update_column method.Sebastian Martinez2011-03-261-2/+4
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Implement and test private method all_timestamp_attributes_in_modelFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Test timestamp_attributes_for_update_in_model that was already in placeFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Added timestamp_attributes_for_create_in_modelFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Test private method all_timestamp_attributesFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Test private method timestamp_attributes_for_updateFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Test private method timestamp_attributes_for_createFranck Verrot2011-02-021-0/+5
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* removing many unused variablesAaron Patterson2010-11-161-1/+1
|
* restore behavior of touch for models without :updated_xx [#5439 state:resolved]tnp2010-09-241-5/+13
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* @user.touch should not fail if User does not have updated_at/updated_on column.Neeraj Singh2010-08-241-1/+7
| | | | | | [#5439 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Add test case for ActiveRecord::Base.record_timestamps = falseWincent Colaiuta2010-08-241-0/+10
| | | | | | | | This is a failing test case for Lighthouse ticket #5440: https://rails.lighthouseapp.com/projects/8994/tickets/5440 Signed-off-by: José Valim <jose.valim@gmail.com>
* Restore pet -> owner relationship to the previous stateSantiago Pastorino2010-08-161-1/+1
| | | | [#5365]