FIX: Hide message button for current user if can't message (#27672)
Hide message button for current user if can't message
This commit is contained in:
parent
0acd6bea4c
commit
7b94cfcb1e
|
@ -147,7 +147,7 @@ class UserCardSerializer < BasicUserSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_send_private_message_to_user
|
def can_send_private_message_to_user
|
||||||
scope.can_send_private_message?(object) || scope.current_user == object
|
scope.can_send_private_message?(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_suspend_reason?
|
def include_suspend_reason?
|
||||||
|
|
|
@ -66,8 +66,20 @@ RSpec.describe UserCardSerializer do
|
||||||
expect(json[:pending_posts_count]).to eq 0
|
expect(json[:pending_posts_count]).to eq 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can_send_private_message_to_user is true" do
|
context "when the user is in a group with PMs enabled" do
|
||||||
expect(json[:can_send_private_message_to_user]).to eq true
|
before { SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:everyone] }
|
||||||
|
|
||||||
|
it "can_send_private_message_to_user is true" do
|
||||||
|
expect(json[:can_send_private_message_to_user]).to eq true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when the user is not in a group with PMs enabled" do
|
||||||
|
before { SiteSetting.personal_message_enabled_groups = Group::AUTO_GROUPS[:moderators] }
|
||||||
|
|
||||||
|
it "can_send_private_message_to_user is false" do
|
||||||
|
expect(json[:can_send_private_message_to_user]).to eq false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue