Skip to content

Commit 5eda287

Browse files
fix
1 parent 6d8bd82 commit 5eda287

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

google-apis-core/lib/google/apis/core/storage_upload.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,16 @@ def cancel_resumable_upload(client)
239239
response = client.delete(@upload_url, nil, request_header)
240240
handle_resumable_upload_http_response_codes(response)
241241

242-
if !@upload_incomplete && (400..499).include?(response.status.to_i) && response.status.to_i != 404
242+
is_successful_cancellation =
243+
!@upload_incomplete &&
244+
(400..499).cover?(response.status.to_i) &&
245+
response.status.to_i != 404
246+
if is_successful_cancellation
243247
@close_io_on_finish = true
244-
true # method returns true if upload is successfully cancelled
248+
return true # method returns true if upload is successfully cancelled
245249
else
246-
logger.debug { sprintf("Failed to cancel upload session. Response: #{response.status.to_i} - #{response.body}") }
247-
false
250+
logger.debug { "Failed to cancel upload session. Response: #{response.status.to_i} - #{response.body}" }
251+
return false
248252
end
249253
end
250254

google-apis-core/spec/google/apis/core/service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
.to_return(status: 404)
302302
end
303303
it 'should return false' do
304-
expect(command).to be_falsey
304+
expect(command).to be(false)
305305
end
306306
end
307307

@@ -345,7 +345,7 @@
345345
.to_return(status: 404)
346346
end
347347
it 'should return false' do
348-
expect(command).to be_falsey
348+
expect(command).to be(false)
349349
end
350350
end
351351
end

0 commit comments

Comments
 (0)