Methods
- T
-
- test_dup,
- test_dup_after_initialize_callbacks,
- test_dup_attributes_are_independent,
- test_dup_has_no_id,
- test_dup_not_destroyed,
- test_dup_not_persisted,
- test_dup_timestamps_are_cleared,
- test_dup_topics_are_independent,
- test_dup_validity_is_independent,
- test_dup_with_changes,
- test_dup_with_default_scope,
- test_dup_with_modified_attributes,
- test_dup_without_primary_key,
- test_is_readonly,
- test_not_readonly
Instance Public methods
test_dup()
Link
test_dup_after_initialize_callbacks()
Link
test_dup_attributes_are_independent()
Link
test_dup_has_no_id()
Link
test_dup_not_destroyed()
Link
test_dup_not_persisted()
Link
test_dup_timestamps_are_cleared()
Link
# File activerecord/test/cases/dup_test.rb, line 93 def test_dup_timestamps_are_cleared topic = Topic.first assert_not_nil topic.updated_at assert_not_nil topic.created_at # temporary change to the topic object topic.updated_at -= 3.days #dup should not preserve the timestamps if present new_topic = topic.dup assert_nil new_topic.updated_at assert_nil new_topic.created_at new_topic.save assert_not_nil new_topic.updated_at assert_not_nil new_topic.created_at end
test_dup_topics_are_independent()
Link
test_dup_validity_is_independent()
Link
# File activerecord/test/cases/dup_test.rb, line 119 def test_dup_validity_is_independent repair_validations(Topic) do Topic.validates_presence_of :title topic = Topic.new("title" => "Literature") topic.valid? duped = topic.dup duped.title = nil assert duped.invalid? topic.title = nil duped.title = 'Mathematics' assert topic.invalid? assert duped.valid? end end
test_dup_with_changes()
Link
# File activerecord/test/cases/dup_test.rb, line 57 def test_dup_with_changes dbtopic = Topic.first topic = Topic.new topic.attributes = dbtopic.attributes.except("id") #duped has no timestamp values duped = dbtopic.dup #clear topic timestamp values topic.send(:clear_timestamp_attributes) assert_equal topic.changes, duped.changes end
test_dup_with_default_scope()
Link
# File activerecord/test/cases/dup_test.rb, line 136 def test_dup_with_default_scope prev_default_scopes = Topic.default_scopes Topic.default_scopes = [proc { Topic.where(:approved => true) }] topic = Topic.new(:approved => false) assert !topic.dup.approved?, "should not be overridden by default scopes" ensure Topic.default_scopes = prev_default_scopes end
test_dup_with_modified_attributes()
Link
test_dup_without_primary_key()
Link
test_is_readonly()
Link