2017-04-05 08:29:48 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::UsageData do
|
2017-07-19 10:45:28 -04:00
|
|
|
let(:projects) { create_list(:project, 3) }
|
|
|
|
let!(:board) { create(:board, project: projects[0]) }
|
2017-04-05 08:29:48 -04:00
|
|
|
|
|
|
|
describe '#data' do
|
2017-07-19 10:45:28 -04:00
|
|
|
before do
|
|
|
|
create(:jira_service, project: projects[0])
|
|
|
|
create(:jira_service, project: projects[1])
|
|
|
|
create(:prometheus_service, project: projects[1])
|
|
|
|
create(:service, project: projects[0], type: 'SlackSlashCommandsService', active: true)
|
|
|
|
create(:service, project: projects[1], type: 'SlackService', active: true)
|
|
|
|
create(:service, project: projects[2], type: 'SlackService', active: true)
|
|
|
|
end
|
|
|
|
|
2017-05-01 11:13:33 -04:00
|
|
|
subject { described_class.data }
|
2017-04-05 08:29:48 -04:00
|
|
|
|
|
|
|
it "gathers usage data" do
|
|
|
|
expect(subject.keys).to match_array(%i(
|
|
|
|
active_user_count
|
|
|
|
counts
|
|
|
|
recorded_at
|
2017-01-18 13:33:33 -05:00
|
|
|
mattermost_enabled
|
2017-04-06 15:16:57 -04:00
|
|
|
edition
|
2017-04-05 08:49:22 -04:00
|
|
|
version
|
|
|
|
uuid
|
2017-05-09 15:58:22 -04:00
|
|
|
hostname
|
2017-04-05 08:29:48 -04:00
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "gathers usage counts" do
|
|
|
|
count_data = subject[:counts]
|
|
|
|
|
|
|
|
expect(count_data[:boards]).to eq(1)
|
2017-07-19 10:45:28 -04:00
|
|
|
expect(count_data[:projects]).to eq(3)
|
2017-04-05 08:29:48 -04:00
|
|
|
|
|
|
|
expect(count_data.keys).to match_array(%i(
|
|
|
|
boards
|
|
|
|
ci_builds
|
2017-06-19 13:56:27 -04:00
|
|
|
ci_internal_pipelines
|
|
|
|
ci_external_pipelines
|
2017-04-05 08:29:48 -04:00
|
|
|
ci_runners
|
|
|
|
ci_triggers
|
2017-05-07 18:35:56 -04:00
|
|
|
ci_pipeline_schedules
|
2017-04-05 08:29:48 -04:00
|
|
|
deploy_keys
|
|
|
|
deployments
|
|
|
|
environments
|
2017-06-15 06:50:45 -04:00
|
|
|
in_review_folder
|
2017-04-05 08:29:48 -04:00
|
|
|
groups
|
|
|
|
issues
|
|
|
|
keys
|
|
|
|
labels
|
|
|
|
lfs_objects
|
|
|
|
merge_requests
|
|
|
|
milestones
|
|
|
|
notes
|
|
|
|
projects
|
2017-07-19 03:07:17 -04:00
|
|
|
projects_imported_from_github
|
2017-07-19 10:45:28 -04:00
|
|
|
projects_jira_active
|
|
|
|
projects_slack_notifications_active
|
|
|
|
projects_slack_slash_active
|
2017-04-06 15:52:08 -04:00
|
|
|
projects_prometheus_active
|
2017-04-05 08:29:48 -04:00
|
|
|
pages_domains
|
|
|
|
protected_branches
|
|
|
|
releases
|
|
|
|
snippets
|
|
|
|
todos
|
2017-03-09 11:00:25 -05:00
|
|
|
uploads
|
2017-04-05 08:29:48 -04:00
|
|
|
web_hooks
|
|
|
|
))
|
|
|
|
end
|
2017-07-19 10:45:28 -04:00
|
|
|
|
|
|
|
it 'gathers projects data correctly' do
|
|
|
|
count_data = subject[:counts]
|
|
|
|
|
|
|
|
expect(count_data[:projects]).to eq(3)
|
|
|
|
expect(count_data[:projects_prometheus_active]).to eq(1)
|
|
|
|
expect(count_data[:projects_jira_active]).to eq(2)
|
|
|
|
expect(count_data[:projects_slack_notifications_active]).to eq(2)
|
|
|
|
expect(count_data[:projects_slack_slash_active]).to eq(1)
|
|
|
|
end
|
2017-04-05 08:29:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#license_usage_data' do
|
2017-05-01 11:13:33 -04:00
|
|
|
subject { described_class.license_usage_data }
|
2017-04-05 08:29:48 -04:00
|
|
|
|
|
|
|
it "gathers license data" do
|
2017-04-05 08:49:22 -04:00
|
|
|
expect(subject[:uuid]).to eq(current_application_settings.uuid)
|
2017-04-05 08:29:48 -04:00
|
|
|
expect(subject[:version]).to eq(Gitlab::VERSION)
|
|
|
|
expect(subject[:active_user_count]).to eq(User.active.count)
|
|
|
|
expect(subject[:recorded_at]).to be_a(Time)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|