FEATURE: Bulk Unlisting of topics

This commit is contained in:
Robin Ward
2015-10-27 16:57:40 -04:00
parent 46ca66771b
commit 6b236d3c83
5 changed files with 77 additions and 46 deletions

View File

@ -153,4 +153,31 @@ describe TopicsBulkAction do
end
end
end
describe "unlist" do
let(:topic) { Fabricate(:topic) }
context "when the user can moderate the topic" do
it "unlists 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: 'unlist')
topic_ids = tba.perform!
expect(topic_ids).to eq([topic.id])
topic.reload
expect(topic).not_to be_visible
end
end
context "when the user can't edit the topic" do
it "doesn't unlist the topic" do
Guardian.any_instance.expects(:can_moderate?).returns(false)
tba = TopicsBulkAction.new(topic.user, [topic.id], type: 'unlist')
topic_ids = tba.perform!
expect(topic_ids).to be_blank
topic.reload
expect(topic).to be_visible
end
end
end
end