mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 15:18:37 +08:00
FIX: Don't show category options for reports that can't be scoped to a category.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::ReportsController do
|
||||
|
||||
it "is a subclass of AdminController" do
|
||||
expect(Admin::ReportsController < Admin::AdminController).to eq(true)
|
||||
end
|
||||
@ -58,6 +57,46 @@ describe Admin::ReportsController do
|
||||
|
||||
end
|
||||
|
||||
describe 'when report is scoped to a category' do
|
||||
let(:category) { Fabricate(:category) }
|
||||
let(:topic) { Fabricate(:topic, category: category) }
|
||||
let(:other_topic) { Fabricate(:topic) }
|
||||
|
||||
it 'should render the report as JSON' do
|
||||
topic
|
||||
other_topic
|
||||
|
||||
xhr :get, :show, type: 'topics', category_id: category.id
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
|
||||
expect(report["type"]).to eq('topics')
|
||||
expect(report["data"].count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when report is scoped to a group' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:other_user) { Fabricate(:user) }
|
||||
let(:group) { Fabricate(:group) }
|
||||
|
||||
it 'should render the report as JSON' do
|
||||
other_user
|
||||
group.add(user)
|
||||
|
||||
xhr :get, :show, type: 'signups', group_id: group.id
|
||||
|
||||
expect(response).to be_success
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
|
||||
expect(report["type"]).to eq('signups')
|
||||
expect(report["data"].count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user