trabajo-afectivo/app/controllers/tests_controller.rb

37 lines
804 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2012-11-23 08:36:12 +00:00
class TestsController < ApplicationController
prepend_before_action -> { authentication_check_only }
layout 'tests', except: %i[wait raised_exception]
def show
@filename = params[:name]
if lookup_context.exists? @filename, 'tests'
render @filename
elsif @filename.starts_with? 'form'
render 'form'
else
render
end
end
2012-11-23 08:36:12 +00:00
# GET /test/wait
def wait
sleep params[:sec].to_i
result = { success: true }
render json: result
2012-11-23 08:36:12 +00:00
end
# GET /test/raised_exception
def error_raised_exception
exception = params.fetch(:exception, 'StandardError')
message = params.fetch(:message, 'no message provided')
raise exception.safe_constantize, message
end
end