diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-01-18 15:24:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-18 15:24:30 -0500 |
commit | fd04c8cbb6627ef65ea728b5026b21bd24471c18 (patch) | |
tree | 6b4138cde034af1511fdcaf143e91c3aa224edb0 /activerecord | |
parent | 5fe603ac288d4432be77cfa851e86ad66fd48d53 (diff) | |
parent | 84206ad38750840431ea0cbc490177ad61b11bfc (diff) | |
download | rails-fd04c8cbb6627ef65ea728b5026b21bd24471c18.tar.gz rails-fd04c8cbb6627ef65ea728b5026b21bd24471c18.tar.bz2 rails-fd04c8cbb6627ef65ea728b5026b21bd24471c18.zip |
Merge pull request #31663 from Edouard-chin/remove-without-sql-mode
Added a test around `NO_AUTO_VALUE_ON_ZERO`:
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 8e8a49af8e..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: : " |