FIX: serialize can_ignore_users (#25672)

Bug introduced in this PR https://github.com/discourse/discourse/pull/25585/files#diff-55dea7dea5b8655da575a2f23156240686c956d081d36ea9976d38b29b72b5d2R130

`can_ignore_users` method was created but not added to attributes and therefore it was not serialized.
This commit is contained in:
Krzysztof Kotlarek 2024-02-14 15:17:19 +11:00 committed by GitHub
parent 709bed5d1c
commit c03d22f633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class CurrentUserSerializer < BasicUserSerializer
:no_password,
:can_delete_account,
:can_post_anonymously,
:can_ignore_users,
:custom_fields,
:muted_category_ids,
:indirectly_muted_category_ids,

View File

@ -150,6 +150,27 @@ RSpec.describe CurrentUserSerializer do
end
end
describe "#can_ignore_users" do
let(:guardian) { Guardian.new(user) }
let(:payload) { serializer.as_json }
context "when user is a regular one" do
let(:user) { Fabricate(:user) }
it "return false for regular users" do
expect(payload[:can_ignore_users]).to eq(false)
end
end
context "when user is a staff member" do
let(:user) { Fabricate(:moderator) }
it "returns true" do
expect(payload[:can_ignore_users]).to eq(true)
end
end
end
describe "#can_review" do
let(:guardian) { Guardian.new(user) }
let(:payload) { serializer.as_json }