FEATURE: add user_suspended attribute in post serialize. (#16413)

This PR will include `suspended` attribute in post serializer to check it in post widget and add a CSS class name.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
Vinoth Kannan
2022-04-13 19:58:09 +05:30
committed by GitHub
parent 01107e418e
commit c863244382
6 changed files with 44 additions and 1 deletions

View File

@ -88,6 +88,26 @@ describe PostSerializer do
end
end
context "a post by a suspended user" do
def subject
PostSerializer.new(post, scope: Guardian.new(Fabricate(:admin)), root: false).as_json
end
it "serializes correctly" do
expect(subject[:user_suspended]).to be_nil
post.user.update!(
suspended_till: 1.month.from_now,
)
expect(subject[:user_suspended]).to eq(true)
freeze_time (2.months.from_now)
expect(subject[:user_suspended]).to be_nil
end
end
context "display_username" do
let(:user) { post.user }
let(:serializer) { PostSerializer.new(post, scope: Guardian.new, root: false) }