Skip to content

Commit

Permalink
Present social media accounts to publishing API
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHallam committed Dec 11, 2024
1 parent 5c90304 commit 152258b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/editionable_topical_event.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class EditionableTopicalEvent < Edition
include Edition::SocialMediaAccounts

def display_type_key
"editionable_topical_event"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,22 @@ def links
{}
end

private

def details
{}
{}.tap do |details|
details[:social_media_links] = social_media_links
end
end

def social_media_links
item.social_media_accounts.map do |social_media_account|
{
href: social_media_account.url,
service_type: social_media_account.service_name.parameterize,
title: social_media_account.display_name,
}
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ def present(...)
end

test "presents a Topical Event ready for adding to the publishing API" do
topical_event = create(:editionable_topical_event)
topical_event = create(:editionable_topical_event,
:with_social_media_account)

public_path = topical_event.public_path

expected_details = {
social_media_links: [
{
href: topical_event.social_media_accounts.first.url,
service_type: topical_event.social_media_accounts.first.service_name.parameterize,
title: topical_event.social_media_accounts.first.display_name,
},
],
}

expected_hash = {
base_path: public_path,
title: topical_event.title,
Expand All @@ -22,7 +33,7 @@ def present(...)
public_updated_at: topical_event.updated_at,
routes: [{ path: public_path, type: "exact" }],
redirects: [],
details: {},
details: expected_details,
update_type: "major",
}

Expand Down

0 comments on commit 152258b

Please sign in to comment.