From 08e781569aea7f0e084c169c70b452e337aa1b5f Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 25 Feb 2017 16:33:06 -0600 Subject: Deprecate AbstractAdapter#verify! with arguments --- activerecord/test/cases/adapters/mysql2/connection_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index bae283a048..20f1b77f31 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -63,6 +63,18 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase assert @connection.active? end + def test_verify_with_args_is_deprecated + assert_deprecated do + @connection.verify!(option: true) + end + assert_deprecated do + @connection.verify!([]) + end + assert_deprecated do + @connection.verify!({}) + end + end + def test_execute_after_disconnect @connection.disconnect! -- cgit v1.2.3 From cb3270cf4e13cfb6ba554e0fa52402657c51d171 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 25 Feb 2017 19:44:42 -0600 Subject: Use ensure block for things we cleanup in tests --- activerecord/test/cases/adapters/mysql2/connection_test.rb | 2 +- activerecord/test/cases/adapters/postgresql/connection_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/adapters/mysql2/connection_test.rb b/activerecord/test/cases/adapters/mysql2/connection_test.rb index bae283a048..58bf3003b8 100644 --- a/activerecord/test/cases/adapters/mysql2/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql2/connection_test.rb @@ -42,7 +42,7 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase @connection.update("set @@wait_timeout=1") sleep 2 assert !@connection.active? - + ensure # Repair all fixture connections so other tests won't break. @fixture_connections.each(&:verify!) end diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb index 3cbd4ca212..98d392f25a 100644 --- a/activerecord/test/cases/adapters/postgresql/connection_test.rb +++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb @@ -178,6 +178,7 @@ module ActiveRecord "umm -- looks like you didn't break the connection, because we're still " \ "successfully querying with the same connection pid." + ensure # Repair all fixture connections so other tests won't break. @fixture_connections.each(&:verify!) end -- cgit v1.2.3 From c92757fb68f5a281be0f2ea67e369672e9c4ec6d Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 22 Sep 2016 21:22:14 +0900 Subject: Fix `change_column` to drop default with `null: false` Currently `change_column` cannot drop default if `null: false` is specified at the same time. This change fixes the issue. ```ruby # cannot drop default change_column "tests", "contributor", :boolean, default: nil, null: false # we need the following workaround currently change_column "tests", "contributor", :boolean, null: false change_column "tests", "contributor", :boolean, default: nil ``` Closes #26582 --- activerecord/test/cases/migration/columns_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/migration/columns_test.rb b/activerecord/test/cases/migration/columns_test.rb index 55c06da411..2329888345 100644 --- a/activerecord/test/cases/migration/columns_test.rb +++ b/activerecord/test/cases/migration/columns_test.rb @@ -225,6 +225,16 @@ module ActiveRecord assert_nil TestModel.new.contributor end + def test_change_column_to_drop_default_with_null_false + add_column "test_models", "contributor", :boolean, default: true, null: false + assert TestModel.new.contributor? + + change_column "test_models", "contributor", :boolean, default: nil, null: false + TestModel.reset_column_information + assert_not TestModel.new.contributor? + assert_nil TestModel.new.contributor + end + def test_change_column_with_new_default add_column "test_models", "administrator", :boolean, default: true assert TestModel.new.administrator? -- cgit v1.2.3