diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-06-03 14:00:25 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-06-03 18:28:14 +0900 |
commit | cd64345812567cf67fc7cca740ffc211b272e9f1 (patch) | |
tree | 1c2212984e9c37cc3a5ad45f29e808c85c5c06da /activerecord/test/cases/adapters | |
parent | 88ae9bf174d583153dfd93cfe3b916dfcdd16413 (diff) | |
download | rails-cd64345812567cf67fc7cca740ffc211b272e9f1.tar.gz rails-cd64345812567cf67fc7cca740ffc211b272e9f1.tar.bz2 rails-cd64345812567cf67fc7cca740ffc211b272e9f1.zip |
Explicitly clear type map before run `test_only_reload_type_map_once_for_every_unknown_type`
Currently, the following test fails.
```
bin/test -a sqlite3_mem --seed 37473 test/cases/relation_test.rb
```
This is due to reset connection in `test_respond_to_for_non_selected_element` postprocessing.
This reset is added with #29332 for `test_only_reload_type_map_once_for_every_unknown_type`.
Since the above test expects the type map to be empty at the time of
test run, I think that it is better to empty the type map before test run.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index bfc763e1ef..b55b766d20 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -325,15 +325,18 @@ module ActiveRecord end def test_only_reload_type_map_once_for_every_unknown_type + reset_connection + connection = ActiveRecord::Base.connection + silence_warnings do assert_queries 2, ignore_none: true do - @connection.select_all "SELECT NULL::anyelement" + connection.select_all "SELECT NULL::anyelement" end assert_queries 1, ignore_none: true do - @connection.select_all "SELECT NULL::anyelement" + connection.select_all "SELECT NULL::anyelement" end assert_queries 2, ignore_none: true do - @connection.select_all "SELECT NULL::anyarray" + connection.select_all "SELECT NULL::anyarray" end end ensure @@ -341,10 +344,13 @@ module ActiveRecord end def test_only_warn_on_first_encounter_of_unknown_oid + reset_connection + connection = ActiveRecord::Base.connection + warning = capture(:stderr) { - @connection.select_all "SELECT NULL::anyelement" - @connection.select_all "SELECT NULL::anyelement" - @connection.select_all "SELECT NULL::anyelement" + connection.select_all "SELECT NULL::anyelement" + connection.select_all "SELECT NULL::anyelement" + connection.select_all "SELECT NULL::anyelement" } assert_match(/\Aunknown OID \d+: failed to recognize type of 'anyelement'\. It will be treated as String\.\n\z/, warning) ensure |