Class: ActionController::TestRequest — Documentation by YARD 0.9.45

# Class: ActionController::TestRequest

Inherits:
  Object
  - Object
  - ActionController::TestRequest
  show all

Defined in:
  lib/oauth/client/action_controller_request.rb

## Constant Summary collapse

OAUTH_ENABLED_KEY =

      :oauth_action_controller_test_request_use_oauth

## Class Method Summary collapse

- .use_oauth=(value) ⇒ Object
- .use_oauth? ⇒ Boolean

## Instance Method Summary collapse

- #apply_oauth! ⇒ Object
- #configure_oauth(consumer = nil, token = nil, options = {}) ⇒ Object
- #set_oauth_header ⇒ Object
- #set_oauth_parameters ⇒ Object
- #set_oauth_query_string ⇒ Object

## Class Method Details

### .use_oauth=(value) ⇒ `Object`

    32
    33
    34
    # File 'lib/oauth/client/action_controller_request.rb', line 32

    def use_oauth=(value)
      Thread.current[OAUTH_ENABLED_KEY] = value
    end

### .use_oauth? ⇒ `Boolean`

Returns:

- (`Boolean`)

    36
    37
    38
    # File 'lib/oauth/client/action_controller_request.rb', line 36

    def use_oauth?
      Thread.current[OAUTH_ENABLED_KEY]
    end

## Instance Method Details

### #apply_oauth! ⇒ `Object`

    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    # File 'lib/oauth/client/action_controller_request.rb', line 52

    def apply_oauth!
      return unless ActionController::TestRequest.use_oauth? && @oauth_options

      @oauth_helper = OAuth::Client::Helper.new(
        self,
        @oauth_options.merge(request_uri: (respond_to?(:fullpath) ? fullpath : request_uri))
      )
      @oauth_helper.amend_user_agent_header(env)

      send("set_oauth_#{@oauth_options[:scheme]}")
    end

### #configure_oauth(consumer = nil, token = nil, options = {}) ⇒ `Object`

    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    # File 'lib/oauth/client/action_controller_request.rb', line 41

    def configure_oauth(consumer = nil, token = nil, options = {})
      @oauth_options = {
        consumer: consumer,
        token: token,
        scheme: "header",
        signature_method: nil,
        nonce: nil,
        timestamp: nil
      }.merge(options)
    end

### #set_oauth_header ⇒ `Object`

    64
    65
    66
    # File 'lib/oauth/client/action_controller_request.rb', line 64

    def set_oauth_header
      env["Authorization"] = @oauth_helper.header
    end

### #set_oauth_parameters ⇒ `Object`

    68
    69
    70
    71
    # File 'lib/oauth/client/action_controller_request.rb', line 68

    def set_oauth_parameters
      @query_parameters = @oauth_helper.parameters_with_oauth
      @query_parameters.merge!(oauth_signature: @oauth_helper.signature)
    end

### #set_oauth_query_string ⇒ `Object`

    73
    74
    # File 'lib/oauth/client/action_controller_request.rb', line 73

    def set_oauth_query_string
    end