diff options
author | Sam Davies <seivadmas@gmail.com> | 2015-11-05 17:44:47 -0300 |
---|---|---|
committer | Sam Davies <seivadmas@gmail.com> | 2015-11-05 17:44:47 -0300 |
commit | 9e28f415f5aa52a3179d7cbef2594a0d0c03bcce (patch) | |
tree | 8a83ba8e0f3332c40662efd24b21a5c3245f9a62 /activerecord/test | |
parent | 50c53340824de2a8000fd2d5551cbce2603dc34a (diff) | |
download | rails-9e28f415f5aa52a3179d7cbef2594a0d0c03bcce.tar.gz rails-9e28f415f5aa52a3179d7cbef2594a0d0c03bcce.tar.bz2 rails-9e28f415f5aa52a3179d7cbef2594a0d0c03bcce.zip |
Make tests a bit more beautiful
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/hot_compatibility_test.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/activerecord/test/cases/hot_compatibility_test.rb b/activerecord/test/cases/hot_compatibility_test.rb index e97be4a2fc..9fc75b7377 100644 --- a/activerecord/test/cases/hot_compatibility_test.rb +++ b/activerecord/test/cases/hot_compatibility_test.rb @@ -64,6 +64,9 @@ class HotCompatibilityTest < ActiveRecord::TestCase record.reload end + assert get_prepared_statement_cache(@klass.connection).any?, + "expected prepared statement cache to have something in it" + # add a new column ddl_connection.add_column :hot_compatibilities, :baz, :string @@ -73,11 +76,7 @@ class HotCompatibilityTest < ActiveRecord::TestCase end end - prepared_statement_cache = @klass.connection - .instance_variable_get(:@statements) - .instance_variable_get(:@cache)[Process.pid] - - assert_empty prepared_statement_cache, + assert_empty get_prepared_statement_cache(@klass.connection), "expected prepared statement cache to be empty but it wasn't" end end @@ -91,6 +90,9 @@ class HotCompatibilityTest < ActiveRecord::TestCase record.reload end + assert get_prepared_statement_cache(@klass.connection).any?, + "expected prepared statement cache to have something in it" + # add a new column ddl_connection.add_column :hot_compatibilities, :baz, :string @@ -104,11 +106,7 @@ class HotCompatibilityTest < ActiveRecord::TestCase end end - prepared_statement_cache = @klass.connection - .instance_variable_get(:@statements) - .instance_variable_get(:@cache)[Process.pid] - - assert_empty prepared_statement_cache, + assert_empty get_prepared_statement_cache(@klass.connection), "expected prepared statement cache to be empty but it wasn't" end end @@ -116,6 +114,11 @@ class HotCompatibilityTest < ActiveRecord::TestCase private + def get_prepared_statement_cache(connection) + connection.instance_variable_get(:@statements) + .instance_variable_get(:@cache)[Process.pid] + end + # Rails will automatically clear the prepared statements on the connection # that runs the migration, so we use two connections to simulate what would # actually happen on a production system; we'd have one connection running the |