Commit 7fd8de80376e5f33bfda7605ce90025be2c83c99
1 parent
2ed568b3
Exists in
master
and in
21 other branches
Added test for nested objects
Showing
2 changed files
with
14 additions
and
2 deletions
Show diff stats
test/sql_test.rb
... | ... | @@ -292,6 +292,12 @@ class TestSql < Minitest::Unit::TestCase |
292 | 292 | assert_equal [1, 2], result.user_ids |
293 | 293 | end |
294 | 294 | |
295 | + def test_nested_object | |
296 | + aisle = {"id" => 1, "name" => "Frozen"} | |
297 | + store [{name: "Product A", aisle: aisle}] | |
298 | + assert_equal aisle, Product.search("product", load: false).first.aisle.to_hash | |
299 | + end | |
300 | + | |
295 | 301 | # TODO see if Mongoid is loaded |
296 | 302 | if !defined?(Mongoid) |
297 | 303 | def test_include | ... | ... |
test/test_helper.rb
... | ... | @@ -121,10 +121,16 @@ class Product |
121 | 121 | word_middle: [:name], |
122 | 122 | word_end: [:name] |
123 | 123 | |
124 | - attr_accessor :conversions, :user_ids | |
124 | + attr_accessor :conversions, :user_ids, :aisle | |
125 | 125 | |
126 | 126 | def search_data |
127 | - serializable_hash.except("id").merge conversions: conversions, user_ids: user_ids, location: [latitude, longitude], multiple_locations: [[latitude, longitude], [0, 0]] | |
127 | + serializable_hash.except("id").merge( | |
128 | + conversions: conversions, | |
129 | + user_ids: user_ids, | |
130 | + location: [latitude, longitude], | |
131 | + multiple_locations: [[latitude, longitude], [0, 0]], | |
132 | + aisle: aisle | |
133 | + ) | |
128 | 134 | end |
129 | 135 | |
130 | 136 | def should_index? | ... | ... |