diff options
author | Stan Hu <stanhu@gmail.com> | 2016-10-19 14:29:01 -0700 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 15:20:55 +0200 |
commit | f30a46b401f283f2dc868da17de413eee05198a5 (patch) | |
tree | 9be951a0c4f937d3a8a9adfe46dce088ba9fbb34 | |
parent | bca368990acdb86acf251382c191fa9b7627837a (diff) | |
download | gitlab-ce-f30a46b401f283f2dc868da17de413eee05198a5.tar.gz |
Used named parameter for refreshing usage data
-rw-r--r-- | app/workers/gitlab_usage_ping_worker.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/usage_data.rb | 8 | ||||
-rw-r--r-- | spec/workers/gitlab_usage_ping_worker_spec.rb | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb index f26a3f47dad..4a9d626caec 100644 --- a/app/workers/gitlab_usage_ping_worker.rb +++ b/app/workers/gitlab_usage_ping_worker.rb @@ -15,7 +15,7 @@ class GitlabUsagePingWorker begin HTTParty.post(url, - body: Gitlab::UsageData.to_json(true), + body: Gitlab::UsageData.to_json(force_refresh: true), headers: { 'Content-type' => 'application/json' } ) rescue HTTParty::Error => e diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 02750fa02e6..26812ed7164 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -3,16 +3,16 @@ module Gitlab include Gitlab::CurrentSettings class << self - def data(force_refresh = false) - Rails.cache.fetch('usage_data', force: force_refresh) { uncached_data } + def data(force_refresh: false) + Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data } end def uncached_data license_usage_data.merge(system_usage_data) end - def to_json(force_refresh = false) - data(force_refresh).to_json + def to_json(force_refresh: false) + data(force_refresh: force_refresh).to_json end def system_usage_data diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb index 8821df3d81e..b6c080f36f4 100644 --- a/spec/workers/gitlab_usage_ping_worker_spec.rb +++ b/spec/workers/gitlab_usage_ping_worker_spec.rb @@ -8,6 +8,7 @@ describe GitlabUsagePingWorker do stub_request(:post, "https://version.gitlab.com/usage_data"). to_return(status: 200, body: '', headers: {}) + expect(Gitlab::UsageData).to receive(:to_json).with({ force_refresh: true }).and_call_original expect(subject).to receive(:try_obtain_lease).and_return(true) expect(subject.perform.response.code.to_i).to eq(200) |