aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-04-23 13:37:19 -0500
committerYves Senn <yves.senn@gmail.com>2014-04-23 13:37:19 -0500
commit32cdc032c30dad13931b6ce800d740a72872dabd (patch)
tree1364e6e39857cc7459d60af1bdcfbe765fb32437 /activerecord/test/cases
parente20114006ac086241c886203fa0087567c8fef79 (diff)
parent4866399054c9facf11bc743c0e0969e6c81f6c31 (diff)
downloadrails-32cdc032c30dad13931b6ce800d740a72872dabd.tar.gz
rails-32cdc032c30dad13931b6ce800d740a72872dabd.tar.bz2
rails-32cdc032c30dad13931b6ce800d740a72872dabd.zip
Merge pull request #14842 from lucasmazza/lm-no-touching-callbacks
Move `NoTouching` down the inheritance chain on AR::Base
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/timestamp_test.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index 594b4fb07b..77ab427be0 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -112,7 +112,7 @@ class TimestampTest < ActiveRecord::TestCase
previous_starting = task.starting
previous_ending = task.ending
task.touch(:starting, :ending)
-
+
assert_not_equal previous_starting, task.starting
assert_not_equal previous_ending, task.ending
assert_in_delta Time.now, task.starting, 1
@@ -170,6 +170,25 @@ class TimestampTest < ActiveRecord::TestCase
assert !@developer.no_touching?
end
+ def test_no_touching_with_callbacks
+ klass = Class.new(ActiveRecord::Base) do
+ self.table_name = "developers"
+
+ attr_accessor :after_touch_called
+
+ after_touch do |user|
+ user.after_touch_called = true
+ end
+ end
+
+ developer = klass.first
+
+ klass.no_touching do
+ developer.touch
+ assert_not developer.after_touch_called
+ end
+ end
+
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at
pet = Pet.first
owner = pet.owner