Sha256: e95ce9248f4a3ec21398d31479becc7e77b4d8ca5bceee3f73681a5ded54a3be

Contents?: true

Size: 867 Bytes

Versions: 12

Compression:

Stored size: 867 Bytes

Contents

module Inferno
  module Web
    module Controllers
      module TestSessions
        class Create < Controller
          PARAMS = [:test_suite_id].freeze

          def call(params)
            session = repo.create(create_params(params))

            repo.apply_preset(session.id, params[:preset_id]) if params[:preset_id].present?

            self.body = serialize(session)
          rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation => e
            self.body = { errors: e.message }.to_json
            self.status = 422
          rescue StandardError => e
            Application['logger'].error(e.full_message)
            self.body = { errors: e.message }.to_json
            self.status = 500
          end

          def create_params(params)
            params.to_h.slice(*PARAMS)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
inferno_core-0.3.4 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.3.3 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.3.2 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.3.1 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.3.0 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.3.0.rc1 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.2.0 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.2.0.rc4 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.2.0.rc3 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.2.0.rc2 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.2.0.rc1 lib/inferno/apps/web/controllers/test_sessions/create.rb
inferno_core-0.1.4.pre lib/inferno/apps/web/controllers/test_sessions/create.rb