mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: per-category approval settings (#5778)
- disallow moving topics to a category that requires topic approval
This commit is contained in:
@@ -281,4 +281,51 @@ describe NewPostManager do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when posting in the category requires approval' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:category) { Fabricate(:category) }
|
||||
|
||||
context 'when new topics require approval' do
|
||||
before do
|
||||
category.custom_fields[Category::REQUIRE_TOPIC_APPROVAL] = true
|
||||
category.save
|
||||
end
|
||||
|
||||
it 'enqueues new topics' do
|
||||
manager = NewPostManager.new(
|
||||
user,
|
||||
raw: 'this is a new topic',
|
||||
title: "Let's start a new topic!",
|
||||
category: category.id
|
||||
)
|
||||
|
||||
expect(manager.perform.action).to eq(:enqueued)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when new posts require approval' do
|
||||
let(:topic) { Fabricate(:topic, category: category) }
|
||||
|
||||
before do
|
||||
category.custom_fields[Category::REQUIRE_REPLY_APPROVAL] = true
|
||||
category.save
|
||||
end
|
||||
|
||||
it 'enqueues new posts' do
|
||||
manager = NewPostManager.new(user, raw: 'this is a new post', topic_id: topic.id)
|
||||
expect(manager.perform.action).to eq(:enqueued)
|
||||
end
|
||||
|
||||
it "doesn't blow up with invalid topic_id" do
|
||||
expect do
|
||||
manager = NewPostManager.new(
|
||||
user,
|
||||
raw: 'this is a new topic',
|
||||
topic_id: 97546
|
||||
)
|
||||
expect(manager.perform.action).to eq(:create_post)
|
||||
end.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,6 +62,23 @@ describe PostRevisor do
|
||||
expect(post.topic.category_id).to eq(category.id)
|
||||
end
|
||||
|
||||
it 'does not revise category when the destination category requires topic approval' do
|
||||
new_category = Fabricate(:category)
|
||||
new_category.custom_fields[Category::REQUIRE_TOPIC_APPROVAL] = true
|
||||
new_category.save!
|
||||
|
||||
post = create_post
|
||||
old_category_id = post.topic.category_id
|
||||
|
||||
post.revise(post.user, category_id: new_category.id)
|
||||
expect(post.reload.topic.category_id).to eq(old_category_id)
|
||||
|
||||
new_category.custom_fields[Category::REQUIRE_TOPIC_APPROVAL] = false
|
||||
new_category.save!
|
||||
|
||||
post.revise(post.user, category_id: new_category.id)
|
||||
expect(post.reload.topic.category_id).to eq(new_category.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'revise wiki' do
|
||||
|
||||
Reference in New Issue
Block a user