aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/fixtures_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/fixtures_test.rb')
-rw-r--r--activerecord/test/cases/fixtures_test.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index b0b63f5203..d692c0eccb 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -81,6 +81,28 @@ class FixturesTest < ActiveRecord::TestCase
end
end
+ def test_no_auto_value_on_zero_is_disabled
+ skip unless current_adapter?(:Mysql2Adapter)
+
+ begin
+ fixtures = [
+ { "name" => "first", "wheels_count" => 2 },
+ { "name" => "second", "wheels_count" => 3 }
+ ]
+ subscriber = InsertQuerySubscriber.new
+ subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
+
+ assert_nothing_raised do
+ ActiveRecord::Base.connection.insert_fixtures(fixtures, "aircraft")
+ end
+
+ expected_sql = "INSERT INTO `aircraft` (`id`, `name`, `wheels_count`) VALUES (DEFAULT, 'first', 2), (DEFAULT, 'second', 3)"
+ assert_equal expected_sql, subscriber.events.first
+ ensure
+ ActiveSupport::Notifications.unsubscribe(subscription)
+ end
+ end
+
def test_broken_yaml_exception
badyaml = Tempfile.new ["foo", ".yml"]
badyaml.write "a: : "
@@ -247,7 +269,7 @@ class FixturesTest < ActiveRecord::TestCase
def test_nonexistent_fixture_file
nonexistent_fixture_path = FIXTURES_ROOT + "/imnothere"
- #sanity check to make sure that this file never exists
+ # sanity check to make sure that this file never exists
assert Dir[nonexistent_fixture_path + "*"].empty?
assert_raise(Errno::ENOENT) do