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:
cpradio
2014-09-22 14:56:48 -04:00
parent d97548114f
commit afdbb2bb96
5 changed files with 54 additions and 6 deletions

View File

@ -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