diff --git a/app/models/creator.rb b/app/models/creator.rb index 0b42026c5..e50fd1579 100644 --- a/app/models/creator.rb +++ b/app/models/creator.rb @@ -27,6 +27,11 @@ def self.find_param(param) find_by!(slug: param) end + def summary_html + return unless caption || notes + "
#{"
#{caption}
" if caption}#{Kramdown::Document.new(notes).to_html.rstrip if notes}
" + end + def to_activitypub_object { "@context": { @@ -41,6 +46,7 @@ def to_activitypub_object "@type": "@string" } }, + summary: summary_html, attributionDomains: [ [Rails.application.default_url_options[:host], Rails.application.default_url_options[:port]].compact.join(":") ], diff --git a/spec/factories/creator.rb b/spec/factories/creator.rb index feb70e736..930c1c3c7 100644 --- a/spec/factories/creator.rb +++ b/spec/factories/creator.rb @@ -2,5 +2,7 @@ factory :creator do sequence(:name) { |n| "Creator #{n}" } sequence(:public_id) { |n| "creator_#{n}" } + caption { Faker::Lorem.sentence } + notes { Faker::Lorem.paragraph } end end diff --git a/spec/models/creator_spec.rb b/spec/models/creator_spec.rb index 7ce8e75f8..0a9fe35b7 100644 --- a/spec/models/creator_spec.rb +++ b/spec/models/creator_spec.rb @@ -5,4 +5,26 @@ it_behaves_like "Commentable" it_behaves_like "Caber::Object" it_behaves_like "Sluggable" + + context "when generating an ActivityStreams representation" do + subject(:creator) { create(:creator) } + + let(:ap) { creator.to_activitypub_object } + + it "includes concrete type" do + expect(ap[:concreteType]).to eq "Creator" + end + + it "includes attributionDomain" do + expect(ap[:attributionDomains]).to eq ["localhost:3214"] + end + + it "includes caption in summary" do + expect(ap[:summary]).to include creator.caption + end + + it "includes notes in summary" do + expect(ap[:summary]).to include creator.notes + end + end end