From 66f715550e575129e5d8b093a15aa67527136bd2 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 14 Feb 2023 13:50:55 +0100 Subject: [PATCH] Add `memorial` attribute to REST API (#23591) --- app/serializers/rest/account_serializer.rb | 8 +++++++- spec/serializers/rest/account_serializer_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index f6fad9fe1..2845470be 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -16,6 +16,8 @@ class REST::AccountSerializer < ActiveModel::Serializer attribute :silenced, key: :limited, if: :silenced? attribute :noindex, if: :local? + attribute :memorial, if: :memorial? + class AccountDecorator < SimpleDelegator def self.model_name Account.model_name @@ -124,6 +126,10 @@ class REST::AccountSerializer < ActiveModel::Serializer object.silenced? end + def memorial + object.memorial? + end + def roles if object.suspended? || object.user.nil? [] @@ -136,7 +142,7 @@ class REST::AccountSerializer < ActiveModel::Serializer object.user_prefers_noindex? end - delegate :suspended?, :silenced?, :local?, to: :object + delegate :suspended?, :silenced?, :local?, :memorial?, to: :object def moved_and_not_nested? object.moved? diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index ce29df3a7..5b08d5aca 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -34,4 +34,14 @@ describe REST::AccountSerializer do expect(subject['roles']).to eq [] end end + + context 'when the account is memorialized' do + before do + account.memorialize! + end + + it 'marks it as such' do + expect(subject['memorial']).to be true + end + end end