Sha256: dbeb07b86d1dc84474c5201eec453d28c3765c50cc90fbfa51bc82ee89febfb9

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class ActiveRecordAuthenticatesManyTest < ActiveSupport::TestCase
  def test_authenticates_many_new
    binary_logic = companies(:binary_logic)
    user_session = binary_logic.user_sessions.new
    assert_equal({:find_options => {:conditions => "\"users\".company_id = #{binary_logic.id}"}, :id => nil}, user_session.scope)
    
    employee_session = binary_logic.employee_sessions.new
    assert_equal({:find_options => {:conditions => "\"employees\".company_id = #{binary_logic.id}"}, :id => nil}, employee_session.scope)
  end
  
  def test_authenticates_many_create_and_find
    binary_logic = companies(:binary_logic)
    logic_over_data = companies(:logic_over_data)
    ben = users(:ben)
    zack = users(:zack)
    
    assert !binary_logic.user_sessions.find
    assert !logic_over_data.user_sessions.find
    assert logic_over_data.user_sessions.create(zack)
    assert !binary_logic.user_sessions.find
    assert logic_over_data.user_sessions.find
    assert binary_logic.user_sessions.create(ben)
    assert binary_logic.user_sessions.find
    assert !logic_over_data.user_sessions.find
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-1.0.0 test/active_record_authenticates_many_test.rb