Skip to content

Commit 104f91f

Browse files
dwkoogtkarmi
authored andcommittedMay 7, 2014
[MODEL] Added tests for each_with_hit and map_with_hit
These are tests for commit 83831b3. Closes elastic#99 Closes elastic#102
1 parent d3e5c8b commit 104f91f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
 

‎elasticsearch-model/test/integration/active_record_basic_test.rb

+12
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ class ::Article < ActiveRecord::Base
8181
end
8282
end
8383

84+
should "preserve the search results order for records" do
85+
response = Article.search('title:code')
86+
87+
response.records.each_with_hit do |r, h|
88+
assert_equal h._id, r.id.to_s
89+
end
90+
91+
response.records.map_with_hit do |r, h|
92+
assert_equal h._id, r.id.to_s
93+
end
94+
end
95+
8496
should "remove document from index on destroy" do
8597
article = Article.first
8698

‎elasticsearch-model/test/integration/mongoid_basic_test.rb

+12
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ def as_indexed_json(options={})
9595
end
9696
end
9797

98+
should "preserve the search results order for records" do
99+
response = MongoidArticle.search('title:code')
100+
101+
response.records.each_with_hit do |r, h|
102+
assert_equal h._id, r.id.to_s
103+
end
104+
105+
response.records.map_with_hit do |r, h|
106+
assert_equal h._id, r.id.to_s
107+
end
108+
end
109+
98110
should "remove document from index on destroy" do
99111
article = MongoidArticle.first
100112

0 commit comments

Comments
 (0)