From 7bffe1b90fb4ff104fce089b0dbc19ee04df84a9 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Thu, 27 Jun 2024 17:09:26 -0400 Subject: [PATCH] Normalize class object values to their string class name. Why is NilClass normalized to {}? That's what the test wants --- app/controllers/api/base_controller/normalizer.rb | 4 ++++ spec/requests/requests_spec.rb | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/base_controller/normalizer.rb b/app/controllers/api/base_controller/normalizer.rb index f2585e2cd8..ddefee7d15 100644 --- a/app/controllers/api/base_controller/normalizer.rb +++ b/app/controllers/api/base_controller/normalizer.rb @@ -56,6 +56,10 @@ def normalize_attr(attr, value) Float::INFINITY.to_s elsif Api.resource_attribute?(attr) normalize_resource(value) + elsif value == NilClass + {} + elsif value.kind_of?(Class) + value.name else value end diff --git a/spec/requests/requests_spec.rb b/spec/requests/requests_spec.rb index f9a20d494c..9111cc7cdd 100644 --- a/spec/requests/requests_spec.rb +++ b/spec/requests/requests_spec.rb @@ -269,8 +269,7 @@ "id" => request.id.to_s, "workflow" => a_hash_including("values"), "v_allowed_tags" => [a_hash_including("children")], - "v_workflow_class" => a_hash_including( - "instance_logger" => a_hash_including("klass" => request.workflow.class.to_s)) + "v_workflow_class" => request.workflow.class.to_s ) expect(response.parsed_body).to match(expected_response) @@ -318,7 +317,7 @@ expected_response = a_hash_including( "id" => request.id.to_s, - "v_workflow_class" => {} + "v_workflow_class" => {} # Need to figure out why NilClass comes back as {} previously ) expect(response.parsed_body).to match(expected_response)