Commit 010c81f7 authored by Candy Tsai's avatar Candy Tsai

fix rubocop warnings

parent ffab7062
Pipeline #50404 passed with stage
in 10 minutes and 3 seconds
......@@ -10,16 +10,16 @@ module Debci
before '/*' do
@user = ENV['FAKE_CERTIFICATE_USER'] || env['SSL_CLIENT_S_DN_CN']
if not @user
unless @user
# TODO: change to unauthenticated template
halt(403, "Unauthenticated!\n")
end
end
get '/' do
@suites = Debci.config.suite_list
@archs = Debci.config.arch_list
erb :self_service
erb :self_service
end
post '/test/submit' do
......@@ -33,7 +33,7 @@ module Debci
temp_obj['package'] = package
temp_obj['suite'] = suite
temp_obj['arch'] = arch
temp_obj['pin-packages']= []
temp_obj['pin-packages'] = []
pin_packages.each do |pin_package|
pin_package = pin_package.split(/,\s*/)
temp_obj['pin-packages'].push(pin_package)
......@@ -49,14 +49,12 @@ module Debci
post '/test/upload' do
begin
tests_file = File.read(params[:tests])
tests = JSON.load(tests_file)
if not tests.kind_of?(Array)
raise "Not an array"
end
tests = JSON.parse(tests_file)
raise "Not an array" unless tests.is_a?(Array)
Debci::Test.request_tests(tests, @user)
rescue JSON::ParserError => error
halt(400, "Invalid JSON: #{error}")
rescue => error
rescue StandardError => error
halt(400, "Error: #{error}")
else
201
......
......@@ -5,17 +5,19 @@ module Debci
priority = 1
job.enqueue(priority)
end
def create_job(package, suite, arch, requestor, status, trigger, pin_packages)
job = Debci::Job.create!(
package: package,
suite: suite,
def create_job(test, arch, requestor, status)
Debci::Job.create!(
package: test['package'],
suite: test['suite'],
arch: arch,
requestor: requestor,
status: status,
trigger: trigger,
pin_packages: pin_packages,
trigger: test['trigger'],
pin_packages: test['pin-packages']
)
end
def request_tests(tests, requestor)
tests.each do |test|
pkg = test['package']
......@@ -26,11 +28,11 @@ module Debci
status = 'fail'
end
test['arch'].each do |arch|
job = self.create_job(test['package'], test['suite'], arch, requestor, status, test['trigger'], test['pin-packages'])
self.enqueue(job) if enqueue
job = create_job(test, arch, requestor, status)
enqueue(job) if enqueue
end
end
end
end
end
end
\ No newline at end of file
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