Sha256: eeb5a5037f2a29810f6dbb2c4f8111d0b947e4d874d703189e3eb943b7774066

Contents?: true

Size: 750 Bytes

Versions: 9

Compression:

Stored size: 750 Bytes

Contents

module ControllerTestHelpers
  def visit(action, params = {}, options = {})
    method = options.delete(:method) || :get

    user = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"]
    password = ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"]

    if options[:auth] == :disabled
      ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = nil
      ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = nil
    else
      request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(
        options[:user] || user, options[:password] || password
      ) unless options[:auth] == false
    end

    send(method, action, params)

    ENV["RESQUE_WEB_HTTP_BASIC_AUTH_USER"] = user
    ENV["RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD"] = password
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
resque-web-0.0.8 test/support/controller_test_helpers.rb
resque-web-edge-1.0.0 test/support/controller_test_helpers.rb
resque-web-0.0.7 test/support/controller_test_helpers.rb
resque-web-clone-0.0.7 test/support/controller_test_helpers.rb
resque-web-clone-0.0.6 test/support/controller_test_helpers.rb
resque-web-0.0.6 test/support/controller_test_helpers.rb
glebtv_resque_web-0.1.0 test/support/controller_test_helpers.rb
resque-web-0.0.5 test/support/controller_test_helpers.rb
resque-web-0.0.4 test/support/controller_test_helpers.rb