mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 20:15:17 +08:00
FEATURE: Bulk Unlisting of topics
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user