FIX: uncategorized setting to control whether topic featured links are allowed
This commit is contained in:
parent
1cbe355c5b
commit
c75bebdea2
|
@ -143,6 +143,7 @@ const Composer = RestModel.extend({
|
|||
if (!this.siteSettings.topic_featured_link_enabled || !canEditTitle || creatingPrivateMessage) { return false; }
|
||||
|
||||
const categoryIds = this.site.get('topic_featured_link_allowed_category_ids');
|
||||
if (!categoryId && categoryIds && categoryIds.indexOf(this.site.get('uncategorized_category_id')) !== -1) { return true; }
|
||||
return categoryIds === undefined || !categoryIds.length || categoryIds.indexOf(categoryId) !== -1;
|
||||
},
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ module TopicGuardian
|
|||
|
||||
def can_edit_featured_link?(category_id)
|
||||
return false unless SiteSetting.topic_featured_link_enabled
|
||||
return !Category.where(topic_featured_link_allowed: false).exists? unless category_id # uncategorized
|
||||
Category.where(id: category_id, topic_featured_link_allowed: true).exists?
|
||||
Category.where(id: category_id||SiteSetting.uncategorized_category_id, topic_featured_link_allowed: true).exists?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2284,16 +2284,20 @@ describe Guardian do
|
|||
context 'topic featured link category restriction' do
|
||||
before { SiteSetting.topic_featured_link_enabled = true }
|
||||
let(:guardian) { Guardian.new }
|
||||
let(:uncategorized) { Category.find(SiteSetting.uncategorized_category_id) }
|
||||
|
||||
context "uncategorized" do
|
||||
let!(:link_category) { Fabricate(:link_category) }
|
||||
|
||||
it "allows featured links if no categories forbid it" do
|
||||
it "allows featured links if uncategorized allows it" do
|
||||
uncategorized.topic_featured_link_allowed = true
|
||||
uncategorized.save!
|
||||
expect(guardian.can_edit_featured_link?(nil)).to eq(true)
|
||||
end
|
||||
|
||||
it "forbids featured links if a category forbids it" do
|
||||
Fabricate(:category, topic_featured_link_allowed: false)
|
||||
it "forbids featured links if uncategorized forbids it" do
|
||||
uncategorized.topic_featured_link_allowed = false
|
||||
uncategorized.save!
|
||||
expect(guardian.can_edit_featured_link?(nil)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue