From 028d02ccca9395c801901da9233714028b387f5d Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 11 Oct 2021 14:46:36 +0100 Subject: [PATCH] Test serialized relationship data --- spec/requests/api/v1/customers_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/requests/api/v1/customers_spec.rb b/spec/requests/api/v1/customers_spec.rb index 93c233e699..5b9cab952b 100644 --- a/spec/requests/api/v1/customers_spec.rb +++ b/spec/requests/api/v1/customers_spec.rb @@ -108,6 +108,20 @@ describe "Customers", type: :request do expect(json_error_detail).to eq "The resource you were looking for could not be found." end end + + describe "related records" do + it "serializes the enterprise relationship" do + expected_enterprise_data = { + "data" => { + "id" => customer1.enterprise_id.to_s, + "type" => "enterprise" + } + } + + get "/api/v1/customers/#{customer1.id}" + expect(json_response[:data][:relationships][:enterprise]).to eq(expected_enterprise_data) + end + end end put "Update customer" do