diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 7 | ||||
-rwxr-xr-x | activerecord/test/fixtures/topic.rb | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index bf9a8a5f90..4fb7f39ecc 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -394,6 +394,13 @@ class BasicsTest < Test::Unit::TestCase assert_equal 9900, Topic.find(2).written_on.usec end end + + def test_custom_mutator + topic = Topic.find(1) + # This mutator is protected in the class definition + topic.send(:approved=, true) + assert topic.instance_variable_get("@custom_approved") + end def test_destroy topic = Topic.find(1) diff --git a/activerecord/test/fixtures/topic.rb b/activerecord/test/fixtures/topic.rb index d7cd52e33e..dd71d6bf2b 100755 --- a/activerecord/test/fixtures/topic.rb +++ b/activerecord/test/fixtures/topic.rb @@ -13,8 +13,14 @@ class Topic < ActiveRecord::Base def topic_id id end + protected + def approved=(val) + @custom_approved = val + write_attribute(:approved, val) + end + def default_written_on self.written_on = Time.now unless attribute_present?("written_on") end |