BigW Consortium Gitlab

gitlab_usage_ping_worker_spec.rb 750 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
require 'spec_helper'

describe GitlabUsagePingWorker do
  subject { GitlabUsagePingWorker.new }

  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: {})
11
    expect(Gitlab::UsageData).to receive(:to_json).with({ force_refresh: true }).and_call_original
12 13 14 15 16 17 18 19 20 21 22 23
    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