mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Skip shared drafts logic if disabled (#11918)
It always showed shared drafts if no category was set. Follow-up to dd175537f3fb5f4a62a5935f65443fc9bedb37e3.
This commit is contained in:
@ -58,7 +58,7 @@ class ListController < ApplicationController
|
|||||||
|
|
||||||
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
|
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
|
||||||
|
|
||||||
if guardian.can_see_shared_draft? && @category.present?
|
if guardian.can_create_shared_draft? && @category.present?
|
||||||
if @category.id == SiteSetting.shared_drafts_category.to_i
|
if @category.id == SiteSetting.shared_drafts_category.to_i
|
||||||
# On shared drafts, show the destination category
|
# On shared drafts, show the destination category
|
||||||
list.topics.each do |t|
|
list.topics.each do |t|
|
||||||
|
@ -779,4 +779,37 @@ RSpec.describe ListController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "shared drafts" do
|
||||||
|
fab!(:category1) { Fabricate(:category) }
|
||||||
|
fab!(:category2) { Fabricate(:category) }
|
||||||
|
|
||||||
|
fab!(:topic1) { Fabricate(:topic, category: category1) }
|
||||||
|
fab!(:topic2) { Fabricate(:topic, category: category2) }
|
||||||
|
|
||||||
|
fab!(:shared_draft_topic) { Fabricate(:topic, category: category1) }
|
||||||
|
fab!(:shared_draft) { Fabricate(:shared_draft, topic: shared_draft_topic, category: category2) }
|
||||||
|
|
||||||
|
it "are not displayed if they are disabled" do
|
||||||
|
SiteSetting.shared_drafts_category = ""
|
||||||
|
sign_in(admin)
|
||||||
|
|
||||||
|
get "/c/#{category1.slug}/#{category1.id}.json"
|
||||||
|
expect(response.parsed_body['topic_list']['shared_drafts']).to eq(nil)
|
||||||
|
expect(response.parsed_body['topic_list']['topics'].map { |t| t['id'] }).to contain_exactly(topic1.id, shared_draft_topic.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "are displayed in both shared drafts category and target category" do
|
||||||
|
SiteSetting.shared_drafts_category = category1.id
|
||||||
|
sign_in(admin)
|
||||||
|
|
||||||
|
get "/c/#{category1.slug}/#{category1.id}.json"
|
||||||
|
expect(response.parsed_body['topic_list']['shared_drafts']).to be_nil
|
||||||
|
expect(response.parsed_body['topic_list']['topics'].map { |t| t['id'] }).to contain_exactly(topic1.id, shared_draft_topic.id)
|
||||||
|
|
||||||
|
get "/c/#{category2.slug}/#{category2.id}.json"
|
||||||
|
expect(response.parsed_body['topic_list']['shared_drafts'].map { |t| t['id'] }).to contain_exactly(shared_draft_topic.id)
|
||||||
|
expect(response.parsed_body['topic_list']['topics'].map { |t| t['id'] }).to contain_exactly(topic2.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user