Skip to content

Commit 806863a

Browse files
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.
1 parent 8f37863 commit 806863a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/presenters/worldwide_organisation_presenter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def person_in_primary_role
5151
href: person["web_url"],
5252
image_url: person["details"]["image"]["url"],
5353
image_alt: person["details"]["image"]["alt_text"],
54-
description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join,
54+
description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join(", "),
5555
}
5656
end
5757

@@ -67,7 +67,7 @@ def people_in_non_primary_roles
6767
{
6868
name: person["title"],
6969
href: person["web_url"],
70-
description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join,
70+
description: current_roles.map { |role_app| role_app.dig("links", "role").first["title"] }.join(", "),
7171
}
7272
end
7373
end

test/presenters/worldwide_organisation_presenter_test.rb

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ def schema_name
55
"worldwide_organisation"
66
end
77

8+
test "description of primary_role_person should have spaces between roles" do
9+
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" }] } }] } }] } })
10+
assert_equal "Example Role 1, Example Role 2", presenter.person_in_primary_role[:description]
11+
end
12+
13+
test "description of people_in_non_primary_roles should have spaces between roles" do
14+
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" }] } }] } }] } })
15+
assert_equal "Example Role 1, Example Role 2", presenter.people_in_non_primary_roles.first[:description]
16+
end
17+
818
test "#title returns the title" do
919
assert_equal schema_item["title"], presented_item.title
1020
end

0 commit comments

Comments
 (0)