BigW Consortium Gitlab

Fix rubocop offenses

parent f7d35234
module API
module Helpers
module Runner
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
JOB_TOKEN_PARAM = :token
UPDATE_RUNNER_EVERY = 10 * 60
......@@ -42,7 +42,7 @@ module API
end
def job_not_found!
if headers['User-Agent'].to_s.match(/gitlab(-ci-multi)?-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /)
if headers['User-Agent'].to_s =~ /gitlab(-ci-multi)?-runner \d+\.\d+\.\d+(~beta\.\d+\.g[0-9a-f]+)? /
no_content!
else
not_found!
......
......@@ -94,7 +94,7 @@ module API
end
params do
requires :token, type: String, desc: %q(Runners's authentication token)
requires :id, type: Fixnum, desc: %q(Job's ID)
requires :id, type: Integer, desc: %q(Job's ID)
optional :trace, type: String, desc: %q(Job's full trace)
optional :state, type: String, desc: %q(Job's status: success, failed)
end
......@@ -122,7 +122,7 @@ module API
[416, 'Range not satisfiable']]
end
params do
requires :id, type: Fixnum, desc: %q(Job's ID)
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
end
patch '/:id/trace' do
......@@ -152,9 +152,9 @@ module API
[413, 'File too large']]
end
params do
requires :id, type: Fixnum, desc: %q(Job's ID)
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
optional :filesize, type: Fixnum, desc: %q(ARtifacts filesize)
optional :filesize, type: Integer, desc: %q(Artifacts filesize)
end
post '/:id/artifacts/authorize' do
not_allowed! unless Gitlab.config.artifacts.enabled
......@@ -183,7 +183,7 @@ module API
[413, 'File too large']]
end
params do
requires :id, type: Fixnum, desc: %q(Job's ID)
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
optional :expire_in, type: String, desc: %q(Specify when artifacts should expire)
optional 'file', type: File, desc: %q(Artifact's file)
......@@ -211,9 +211,7 @@ module API
job.artifacts_file = artifacts
job.artifacts_metadata = metadata
job.artifacts_expire_in = params['expire_in'] ||
Gitlab::CurrentSettings
.current_application_settings
.default_artifacts_expire_in
Gitlab::CurrentSettings.current_application_settings.default_artifacts_expire_in
if job.save
present job, with: Entities::JobRequest::Response
......@@ -228,7 +226,7 @@ module API
[404, 'Artifact not found']]
end
params do
requires :id, type: Fixnum, desc: %q(Job's ID)
requires :id, type: Integer, desc: %q(Job's ID)
optional :token, type: String, desc: %q(Job's authentication token)
end
get '/:id/artifacts' do
......
......@@ -3,9 +3,9 @@ module Gitlab
module Build
module Response
class Step
CONDITION_ON_FAILURE = 'on_failure'
CONDITION_ON_SUCCESS = 'on_success'
CONDITION_ALWAYS = 'always'
CONDITION_ON_FAILURE = 'on_failure'.freeze
CONDITION_ON_SUCCESS = 'on_success'.freeze
CONDITION_ALWAYS = 'always'.freeze
attr_reader :name, :script, :when, :allow_failure, :timeout
......
......@@ -281,7 +281,7 @@ describe API::Runner do
expect(json_response['image']).to include({ 'name' => 'ruby:2.1' })
expect(json_response['services']).to include({ 'name' => 'postgres' })
expect(json_response['steps']).to include({ 'name' => 'after_script',
'script' => ['ls', 'date'],
'script' => %w(ls date),
'timeout' => job.timeout,
'when' => 'always',
'allow_failure' => true })
......@@ -889,9 +889,11 @@ describe API::Runner do
end
def upload_artifacts(file, headers = {}, accelerated = true)
params = accelerated ?
{ 'file.path' => file.path, 'file.name' => file.original_filename } :
params = if accelerated
{ 'file.path' => file.path, 'file.name' => file.original_filename }
else
{ 'file' => file }
end
post api("/jobs/#{job.id}/artifacts"), params, headers
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