File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
lib/elasticsearch/model/adapters Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def records
2020 #
2121 sql_records . instance_exec ( response [ 'hits' ] [ 'hits' ] ) do |hits |
2222 define_singleton_method :to_a do
23- if :: ActiveRecord . respond_to ?( :version ) && ::ActiveRecord . version . to_s > '4'
23+ if defined ?( :: ActiveRecord ) && ::ActiveRecord :: VERSION :: MAJOR >= 4
2424 self . load
2525 else
2626 self . __send__ ( :exec_queries )
@@ -47,7 +47,7 @@ def order(*args)
4747 #
4848 sql_records . instance_exec do
4949 define_singleton_method ( :to_a ) do
50- if :: ActiveRecord . respond_to ?( :version ) && ::ActiveRecord . version . to_s > '4'
50+ if defined ?( :: ActiveRecord ) && ::ActiveRecord :: VERSION :: MAJOR >= 4
5151 self . load
5252 else
5353 self . __send__ ( :exec_queries )
Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ class ActiveRecordAssociationsIntegrationTest < Elasticsearch::Test::Integration
230230
231231 assert_equal 3 , response . results . size
232232 assert_equal 3 , response . records . size
233- end if :: ActiveRecord . respond_to ?( :version ) && ::ActiveRecord . version . to_s > '4'
233+ end if defined ?( :: ActiveRecord ) && ::ActiveRecord :: VERSION :: MAJOR >= 4
234234
235235 should "reindex a document after comments are added" do
236236 # Create posts
@@ -272,7 +272,7 @@ class ActiveRecordAssociationsIntegrationTest < Elasticsearch::Test::Integration
272272 }
273273
274274 assert_equal 1 , response . results . size
275- end if :: ActiveRecord . respond_to ?( :version ) && ::ActiveRecord . version . to_s > '4'
275+ end if defined ?( :: ActiveRecord ) && ::ActiveRecord :: VERSION :: MAJOR >= 4
276276
277277 should "reindex a document after Post#touch" do
278278 # Create categories
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ class ::Article < ActiveRecord::Base
126126 should "allow ordering response.records in SQL" do
127127 response = Article . search query : { match : { title : { query : 'test' } } }
128128
129- if :: ActiveRecord . respond_to ?( :version ) && ::ActiveRecord . version . to_s > '4'
129+ if defined ?( :: ActiveRecord ) && ::ActiveRecord :: VERSION :: MAJOR >= 4
130130 assert_equal 'Testing Coding' , response . records . order ( title : :desc ) . first . title
131131 else
132132 assert_equal 'Testing Coding' , response . records . order ( 'title DESC' ) . first . title
You can’t perform that action at this time.
0 commit comments