Parse JSON to test variant and distributor ids

We looked at the whole JSON string before and sometimes a distributor id
would match a variant id which made the test flaky.
This commit is contained in:
Maikel Linke
2023-01-24 11:51:44 +11:00
parent d37fa9fc5f
commit d18d0ef6b1

View File

@@ -18,11 +18,15 @@ describe Api::Admin::OrderCycleSerializer do
end
it "serializes the order cycle with editable_variants_for_incoming_exchanges" do
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to include order_cycle.variants.first.id.to_s
expect(serializer.editable_variants_for_incoming_exchanges.to_json).to_not include order_cycle.distributors.first.id.to_s
expect(from_json(serializer.editable_variants_for_incoming_exchanges).values.sum).to include order_cycle.variants.first.id
expect(from_json(serializer.editable_variants_for_incoming_exchanges).keys).to_not include order_cycle.distributors.first.id.to_s
end
it "serializes the order cycle with editable_variants_for_outgoing_exchanges" do
expect(serializer.editable_variants_for_outgoing_exchanges.to_json).to include order_cycle.variants.first.id.to_s
end
def from_json(serializer_result)
JSON.parse(serializer_result.to_json)
end
end