提交 9e28f415 编写于 作者: S Sam Davies

Make tests a bit more beautiful

上级 50c53340
......@@ -64,6 +64,9 @@ def self.name; 'HotCompatibility'; end
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 @@ def self.name; 'HotCompatibility'; end
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 @@ def self.name; 'HotCompatibility'; end
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 @@ def self.name; 'HotCompatibility'; end
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 @@ def self.name; 'HotCompatibility'; end
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册