mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 05:07:57 +08:00

Plugins like for example AI or Akismet create reviewable items. When the plugin is disabled, then we cannot properly handle those items. In that situation, we should display warnings about unhandled types. Instruct admin to reenable plugins. In addition, we should allow the admin to delete all pending reviews from disabled plugins.
38 lines
1017 B
Ruby
38 lines
1017 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
RSpec.describe Admin::UnknownReviewablesController do
|
|
let(:admin) { Fabricate(:admin) }
|
|
let(:user) { Fabricate(:user) }
|
|
fab!(:reviewable)
|
|
fab!(:unknown_reviewable) { Fabricate(:reviewable, type: "ReviewablePost") }
|
|
|
|
describe "#destroy" do
|
|
context "when user is an admin" do
|
|
before do
|
|
sign_in admin
|
|
|
|
allow(Reviewable).to receive(:types).and_return([ReviewableUser])
|
|
end
|
|
|
|
it "destroys all pending reviewables of specified types" do
|
|
delete "/admin/unknown_reviewables/destroy.json"
|
|
expect(response.code).to eq("200")
|
|
|
|
reviewable.reload
|
|
expect { unknown_reviewable.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
|
end
|
|
end
|
|
|
|
context "when user is not an admin" do
|
|
before { sign_in user }
|
|
|
|
it "raises Discourse::InvalidAccess" do
|
|
delete "/admin/unknown_reviewables/destroy.json"
|
|
expect(response.code).to eq("404")
|
|
end
|
|
end
|
|
end
|
|
end
|