Commit 3cf78b50 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'ta-fix-sync-seat-link-worker-parameter' into 'master'

Backwards compatible active_users param

See merge request gitlab-org/gitlab!28241
parents dbdac50a 13e251bd
......@@ -12,7 +12,10 @@ class SyncSeatLinkRequestWorker
RequestError = Class.new(StandardError)
def perform(date, license_key, max_historical_user_count, active_users)
# active_users param is optional as it was added in a patch release for %12.9.
# The optional nil value can be removed in the next major release, %13.0, when
# it becomes mandatory.
def perform(date, license_key, max_historical_user_count, active_users = nil)
response = Gitlab::HTTP.post(
URI_PATH,
base_uri: EE::SUBSCRIPTIONS_URL,
......
---
title: Allow active_users param to be optional for SyncSeatLinkRequestWorker#perform
merge_request: 28241
author:
type: fixed
......@@ -26,18 +26,46 @@ describe SyncSeatLinkRequestWorker, type: :worker do
)
end
context 'when the request is not successful' do
before do
stub_request(:post, seat_link_url)
.to_return(status: 400, body: '{"success":false,"error":"Bad Request"}')
shared_examples 'unsuccessful request' do
context 'when the request is not successful' do
before do
stub_request(:post, seat_link_url)
.to_return(status: 400, body: '{"success":false,"error":"Bad Request"}')
end
it 'raises an error with the expected message' do
expect { subject }.to raise_error(
described_class::RequestError,
'Seat Link request failed! Code:400 Body:{"success":false,"error":"Bad Request"}'
)
end
end
end
it_behaves_like 'unsuccessful request'
context 'when the active_users param is not passed' do
subject do
described_class.new.perform('2020-01-01', '123', 5)
end
it 'raises an error with the expected message' do
expect { subject }.to raise_error(
described_class::RequestError,
'Seat Link request failed! Code:400 Body:{"success":false,"error":"Bad Request"}'
it 'still processes the job and sends a request with active_users set to nil' do
stub_request(:post, seat_link_url).to_return(status: 200)
subject
expect(WebMock).to have_requested(:post, seat_link_url).with(
headers: { 'Content-Type' => 'application/json' },
body: {
date: '2020-01-01',
license_key: '123',
max_historical_user_count: 5,
active_users: nil
}.to_json
)
end
it_behaves_like 'unsuccessful request'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment