Commit 393aac2c by Esteban Pastorino Committed by Tute Costa

Compare to ActiveRecord::VERSION instead of shelling out

`bundle exec rails -v` was taking seconds every time, making the test
suite run very slow. This changes the code to compare the version
against `ActiveRecord::VERSION`, which is going to be the same one as
`rails -v`, making it much, much faster.

Simplifies condition: we no longer support Rails < 4.2, so we test for
`>= "5.0"` or fallback to `4.2` branch.
parent caa7c22b
......@@ -12,10 +12,10 @@ module ModelReconstruction
klass.connection_pool.clear_table_cache!(klass.table_name) if klass.connection_pool.respond_to?(:clear_table_cache!)
if klass.connection.respond_to?(:schema_cache)
if `bundle exec rails -v`.include?("4.2")
klass.connection.schema_cache.clear_table_cache!(klass.table_name)
elsif `bundle exec rails -v`.include?("5.0")
if ActiveRecord::VERSION::STRING >= "5.0"
klass.connection.schema_cache.clear_data_source_cache!(klass.table_name)
else
klass.connection.schema_cache.clear_table_cache!(klass.table_name)
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment