Sha256: 65613b05d4014f8b5252e653064ab4a8b0c447db824ff0c6f215a1a425f23914

Contents?: true

Size: 823 Bytes

Versions: 2

Compression:

Stored size: 823 Bytes

Contents

module ApiMacros

  USER_TOKEN_FIELD = 'X-User-Token'

  def request_with_user_session(method, path, params={}, headers={})
    headers.merge!(USER_TOKEN_FIELD => retrieve_access_token)
    send(method, path, params: params, headers: headers)
  end

  def get_with_token(path, params={}, headers={})
    headers.merge!(USER_TOKEN_FIELD => @user.authentication_token)
    get path, params: params, headers: headers
  end

  # make a POST with
  def post_with_token(path, params={}, headers={})
    headers.merge!(USER_TOKEN_FIELD => @user.authentication_token)
    post path, params: params, headers: headers
  end

  # stub out authenticate_request
  def stub_request
    ApplicationController.any_instance.stub(:authenticate_request) { true }
  end

  # Rails.application shortcut
  def app
    Rails.application
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devise_meteor-0.1.1 spec/support/api_macros.rb
devise_meteor-0.1.0 spec/support/api_macros.rb