BigW Consortium Gitlab

usage_data_spec.rb 1.68 KB
Newer Older
1 2 3 4 5 6 7 8
require 'spec_helper'

describe Gitlab::UsageData do
  let!(:project) { create(:empty_project) }
  let!(:project2) { create(:empty_project) }
  let!(:board) { create(:board, project: project) }

  describe '#data' do
9
    subject { described_class.data }
10 11 12 13 14 15

    it "gathers usage data" do
      expect(subject.keys).to match_array(%i(
        active_user_count
        counts
        recorded_at
16
        mattermost_enabled
17
        edition
18 19
        version
        uuid
20
        hostname
21 22 23 24 25 26 27 28 29 30 31 32
      ))
    end

    it "gathers usage counts" do
      count_data = subject[:counts]

      expect(count_data[:boards]).to eq(1)
      expect(count_data[:projects]).to eq(2)

      expect(count_data.keys).to match_array(%i(
        boards
        ci_builds
33 34
        ci_internal_pipelines
        ci_external_pipelines
35 36
        ci_runners
        ci_triggers
37
        ci_pipeline_schedules
38 39 40
        deploy_keys
        deployments
        environments
41
        in_review_folder
42 43 44 45 46 47 48 49 50
        groups
        issues
        keys
        labels
        lfs_objects
        merge_requests
        milestones
        notes
        projects
51
        projects_imported_from_github
52
        projects_prometheus_active
53 54 55 56 57
        pages_domains
        protected_branches
        releases
        snippets
        todos
58
        uploads
59 60 61 62 63 64
        web_hooks
      ))
    end
  end

  describe '#license_usage_data' do
65
    subject { described_class.license_usage_data }
66 67

    it "gathers license data" do
68
      expect(subject[:uuid]).to eq(current_application_settings.uuid)
69 70 71 72 73 74
      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