mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:41:25 +08:00
FEATURE: Add Archive Topics to Bulk actions
Add the ability to archive topics in bulk https://meta.discourse.org/t/archive-topics-via-bulk/20302
This commit is contained in:
@ -122,4 +122,31 @@ describe TopicsBulkAction do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "archive" do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
|
||||
context "when the user can moderate the topic" do
|
||||
it "archives the topic and returns the topic_id" do
|
||||
Guardian.any_instance.expects(:can_moderate?).returns(true)
|
||||
Guardian.any_instance.expects(:can_create?).returns(true)
|
||||
tba = TopicsBulkAction.new(topic.user, [topic.id], type: 'archive')
|
||||
topic_ids = tba.perform!
|
||||
topic_ids.should == [topic.id]
|
||||
topic.reload
|
||||
topic.should be_archived
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user can't edit the topic" do
|
||||
it "doesn't archive the topic" do
|
||||
Guardian.any_instance.expects(:can_moderate?).returns(false)
|
||||
tba = TopicsBulkAction.new(topic.user, [topic.id], type: 'archive')
|
||||
topic_ids = tba.perform!
|
||||
topic_ids.should be_blank
|
||||
topic.reload
|
||||
topic.should_not be_archived
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user