mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
FIX: list_suggested_for conditional for personal_message_enabled_groups (#18373)
Follow-up to e62e93f83a
,
misplaced a bracket and changed the meaning of the conditional.
This commit is contained in:
parent
ab58b0cffe
commit
7152345ee7
|
@ -205,7 +205,10 @@ class TopicQuery
|
|||
# Don't suggest messages unless we have a user, and private messages are
|
||||
# enabled.
|
||||
if topic.private_message? && (
|
||||
@user.blank? || !@user.in_any_groups?(SiteSetting.personal_message_enabled_groups_map || !SiteSetting.enable_personal_messages))
|
||||
@user.blank? ||
|
||||
!@user.in_any_groups?(SiteSetting.personal_message_enabled_groups_map) ||
|
||||
!SiteSetting.enable_personal_messages
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -1157,7 +1157,7 @@ RSpec.describe TopicQuery do
|
|||
|
||||
context 'when logged in' do
|
||||
def suggested_for(topic)
|
||||
topic_query.list_suggested_for(topic).topics.map { |t| t.id }
|
||||
topic_query.list_suggested_for(topic)&.topics&.map { |t| t.id }
|
||||
end
|
||||
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
@ -1260,6 +1260,16 @@ RSpec.describe TopicQuery do
|
|||
it 'should return the group topics' do
|
||||
expect(suggested_topics).to match_array([private_group_topic.id, private_message.id])
|
||||
end
|
||||
|
||||
context "when enable_personal_messages is false" do
|
||||
before do
|
||||
SiteSetting.enable_personal_messages = false
|
||||
end
|
||||
|
||||
it 'should not return topics by the group user' do
|
||||
expect(suggested_topics).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with tag filter" do
|
||||
|
|
|
@ -132,6 +132,11 @@ RSpec.describe TopicViewSerializer do
|
|||
end
|
||||
|
||||
describe 'with private messages' do
|
||||
before do
|
||||
SiteSetting.enable_personal_messages = true
|
||||
Group.refresh_automatic_groups!
|
||||
end
|
||||
|
||||
fab!(:topic) do
|
||||
Fabricate(:private_message_topic,
|
||||
highest_post_number: 1,
|
||||
|
|
Loading…
Reference in New Issue
Block a user