Sha256: 816e1f59f75a69d3dddb9048da5500dbd9d52231c07efdc4f79d57f4ab26842b
Contents?: true
Size: 1.01 KB
Versions: 12
Compression:
Stored size: 1.01 KB
Contents
require_relative '../controller' require_relative '../../serializers/test_session' module Inferno module Web module Controllers module TestSessions class Create < Controller PARAMS = [:test_suite_id, :suite_options].freeze def handle(req, res) params = req.params.to_h params.merge!(JSON.parse(req.body.string).symbolize_keys) unless req.body.string.blank? session = repo.create(create_params(params)) repo.apply_preset(session.id, params[:preset_id]) if params[:preset_id].present? res.body = serialize(session) rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation => e halt 422, { errors: e.message }.to_json rescue StandardError => e Application['logger'].error(e.full_message) halt 500, { errors: e.message }.to_json end def create_params(params) params.slice(*PARAMS) end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems