Sha256: da3771f628fb5d0f109001c286cfa42c828a065327358a816ceb0360b42a7c3f

Contents?: true

Size: 588 Bytes

Versions: 1

Compression:

Stored size: 588 Bytes

Contents

module AuthenticatedTestHelper
  # Sets the current user in the session from the user fixtures.
  def login_as(user)
    @request.session[:user_id] = user ? users(user).id : nil
  end

  def authorize_as(user)
    @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'monkey') : nil
  end

  # rspec
  def mock_user
    user = mock_model(User, :id => 1,
      :login  => 'user_name',
      :name   => 'U. Surname',
      :to_xml => "User-in-XML", :to_json => "User-in-JSON",
      :errors => [])
    user
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fassets_core-0.2.0 lib/authenticated_test_helper.rb