tests_controller.rb 806 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class TestsController < ApplicationController
  3. prepend_before_action -> { authentication_check_only }
  4. layout 'tests', except: %i[wait raised_exception]
  5. def show
  6. @filename = params[:name]
  7. if lookup_context.exists? @filename, 'tests'
  8. render @filename
  9. elsif @filename.starts_with? 'form'
  10. render 'form'
  11. else
  12. render
  13. end
  14. end
  15. # GET /tests/wait
  16. def wait
  17. sleep params[:sec].to_i
  18. result = { success: true }
  19. render json: result
  20. end
  21. # GET /tests/raised_exception
  22. def error_raised_exception
  23. exception = params.fetch(:exception, 'StandardError')
  24. message = params.fetch(:message, 'no message provided')
  25. raise exception.safe_constantize, message
  26. end
  27. end