diff options
author | wangjohn <wangjohn@mit.edu> | 2013-02-18 20:07:05 -0500 |
---|---|---|
committer | wangjohn <wangjohn@mit.edu> | 2013-02-25 00:29:28 -0500 |
commit | e52ff809606323f7370cfaf6e63b083f9b108d6c (patch) | |
tree | 21e150731afe39e38803ae2339febed32f4f1532 /activerecord/test/cases | |
parent | 3762ee0baa2285bdc4a76d4d492fbe34a10cdc3a (diff) | |
download | rails-e52ff809606323f7370cfaf6e63b083f9b108d6c.tar.gz rails-e52ff809606323f7370cfaf6e63b083f9b108d6c.tar.bz2 rails-e52ff809606323f7370cfaf6e63b083f9b108d6c.zip |
Raising an ActiveRecordError when one tries to use .touch(name) on a new
object that has not yet been persisted. This behavior follows the
precedent set by update_columns.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index fbc66540d6..af1845c937 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1447,6 +1447,13 @@ class BasicsTest < ActiveRecord::TestCase assert_match(/\/#{dev.id}$/, dev.cache_key) end + def test_touch_should_raise_error_on_a_new_object + company = Company.new(:rating => 1, :name => "37signals", :firm_name => "37signals") + assert_raises(ActiveRecord::ActiveRecordError) do + company.touch :updated_at + end + end + def test_cache_key_format_is_precise_enough dev = Developer.first key = dev.cache_key |