2017-04-05 12:19:59 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GitlabUsagePingWorker do
|
2017-05-01 15:13:33 +00:00
|
|
|
subject { described_class.new }
|
2017-04-05 12:19:59 +00:00
|
|
|
|
|
|
|
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: {})
|
2016-10-19 21:29:01 +00:00
|
|
|
expect(Gitlab::UsageData).to receive(:to_json).with({ force_refresh: true }).and_call_original
|
2017-04-05 12:19:59 +00:00
|
|
|
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
|