Commit 13e251bd authored by Tyler Amos's avatar Tyler Amos

Backwards compatible active_users param

The active_users param was added to SyncSeatLinkRequestWorker without an
optional nil value, which could break existing jobs.
parent db5cd3f3
...@@ -12,7 +12,10 @@ class SyncSeatLinkRequestWorker ...@@ -12,7 +12,10 @@ class SyncSeatLinkRequestWorker
RequestError = Class.new(StandardError) 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( response = Gitlab::HTTP.post(
URI_PATH, URI_PATH,
base_uri: EE::SUBSCRIPTIONS_URL, 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 ...@@ -26,18 +26,46 @@ describe SyncSeatLinkRequestWorker, type: :worker do
) )
end end
context 'when the request is not successful' do shared_examples 'unsuccessful request' do
before do context 'when the request is not successful' do
stub_request(:post, seat_link_url) before do
.to_return(status: 400, body: '{"success":false,"error":"Bad Request"}') 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 end
it 'raises an error with the expected message' do it 'still processes the job and sends a request with active_users set to nil' do
expect { subject }.to raise_error( stub_request(:post, seat_link_url).to_return(status: 200)
described_class::RequestError,
'Seat Link request failed! Code:400 Body:{"success":false,"error":"Bad Request"}' 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 end
it_behaves_like 'unsuccessful request'
end end
end 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