FIX: Don't show category options for reports that can't be scoped to a category.

This commit is contained in:
Guo Xiang Tan
2017-04-13 17:10:55 +08:00
parent bda20cc44a
commit 3d76fb9c2c
6 changed files with 58 additions and 12 deletions

View File

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