FIX: user group message route should not be case-sensitive (#12753)

This commit is contained in:
Arpit Jalan 2021-04-20 10:25:31 +05:30 committed by GitHub
parent cc7e352f30
commit af6d0342b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -153,7 +153,7 @@ class ListController < ApplicationController
end end
when :private_messages_group, :private_messages_group_archive when :private_messages_group, :private_messages_group_archive
define_method("#{action}") do define_method("#{action}") do
group = Group.find_by(name: params[:group_name]) group = Group.find_by("LOWER(name) = ?", params[:group_name].downcase)
raise Discourse::NotFound if !group raise Discourse::NotFound if !group
raise Discourse::NotFound unless guardian.can_see_group_messages?(group) raise Discourse::NotFound unless guardian.can_see_group_messages?(group)

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe ListController do RSpec.describe ListController do
fab!(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic, user: user) } fab!(:topic) { Fabricate(:topic, user: user) }
fab!(:group) { Fabricate(:group) } fab!(:group) { Fabricate(:group, name: "AwesomeGroup") }
fab!(:admin) { Fabricate(:admin) } fab!(:admin) { Fabricate(:admin) }
before do before do
@ -247,7 +247,7 @@ RSpec.describe ListController do
it 'should return the right response' do it 'should return the right response' do
topic = Fabricate(:private_message_topic, allowed_groups: [group]) topic = Fabricate(:private_message_topic, allowed_groups: [group])
get "/topics/private-messages-group/#{user.username}/#{group.name}.json" get "/topics/private-messages-group/#{user.username}/awesomegroup.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)