Sha256: 65dcd50911b7736dfb9b4f8756ae02b8f7bd39f20f41d8bc7a6527cff3d39b20

Contents?: true

Size: 1.86 KB

Versions: 7

Compression:

Stored size: 1.86 KB

Contents

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
# See vendor/plugins/authlogic/lib/authlogic/test_case.rb
#----------------------------------------------------------------------------
def activate_authlogic
  require 'authlogic/test_case/rails_request_adapter'
  require 'authlogic/test_case/mock_cookie_jar'
  require 'authlogic/test_case/mock_request'

  Authlogic::Session::Base.controller = (@request && Authlogic::TestCase::RailsRequestAdapter.new(@request)) || controller
end

# Note: Authentication is NOT ActiveRecord model, so we mock and stub it using RSpec.
#----------------------------------------------------------------------------
def login(user_stubs = {}, session_stubs = {})
  User.current_user = @current_user = FactoryGirl.create(:user, user_stubs)
  @current_user_session = double(Authentication, {:record => current_user}.merge(session_stubs))
  Authentication.stub(:find).and_return(@current_user_session)
  #set_timezone
end
alias :require_user :login

#----------------------------------------------------------------------------
def login_and_assign(user_stubs = {}, session_stubs = {})
  login(user_stubs, session_stubs)
  assigns[:current_user] = current_user
end

#----------------------------------------------------------------------------
def logout
  @current_user = nil
  @current_user_session = nil
  Authentication.stub(:find).and_return(nil)
end
alias :require_no_user :logout

#----------------------------------------------------------------------------
def current_user
  @current_user
end

#----------------------------------------------------------------------------
def current_user_session
  @current_user_session
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fat_free_crm-0.13.6 spec/support/auth_macros.rb
fat_free_crm-0.13.5 spec/support/auth_macros.rb
fat_free_crm-0.13.4 spec/support/auth_macros.rb
fat_free_crm-0.13.3 spec/support/auth_macros.rb
fat_free_crm-0.13.2 spec/support/auth_macros.rb
fat_free_crm-0.13.1 spec/support/auth_macros.rb
fat_free_crm-0.13.0 spec/support/auth_macros.rb