Commit 7d144dc0 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'service_desk_usage_ping' into 'master'

Service desk usage ping

Closes #1706

See merge request !1588
parents ce0fb87c cb4a9f8a
......@@ -74,6 +74,8 @@ The total number of the following is sent back to GitLab Inc.:
- Protected branches
- Releases
- Remote mirrors
- Service Desk projects
- Service Desk issues
- Web hooks
Also, we track if you've installed Mattermost with GitLab.
......
......@@ -49,7 +49,20 @@ module Gitlab
todos: Todo.count,
uploads: Upload.count,
web_hooks: WebHook.count
}.merge(service_desk_counts)
}
end
def service_desk_counts
return {} unless ::License.current.add_on?('GitLab_ServiceDesk')
projects_with_service_desk = Project.where(service_desk_enabled: true)
{
service_desk_enabled_projects: projects_with_service_desk.count,
service_desk_issues: Issue.where(project: projects_with_service_desk,
author: User.support_bot,
confidential: true).count
}
end
......
require 'spec_helper'
describe Gitlab::UsageData do
let!(:project) { create(:project) }
let!(:project2) { create(:project) }
let!(:project) { create(:empty_project) }
let!(:project2) { create(:empty_project) }
let!(:board) { create(:board, project: project) }
describe '#data' do
subject { Gitlab::UsageData.data }
subject { described_class.data }
it "gathers usage data" do
expect(subject.keys).to match_array(%i(
......@@ -68,8 +68,8 @@ describe Gitlab::UsageData do
end
end
describe '#license_usage_data' do
subject { Gitlab::UsageData.license_usage_data }
describe '.license_usage_data' do
subject { described_class.license_usage_data }
it "gathers license data" do
license = ::License.current
......@@ -87,4 +87,29 @@ describe Gitlab::UsageData do
expect(subject[:recorded_at]).to be_a(Time)
end
end
describe '.service_desk_counts' do
subject { described_class.service_desk_counts }
let!(:project3) { create(:empty_project, service_desk_enabled: true) }
let!(:project4) { create(:empty_project, service_desk_enabled: true) }
context 'when Service Desk is disabled' do
it 'returns an empty hash' do
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk').and_return(false)
expect(subject).to eq({})
end
end
context 'when Service Desk is enabled' do
it 'gathers Service Desk data' do
create_list(:issue, 3, confidential: true, author: User.support_bot, project: [project3, project4].sample)
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk').and_return(true)
expect(subject).to eq(service_desk_enabled_projects: 2,
service_desk_issues: 3)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment