UX: hide warning if all users mentioned via group are already invited. (#23557)

Previously, a "`some_not_allowed`" warning message was appeared in composer even when all the users mentioned via group are already invited to the private message directly or via other groups.
This commit is contained in:
Vinoth Kannan 2023-09-13 19:21:44 +05:30 committed by GitHub
parent 7f7e7fe516
commit e4849445ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -65,10 +65,14 @@ class ComposerController < ApplicationController
.count
if notified_count > 0
if notified_count == group.user_count
group_reasons.delete(group.name)
else
group_reasons[group.name] = :some_not_allowed
serialized_group[:notified_count] = notified_count
end
end
end
hash[group.name] = serialized_group
hash

View File

@ -185,7 +185,6 @@ RSpec.describe ComposerController do
other_group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:everyone])
other_group.add(allowed_user)
other_group.add(user)
other_group.add(Fabricate(:user))
# Trying to mention other_group which has not been invited, but two of
# its members have been (allowed_user directly and user via group).
@ -193,6 +192,15 @@ RSpec.describe ComposerController do
expect(response.status).to eq(200)
expect(response.parsed_body["groups"]).to eq(other_group.name => { "user_count" => 2 })
expect(response.parsed_body["group_reasons"]).to be_empty
other_group.add(Fabricate(:user))
get "/composer/mentions.json", params: { names: [other_group.name], topic_id: topic.id }
expect(response.status).to eq(200)
expect(response.parsed_body["groups"]).to eq(
other_group.name => {
"user_count" => 3,