Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

test case for #7567

  • Loading branch information...
commit 871cc97242077b056d7d572f271c2a08fed86b17 1 parent 05e9258
Yves Senn authored October 06, 2012
13  activerecord/test/cases/callbacks_test.rb
... ...
@@ -1,4 +1,6 @@
1 1
 require "cases/helper"
  2
+require "models/pet"
  3
+require "models/owner"
2 4
 
3 5
 class CallbackDeveloper < ActiveRecord::Base
4 6
   self.table_name = 'developers'
@@ -531,5 +533,16 @@ def test_inheritence_of_callbacks
531 533
     child.save
532 534
     assert child.after_save_called
533 535
   end
  536
+end
  537
+
  538
+class CallbacksTest < ActiveRecord::TestCase
  539
+  fixtures :pets, :owners
534 540
 
  541
+  def test_after_touch_callback_called_on_belongs_to
  542
+    chew = pets(:chew)
  543
+    ashley = chew.owner
  544
+    chew.updated_at = Time.now
  545
+    chew.save!
  546
+    assert_equal true, ashley.after_touch_callack_executed
  547
+  end
535 548
 end
6  activerecord/test/models/owner.rb
@@ -2,4 +2,10 @@ class Owner < ActiveRecord::Base
2 2
   self.primary_key = :owner_id
3 3
   has_many :pets
4 4
   has_many :toys, :through => :pets
  5
+
  6
+  attr_reader :after_touch_callack_executed
  7
+  after_touch :sample_after_touch_callback
  8
+  def sample_after_touch_callback
  9
+    @after_touch_callack_executed = true
  10
+  end
5 11
 end

0 notes on commit 871cc97

Please sign in to comment.
Something went wrong with that request. Please try again.