Skip to content

Commit 291048f

Browse files
committed
Add one more test
1 parent 7df1a32 commit 291048f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

spec/v3/services/job/restart_spec.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,16 @@
220220
end
221221

222222
context 'billing authorization' do
223-
context 'billing service rejects the job' do
223+
context 'billing service authorizes the job' do
224224
before do
225225
stub_request(:post, /http:\/\/localhost:9292\/(users|organizations)\/(.+)\/authorize_build/).to_return(
226-
body: MultiJson.dump(allowed: false, rejection_code: :no_build_credits), status: 403
226+
body: MultiJson.dump(allowed: true, rejection_code: :nil), status: 200
227227
)
228228
end
229229

230-
it 'does not restart the job' do
230+
it 'restarts the job' do
231231
post("/v3/job/#{job.id}/restart", params, headers)
232-
expect(last_response.status).to eq(403)
232+
expect(last_response.status).to eq(202)
233233
end
234234
end
235235

@@ -245,6 +245,19 @@
245245
expect(last_response.status).to eq(202)
246246
end
247247
end
248+
249+
context 'billing service rejects the job' do
250+
before do
251+
stub_request(:post, /http:\/\/localhost:9292\/(users|organizations)\/(.+)\/authorize_build/).to_return(
252+
body: MultiJson.dump(allowed: false, rejection_code: :no_build_credits), status: 403
253+
)
254+
end
255+
256+
it 'does not restart the job' do
257+
post("/v3/job/#{job.id}/restart", params, headers)
258+
expect(last_response.status).to eq(403)
259+
end
260+
end
248261
end
249262

250263
describe "passed state" do

0 commit comments

Comments
 (0)