2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-11-23 08:36:12 +00:00
|
|
|
class TestsController < ApplicationController
|
|
|
|
|
2021-02-10 08:11:02 +00:00
|
|
|
prepend_before_action -> { authentication_check_only }
|
|
|
|
|
2021-10-14 14:35:12 +00:00
|
|
|
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
|
2015-04-27 13:42:53 +00:00
|
|
|
result = { success: true }
|
|
|
|
render json: result
|
2012-11-23 08:36:12 +00:00
|
|
|
end
|
|
|
|
|
2020-02-12 14:50:18 +00:00
|
|
|
# GET /test/raised_exception
|
|
|
|
def error_raised_exception
|
|
|
|
exception = params.fetch(:exception, 'StandardError')
|
|
|
|
message = params.fetch(:message, 'no message provided')
|
2016-06-30 08:24:03 +00:00
|
|
|
|
2020-02-12 14:50:18 +00:00
|
|
|
raise exception.safe_constantize, message
|
2016-06-30 08:24:03 +00:00
|
|
|
end
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|