2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 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
|
|
|
|
|
|
2022-08-26 13:09:22 +00:00
|
|
|
# GET /tests/wait
|
2012-11-23 08:36:12 +00:00
|
|
|
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
|
|
|
|
|
|
2022-08-26 13:09:22 +00:00
|
|
|
# GET /tests/raised_exception
|
2020-02-12 14:50:18 +00:00
|
|
|
def error_raised_exception
|
2023-02-20 09:55:34 +00:00
|
|
|
origin = params.fetch(:origin)
|
|
|
|
|
exception = params.fetch(:exception, 'StandardError')
|
|
|
|
|
message = params.fetch(:message, 'no message provided')
|
|
|
|
|
|
|
|
|
|
# Emulate the originating controller.
|
|
|
|
|
params[:controller] = origin if origin
|
2016-06-30 08:24:03 +00:00
|
|
|
|
2025-10-28 16:10:34 +00:00
|
|
|
klass = exception.safe_constantize
|
|
|
|
|
|
|
|
|
|
error = if klass == Exceptions::ApplicationModel
|
|
|
|
|
klass.new(Ticket.first, message)
|
|
|
|
|
else
|
|
|
|
|
klass.new(message)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
raise error
|
2016-06-30 08:24:03 +00:00
|
|
|
end
|
|
|
|
|
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|