Sha256: 520a712d19a08363d11e83431b66ffa48178679fd5c6e49da4c6759d8c6c6af1

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 KB

Contents

module Inferno
  module Web
    module Controllers
      class TestSessionFormPostController < Hanami::Action
        def self.call(...)
          new.call(...)
        end

        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
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
inferno_core-0.6.1 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.6.0 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.5.4 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.5.3 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.5.2 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.5.1 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.5.0 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.44 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.43 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.42 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.41 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.40 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.39 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.38 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.35 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.34 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.33 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb
inferno_core-0.4.32 lib/inferno/apps/web/controllers/test_session_form_post_controller.rb