Skip to content

Commit a8df5dc

Browse files
committed
Split missing derived id cases into separate specs
1 parent 129c144 commit a8df5dc

1 file changed

Lines changed: 40 additions & 12 deletions

File tree

  • elasticgraph-indexer/spec/unit/elastic_graph/indexer/operation

‎elasticgraph-indexer/spec/unit/elastic_graph/indexer/operation/update_spec.rb‎

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,30 +161,58 @@ module Operation
161161
]
162162
end
163163

164-
it "returns no datastore bulk actions if the source document omits or nulls the id field of the update target" do
164+
it "returns no datastore bulk actions if the source document omits the id field of the update target" do
165165
indexer = indexer_with_widget_workspace_index_definition do |index|
166166
# no customization
167167
end
168+
record = event.record.except("workspace_id")
168169

169-
[event.record.except("workspace_id"), event.record.merge("workspace_id" => nil)].each do |record|
170-
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
170+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
171+
end
172+
173+
it "returns no datastore bulk actions if the source document nulls the id field of the update target" do
174+
indexer = indexer_with_widget_workspace_index_definition do |index|
175+
# no customization
171176
end
177+
record = event.record.merge("workspace_id" => nil)
178+
179+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
172180
end
173181

174-
it "returns no datastore bulk actions if a nested id's parent or leaf is absent or null" do
182+
it "returns no datastore bulk actions if a nested id's parent is absent" do
175183
indexer = indexer_with_widget_workspace_index_definition(id_source: "embedded_values.workspace_id") do |index|
176184
# no customization
177185
end
178-
records = [
179-
event.record.except("embedded_values"),
180-
event.record.merge("embedded_values" => nil),
181-
event.record.merge("embedded_values" => {"name" => "embedded_name"}),
182-
event.record.merge("embedded_values" => {"workspace_id" => nil})
183-
]
186+
record = event.record.except("embedded_values")
184187

185-
records.each do |record|
186-
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
188+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
189+
end
190+
191+
it "returns no datastore bulk actions if a nested id's parent is null" do
192+
indexer = indexer_with_widget_workspace_index_definition(id_source: "embedded_values.workspace_id") do |index|
193+
# no customization
187194
end
195+
record = event.record.merge("embedded_values" => nil)
196+
197+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
198+
end
199+
200+
it "returns no datastore bulk actions if a nested id's leaf is absent" do
201+
indexer = indexer_with_widget_workspace_index_definition(id_source: "embedded_values.workspace_id") do |index|
202+
# no customization
203+
end
204+
record = event.record.merge("embedded_values" => {"name" => "embedded_name"})
205+
206+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
207+
end
208+
209+
it "returns no datastore bulk actions if a nested id's leaf is null" do
210+
indexer = indexer_with_widget_workspace_index_definition(id_source: "embedded_values.workspace_id") do |index|
211+
# no customization
212+
end
213+
record = event.record.merge("embedded_values" => {"workspace_id" => nil})
214+
215+
expect(operations_for_indexer(indexer, event: event.with(record: record))).to eq []
188216
end
189217

190218
it "still raises if a nested id's parent has a malformed non-object shape" do

0 commit comments

Comments
 (0)