mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: If a group is unmentionable, don't render it as mentionable
Now if a group is visible but unmentionable, users can search for it when composing by typing with `@`, but it will be rendered without the grey background color. It will also no longer pop up a JIT warning saying "You are about to mention X people" because the group will not be mentioned.
This commit is contained in:
@@ -2402,7 +2402,10 @@ describe UsersController do
|
||||
|
||||
describe '#is_local_username' do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:group) { Fabricate(:group, name: "Discourse") }
|
||||
fab!(:group) { Fabricate(:group, name: "Discourse", mentionable_level: Group::ALIAS_LEVELS[:everyone]) }
|
||||
let(:unmentionable) {
|
||||
Fabricate(:group, name: "Unmentionable", mentionable_level: Group::ALIAS_LEVELS[:nobody])
|
||||
}
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
fab!(:allowed_user) { Fabricate(:user) }
|
||||
let(:private_topic) { Fabricate(:private_message_topic, user: allowed_user) }
|
||||
@@ -2416,11 +2419,21 @@ describe UsersController do
|
||||
end
|
||||
|
||||
it "finds the group" do
|
||||
sign_in(user)
|
||||
get "/u/is_local_username.json", params: { username: group.name }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["valid_groups"][0]).to eq(group.name)
|
||||
expect(json["valid_groups"]).to include(group.name)
|
||||
expect(json["mentionable_groups"].find { |g| g['name'] == group.name }).to be_present
|
||||
end
|
||||
|
||||
it "finds unmentionable groups" do
|
||||
sign_in(user)
|
||||
get "/u/is_local_username.json", params: { username: unmentionable.name }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json["valid_groups"]).to include(unmentionable.name)
|
||||
expect(json["mentionable_groups"]).to be_blank
|
||||
end
|
||||
|
||||
it "supports multiples usernames" do
|
||||
|
||||
Reference in New Issue
Block a user