File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ def initialize_dup(other)
210
210
211
211
@attributes = cloned_attributes
212
212
213
- _run_after_initialize_callbacks if respond_to? ( :_run_after_initialize_callbacks )
213
+ _run_initialize_callbacks if _initialize_callbacks . any?
214
214
215
215
@changed_attributes = { }
216
216
self . class . column_defaults . each do |attr , orig_value |
Original file line number Diff line number Diff line change @@ -99,5 +99,13 @@ def test_dup_timestamps_are_cleared
99
99
assert_not_nil new_topic . created_at
100
100
end
101
101
102
+ def test_dup_after_initialize_callbacks
103
+ topic = Topic . new
104
+ assert Topic . after_initialize_called
105
+ Topic . after_initialize_called = false
106
+ topic . dup
107
+ assert Topic . after_initialize_called
108
+ end
109
+
102
110
end
103
111
end
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ def topic_id
80
80
81
81
after_initialize :set_email_address
82
82
83
+ class_attribute :after_initialize_called
84
+ after_initialize do
85
+ self . class . after_initialize_called = true
86
+ end
87
+
83
88
def approved = ( val )
84
89
@custom_approved = val
85
90
write_attribute ( :approved , val )
You can’t perform that action at this time.
0 commit comments