From 806863a6e39d495e94e84c2116dd39d7f8d3bb1a Mon Sep 17 00:00:00 2001 From: Patrick Cartlidge Date: Tue, 8 Aug 2023 12:10:44 +0100 Subject: [PATCH] Add spacing to WorldWideOrganisation descriptions Fixes an issue where the description of people that was being generated by the WorldWideOrganisationPresenter was not adding spacing between multiple roles. Fixed the issue and added test cases. --- app/presenters/worldwide_organisation_presenter.rb | 4 ++-- .../worldwide_organisation_presenter_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/presenters/worldwide_organisation_presenter.rb b/app/presenters/worldwide_organisation_presenter.rb index ff2ab21f9..14d8fa291 100644 --- a/app/presenters/worldwide_organisation_presenter.rb +++ b/app/presenters/worldwide_organisation_presenter.rb @@ -51,7 +51,7 @@ def person_in_primary_role href: person["web_url"], image_url: person["details"]["image"]["url"], image_alt: person["details"]["image"]["alt_text"], - description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join, + description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join(", "), } end @@ -67,7 +67,7 @@ def people_in_non_primary_roles { name: person["title"], href: person["web_url"], - description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join, + description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join(", "), } end end diff --git a/test/presenters/worldwide_organisation_presenter_test.rb b/test/presenters/worldwide_organisation_presenter_test.rb index 3a275b5d0..6a2e91222 100644 --- a/test/presenters/worldwide_organisation_presenter_test.rb +++ b/test/presenters/worldwide_organisation_presenter_test.rb @@ -5,6 +5,16 @@ def schema_name "worldwide_organisation" end + test "description of primary_role_person should have spaces between roles" do + presenter = create_presenter(WorldwideOrganisationPresenter, content_item: { "links" => { "primary_role_person" => [{ "details" => { "image" => {} }, "links" => { "role_appointments" => [{ "details" => { "current" => true }, "links" => { "role" => [{ "title" => "Example Role 1" }] } }, { "details" => { "current" => true }, "links" => { "role" => [{ "title" => "Example Role 2" }] } }] } }] } }) + assert_equal "Example Role 1, Example Role 2", presenter.person_in_primary_role[:description] + end + + test "description of people_in_non_primary_roles should have spaces between roles" do + presenter = create_presenter(WorldwideOrganisationPresenter, content_item: { "links" => { "secondary_role_person" => [{ "details" => { "image" => {} }, "links" => { "role_appointments" => [{ "details" => { "current" => true }, "links" => { "role" => [{ "title" => "Example Role 1" }] } }, { "details" => { "current" => true }, "links" => { "role" => [{ "title" => "Example Role 2" }] } }] } }] } }) + assert_equal "Example Role 1, Example Role 2", presenter.people_in_non_primary_roles.first[:description] + end + test "#title returns the title" do assert_equal schema_item["title"], presented_item.title end