Skip to content

Commit c9e3676

Browse files
committed
Improved smart_aggs test [skip ci]
1 parent e80c26f commit c9e3676

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/aggs_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def test_smart_aggs_agg_where
213213
assert_aggs ({"store_id" => {2 => 2}}), where: {_script: Searchkick.script("doc['color'].value == 'red'")}, aggs: {store_id: {where: {_script: Searchkick.script("!doc['in_stock'].value")}}}, smart_aggs: false
214214
end
215215

216+
# only basic conditions are overridden (the rest are additive)
216217
def test_smart_aggs_agg_where_overlap
217218
assert_aggs ({"store_id" => {}}), where: {color: "red"}, aggs: {store_id: {where: {in_stock: false, color: "blue"}}}
218219
assert_aggs ({"store_id" => {}}), where: {color: "red"}, aggs: {store_id: {where: {in_stock: false, color: "blue"}}}, smart_aggs: false
@@ -222,6 +223,9 @@ def test_smart_aggs_agg_where_overlap
222223

223224
assert_aggs ({"store_id" => {2 => 1}}), where: {color: "blue"}, aggs: {store_id: {where: {in_stock: false, "color" => "red"}}}
224225
assert_aggs ({"store_id" => {2 => 1}}), where: {"color" => "blue"}, aggs: {store_id: {where: {in_stock: false, color: "red"}}}
226+
227+
assert_aggs ({"store_id" => {}}), where: {_and: [{color: "blue"}]}, aggs: {store_id: {where: {in_stock: false, color: "red"}}}
228+
assert_aggs ({"store_id" => {2 => 1}}), where: {_and: [{color: "blue"}]}, aggs: {store_id: {where: {in_stock: false, color: "red"}}}, smart_aggs: false
225229
end
226230

227231
def test_smart_aggs_relation

0 commit comments

Comments
 (0)