diff --git a/app/controllers/composer_controller.rb b/app/controllers/composer_controller.rb index d87441a5615..d8bc8625186 100644 --- a/app/controllers/composer_controller.rb +++ b/app/controllers/composer_controller.rb @@ -65,8 +65,12 @@ class ComposerController < ApplicationController .count if notified_count > 0 - group_reasons[group.name] = :some_not_allowed - serialized_group[:notified_count] = notified_count + 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 diff --git a/spec/requests/composer_controller_spec.rb b/spec/requests/composer_controller_spec.rb index 76297223d5c..3e85ca1098c 100644 --- a/spec/requests/composer_controller_spec.rb +++ b/spec/requests/composer_controller_spec.rb @@ -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,