Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3043

Show
Ignore:
Timestamp:
11/15/05 10:48:32 (3 years ago)
Author:
bitsweat
Message:

Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. Closes #1345.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3035 r3043  
    11*SVN* 
     2 
     3* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array.  #1345 [MarkusQ@reality.com] 
    24 
    35* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY.  #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>] 
  • trunk/activerecord/lib/active_record/associations/association_proxy.rb

    r2861 r3043  
    1818      end 
    1919       
     20      def respond_to?(symbol, include_priv = false) 
     21        proxy_respond_to?(symbol, include_priv) || (load_target && @target.respond_to?(symbol, include_priv)) 
     22      end 
     23 
     24      # Explicitly proxy === because the instance method removal above 
     25      # doesn't catch it. 
     26      def ===(other) 
     27        load_target 
     28        other === @target 
     29      end 
     30 
    2031      def reload 
    2132        reset 
    2233        load_target 
    23       end 
    24  
    25       def respond_to?(symbol, include_priv = false) 
    26         proxy_respond_to?(symbol, include_priv) || (load_target && @target.respond_to?(symbol, include_priv)) 
    2734      end 
    2835 
  • trunk/activerecord/test/associations_test.rb

    r2974 r3043  
    8080  def test_triple_equality 
    8181    assert Account === companies(:first_firm).account 
     82    assert companies(:first_firm).account === Account 
    8283  end 
    8384 
     
    279280  def test_finding 
    280281    assert_equal 2, Firm.find(:first).clients.length 
     282  end 
     283 
     284  def test_triple_equality 
     285    assert !(Array === Firm.find(:first).clients) 
     286    assert Firm.find(:first).clients === Array 
    281287  end 
    282288 
     
    748754  end 
    749755 
     756  def test_triple_equality 
     757    assert Client.find(3).firm === Firm 
     758    assert Firm === Client.find(3).firm 
     759  end 
     760 
    750761  def test_type_mismatch 
    751762    assert_raise(ActiveRecord::AssociationTypeMismatch) { Account.find(1).firm = 1 } 
     
    10251036    assert_equal 2, active_record.developers.size 
    10261037    assert active_record.developers.include?(david) 
     1038  end 
     1039 
     1040  def test_triple_equality 
     1041    assert !(Array === Developer.find(1).projects) 
     1042    assert Developer.find(1).projects === Array 
    10271043  end 
    10281044