9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/inferno/apps/web/controllers/test_session_form_post_controller.rb', line 9
def handle(req, res)
test_suite_id = req.params[:test_suite_id]
test_suite = Inferno::Repositories::TestSuites.new.find(test_suite_id)
halt 404, "Unable to find test suite with id #{test_suite_id}" if test_suite.nil?
params = { test_suite_id: }
suite_option_keys = test_suite.suite_options.map(&:id)
options = req.params.to_h.slice(*suite_option_keys)
params[:suite_options] = options.map { |key, value| { id: key, value: } } if options.present?
repo = Inferno::Repositories::TestSessions.new
session = repo.create(params)
preset_id = req.params[:preset_id]
if preset_id.present?
preset = Inferno::Repositories::Presets.new.find(preset_id)
halt 422, "Unable to find preset with id #{preset_id} for test suite #{test_suite_id}" if preset.nil?
repo.apply_preset(session, preset_id)
end
res.redirect_to "#{Inferno::Application['base_url']}/#{test_suite_id}/#{session.id}"
end
|