Sha256: 5dfd8958977031925481a75dbf99a6ca67f2453a66b400c8cd383f8e5c1d87e1

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

require_relative '../../controller'

module Inferno
  module Web
    module Controllers
      module TestSessions
        module SessionData
          class ApplyPreset < Controller
            include Import[
                      test_sessions_repo: 'inferno.repositories.test_sessions',
                      presets_repo: 'inferno.repositories.presets'
                    ]

            def self.resource_class
              'SessionData'
            end

            def handle(req, res)
              test_session_id = req.params[:id]
              test_session = test_sessions_repo.find(test_session_id)

              if test_session.nil?
                Application[:logger].error("Unknown test session #{test_session_id}")
                halt 404
              end

              preset_id = req.params[:preset_id]
              preset = presets_repo.find(preset_id)

              if preset.nil?
                Application[:logger].error("Unknown preset #{preset_id}")
                halt 404
              end

              test_sessions_repo.apply_preset(test_session_id, preset_id)
              res.status = 200
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
inferno_core-0.4.7 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.7.pre lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.6 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.5 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.4 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.3 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.2 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.2.pre lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.1 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.1.pre2 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.1.pre lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb
inferno_core-0.4.0 lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb