Commit 8ab42500b4d1b6cfa78a0b0f5c19331eb815267c

Authored by Andrew Kane
1 parent 3bb0f7b3

Better test [skip ci]

Showing 1 changed file with 8 additions and 4 deletions   Show diff stats
test/where_test.rb
@@ -67,10 +67,6 @@ class WhereTest < Minitest::Test @@ -67,10 +67,6 @@ class WhereTest < Minitest::Test
67 assert_search "product", ["Product B", "Product C"], where: {user_ids: {not: [2], in: [1, 3]}} 67 assert_search "product", ["Product B", "Product C"], where: {user_ids: {not: [2], in: [1, 3]}}
68 assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}} 68 assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}}
69 69
70 - # exists  
71 - assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {exists: true}}  
72 - assert_search "product", ["Product A", "Product B", "Product C", "Product D"], where: {store_id: {exists: true}}  
73 -  
74 # not 70 # not
75 assert_search "product", ["Product D"], where: {user_ids: nil} 71 assert_search "product", ["Product D"], where: {user_ids: nil}
76 assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {not: nil}} 72 assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {not: nil}}
@@ -124,6 +120,14 @@ class WhereTest < Minitest::Test @@ -124,6 +120,14 @@ class WhereTest < Minitest::Test
124 assert_search "*", ["Product A", "Product B"], where: {name: {prefix: "Pro"}} 120 assert_search "*", ["Product A", "Product B"], where: {name: {prefix: "Pro"}}
125 end 121 end
126 122
  123 + def test_exists
  124 + store [
  125 + {name: "Product A", user_ids: [1, 2]},
  126 + {name: "Product B"}
  127 + ]
  128 + assert_search "product", ["Product A"], where: {user_ids: {exists: true}}
  129 + end
  130 +
127 def test_where_string 131 def test_where_string
128 store [ 132 store [
129 {name: "Product A", color: "RED"} 133 {name: "Product A", color: "RED"}