diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/base_test.rb | 4 | ||||
-rwxr-xr-x | activerecord/test/fixtures/topic.rb | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 650d87f91f..5e20cbe127 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -1008,6 +1008,10 @@ class BasicsTest < Test::Unit::TestCase cloned_topic.title["a"] = "c" assert_equal "b", topic.title["a"] + #test if attributes set as part of after_initialize are cloned correctly + assert_equal topic.author_email_address, cloned_topic.author_email_address + + # test if saved clone object differs from original cloned_topic.save assert !cloned_topic.new_record? assert cloned_topic.id != topic.id diff --git a/activerecord/test/fixtures/topic.rb b/activerecord/test/fixtures/topic.rb index dd71d6bf2b..b2541c8640 100755 --- a/activerecord/test/fixtures/topic.rb +++ b/activerecord/test/fixtures/topic.rb @@ -28,4 +28,10 @@ class Topic < ActiveRecord::Base def destroy_children self.class.delete_all "parent_id = #{id}" end -end + + def after_initialize + if self.new_record? + self.author_email_address = 'test@test.com' + end + end +end
\ No newline at end of file |