Finished porting over MySQL import functionality.

* removed assertions on #num_inserts, that is db-specific and is handled in details by abstract_adapter_test.
This commit is contained in:
Zach Dennis 2010-03-13 22:01:01 -05:00
parent e8271778b7
commit 075104a944
7 changed files with 123 additions and 95 deletions

View file

@ -0,0 +1,55 @@
class ActiveSupport::TestCase
module MySQLAssertions
def self.extended(klass)
klass.instance_eval do
assertion(:should_not_update_created_at_on_timestamp_columns) do
Delorean.time_travel_to("5 minutes from now") do
perform_import
assert_equal @topic.created_at.to_i, updated_topic.created_at.to_i
assert_equal @topic.created_on.to_i, updated_topic.created_on.to_i
end
end
assertion(:should_update_updated_at_on_timestamp_columns) do
time = Chronic.parse("5 minutes from now")
Delorean.time_travel_to(time) do
perform_import
assert_equal time.to_i, updated_topic.updated_at.to_i
assert_equal time.to_i, updated_topic.updated_on.to_i
end
end
assertion(:should_not_update_timestamps) do
Delorean.time_travel_to("5 minutes from now") do
perform_import :timestamps => false
assert_equal @topic.created_at.to_i, updated_topic.created_at.to_i
assert_equal @topic.created_on.to_i, updated_topic.created_on.to_i
assert_equal @topic.updated_at.to_i, updated_topic.updated_at.to_i
assert_equal @topic.updated_on.to_i, updated_topic.updated_on.to_i
end
end
assertion(:should_not_update_fields_not_mentioned) do
assert_equal "John Doe", updated_topic.author_name
end
assertion(:should_update_fields_mentioned) do
perform_import
assert_equal "Book - 2nd Edition", updated_topic.title
assert_equal "johndoe@example.com", updated_topic.author_email_address
end
assertion(:should_update_fields_mentioned_with_hash_mappings) do
perform_import
assert_equal "johndoe@example.com", updated_topic.title
assert_equal "Book - 2nd Edition", updated_topic.author_email_address
end
assertion(:should_update_foreign_keys) do
perform_import
assert_equal 57, updated_topic.parent_id
end
end
end
end
end