Sha256: 836c2da8a0c4859de01ccd32c4ca265aa5fd5e9e211364e2f4d794670ebc20ce

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

# some useful test objects

module ExceptionHandling
  module Testing
    class ControllerStub

      class Request
        attr_accessor :parameters, :protocol, :host, :request_uri, :env, :session_options

        def initialize
          @parameters  = { id: "1" }
          @protocol    = 'http'
          @host        = 'localhost'
          @request_uri = "/fun/testing.html?foo=bar"
          @env         = { HOST: "local" }
          @session_options = { id: '93951506217301' }
        end
      end

      attr_accessor :request, :session

      class << self
        attr_accessor :around_filter_method

        def around_filter(method)
          ControllerStub.around_filter_method = method
        end
      end

      def initialize
        @request = Request.new
        @session_id = "ZKL95"
        @session =
          if defined?(Username)
            {
              login_count: 22,
              username_id: Username.first.id,
              user_id: User.first.id,
            }
          else
            {}
          end
      end

      def simulate_around_filter(&block)
        set_current_controller(&block)
      end

      def controller_name
        "ControllerStub"
      end

      def action_name
        "test_action"
      end

      def complete_request_uri
        "#{@request.protocol}#{@request.host}#{@request.request_uri}"
      end

      include ExceptionHandling::Methods
      set_long_controller_action_timeout 2
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
exception_handling-2.6.1 lib/exception_handling/testing.rb
exception_handling-2.6.0 lib/exception_handling/testing.rb
exception_handling-2.5.1.pre.1 lib/exception_handling/testing.rb
exception_handling-2.5.0 lib/exception_handling/testing.rb
exception_handling-2.5.0.pre.2 lib/exception_handling/testing.rb
exception_handling-2.5.0.pre.1 lib/exception_handling/testing.rb
exception_handling-2.4.4.pre.1 lib/exception_handling/testing.rb
exception_handling-2.4.4 lib/exception_handling/testing.rb
exception_handling-2.4.3 lib/exception_handling/testing.rb
exception_handling-2.4.3.pre.2 lib/exception_handling/testing.rb
exception_handling-2.4.3.pre.1 lib/exception_handling/testing.rb
exception_handling-2.4.2 lib/exception_handling/testing.rb
exception_handling-2.4.1 lib/exception_handling/testing.rb
exception_handling-2.4.0 lib/exception_handling/testing.rb
exception_handling-2.4.0.pre.2 lib/exception_handling/testing.rb
exception_handling-2.4.0.pre.1 lib/exception_handling/testing.rb
exception_handling-3.0.pre.1 lib/exception_handling/testing.rb
exception_handling-2.3.0 lib/exception_handling/testing.rb
exception_handling-2.3.0.pre.1 lib/exception_handling/testing.rb