DEV: Address review comments for 5ed84d9885.

This commit is contained in:
Guo Xiang Tan 2020-09-08 11:17:35 +08:00
parent b0f22f2523
commit d3ebaa41ce
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 4 additions and 2 deletions

View File

@ -533,7 +533,7 @@ class TopicQuery
if type == :group if type == :group
result = result result = result
.includes(:allowed_users) .includes(:allowed_users)
.joins("INNER JOIN topic_allowed_groups tag ON tag.topic_id = topics.id AND tag.group_id IN (SELECT id FROM groups WHERE name ilike '#{sanitize_sql_array([@options[:group_name]])}')") .joins("INNER JOIN topic_allowed_groups tag ON tag.topic_id = topics.id AND tag.group_id IN (SELECT id FROM groups WHERE LOWER(name) = '#{PG::Connection.escape_string(@options[:group_name].downcase)}')")
unless user.admin? unless user.admin?
result = result.joins("INNER JOIN group_users gu ON gu.group_id = tag.group_id AND gu.user_id = #{user.id.to_i}") result = result.joins("INNER JOIN group_users gu ON gu.group_id = tag.group_id AND gu.user_id = #{user.id.to_i}")

View File

@ -1157,7 +1157,9 @@ describe TopicQuery do
end end
it 'should return the right list for an admin not part of the group' do it 'should return the right list for an admin not part of the group' do
topics = TopicQuery.new(nil, group_name: group.name) group.update!(name: group.name.capitalize)
topics = TopicQuery.new(nil, group_name: group.name.upcase)
.list_private_messages_group(Fabricate(:admin)) .list_private_messages_group(Fabricate(:admin))
.topics .topics