Sha256: 7e87dade93b668a7e438e2fae37867bfb25b618421cc59038ffb7d9ea4b4ed15
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module Scrivito # # @api public # module TestRequest ROUTING_ERRORS = [ AbstractController::ActionNotFound, ActionController::RoutingError, ActionController::UrlGenerationError, ] # # Make a test request to act as a CMS request. # This is necessary for testing controllers that include {Scrivito::ControllerActions}, because # these controllers do not have explicit routes by default. # # @api public # @param [Scrivito::BasicObj Obj] test_obj requested +Obj+ # # @example # class MyPageControllerTest < ActionController::TestCase # test 'should respond with success' do # request.for_scrivito_obj # get :index # assert_response :success # end # end # def for_scrivito_obj(test_obj = nil) env[Scrivito::CmsEnv::OBJ_ENV_KEY] = test_obj if test_obj class << self def assign_parameters(routes, controller_path, action, parameters = {}) super routes, controller_path, action, parameters rescue *ROUTING_ERRORS => e begin super routes, 'scrivito/cms_dispatch', action, parameters rescue *ROUTING_ERRORS raise e end end end end def for_cms_object(*args) raise "The method `for_cms_object' was removed. Please use `for_scrivito_obj' instead" end end end
Version data entries
4 entries across 4 versions & 1 rubygems