Add `memorial` attribute to REST API (#23591)
This commit is contained in:
parent
520c73c12f
commit
66f715550e
|
@ -16,6 +16,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
attribute :silenced, key: :limited, if: :silenced?
|
attribute :silenced, key: :limited, if: :silenced?
|
||||||
attribute :noindex, if: :local?
|
attribute :noindex, if: :local?
|
||||||
|
|
||||||
|
attribute :memorial, if: :memorial?
|
||||||
|
|
||||||
class AccountDecorator < SimpleDelegator
|
class AccountDecorator < SimpleDelegator
|
||||||
def self.model_name
|
def self.model_name
|
||||||
Account.model_name
|
Account.model_name
|
||||||
|
@ -124,6 +126,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
object.silenced?
|
object.silenced?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def memorial
|
||||||
|
object.memorial?
|
||||||
|
end
|
||||||
|
|
||||||
def roles
|
def roles
|
||||||
if object.suspended? || object.user.nil?
|
if object.suspended? || object.user.nil?
|
||||||
[]
|
[]
|
||||||
|
@ -136,7 +142,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
object.user_prefers_noindex?
|
object.user_prefers_noindex?
|
||||||
end
|
end
|
||||||
|
|
||||||
delegate :suspended?, :silenced?, :local?, to: :object
|
delegate :suspended?, :silenced?, :local?, :memorial?, to: :object
|
||||||
|
|
||||||
def moved_and_not_nested?
|
def moved_and_not_nested?
|
||||||
object.moved?
|
object.moved?
|
||||||
|
|
|
@ -34,4 +34,14 @@ describe REST::AccountSerializer do
|
||||||
expect(subject['roles']).to eq []
|
expect(subject['roles']).to eq []
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue