Skip to content

Commit fe393b0

Browse files
committed
[MODEL] Added integration test for chaining SQL commands on response.records
1 parent 936be78 commit fe393b0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

elasticsearch-model/test/integration/active_record_basic_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ class ::Article < ActiveRecord::Base
113113
assert_equal 'Testing Coding', response.records.first.title
114114
end
115115

116+
should "allow chaining SQL commands on response.records" do
117+
response = Article.search query: { match: { title: { query: 'test' } } }
118+
119+
assert_equal 2, response.records.size
120+
assert_equal 1, response.records.where(title: 'Test').size
121+
assert_equal 'Test', response.records.where(title: 'Test').first.title
122+
end
123+
124+
should "allow ordering response.records in SQL" do
125+
response = Article.search query: { match: { title: { query: 'test' } } }
126+
127+
assert_equal 'Testing Coding', response.records.order(title: :desc).first.title
128+
end
116129
end
117130

118131
end

0 commit comments

Comments
 (0)