diff options
author | Sean McGivern <sean@gitlab.com> | 2017-04-05 13:19:59 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 15:20:55 +0200 |
commit | ebd5e9b4549ebc80155a5a8f139efdb40b6f8b12 (patch) | |
tree | 84d7f3066f0dbf7022bc0ec58cb3ab235006715a /spec/workers | |
parent | c3bb21ff800699bed829a30c75fa81fd0d4dab8d (diff) | |
download | gitlab-ce-ebd5e9b4549ebc80155a5a8f139efdb40b6f8b12.tar.gz |
Port 'Add EE usage ping' to CE
CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/557
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/gitlab_usage_ping_worker_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb new file mode 100644 index 00000000000..8c5c027ac29 --- /dev/null +++ b/spec/workers/gitlab_usage_ping_worker_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe GitlabUsagePingWorker do + subject { GitlabUsagePingWorker.new } + + it "gathers license data" do + data = subject.data + + expect(data[:version]).to eq(Gitlab::VERSION) + expect(data[:active_user_count]).to eq(User.active.count) + end + + it "sends POST request" do + stub_application_setting(usage_ping_enabled: true) + + stub_request(:post, "https://version.gitlab.com/usage_data"). + to_return(status: 200, body: '', headers: {}) + expect(subject).to receive(:try_obtain_lease).and_return(true) + + expect(subject.perform.response.code.to_i).to eq(200) + end + + it "does not run if usage ping is disabled" do + stub_application_setting(usage_ping_enabled: false) + + expect(subject).not_to receive(:try_obtain_lease) + expect(subject).not_to receive(:perform) + end +end |