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

Ticket #9051: has_many_through_rendered_as_collection_updated.diff

File has_many_through_rendered_as_collection_updated.diff, 3.5 kB (added by danger, 1 year ago)

same patch as above - updated to latest trunk

  • actionpack/test/fixtures/db_definitions/sqlite.sql

    old new  
    99  'content' text,  
    1010  'created_at' datetime,  
    1111  'updated_at' datetime,  
    12   'topic_id' integer 
     12  'topic_id' integer, 
     13  'developer_id' integer 
    1314); 
    1415 
    1516CREATE TABLE 'topics' ( 
  • actionpack/test/fixtures/developer.rb

    old new  
    11class Developer < ActiveRecord::Base 
    22  has_and_belongs_to_many :projects 
     3  has_many :replies 
     4  has_many :topics, :through => :replies 
    35end 
    46 
    57class DeVeLoPeR < ActiveRecord::Base 
  • actionpack/test/fixtures/reply.rb

    old new  
    11class Reply < ActiveRecord::Base 
    22  belongs_to :topic, :include => [:replies] 
    3    
     3  belongs_to :developer 
     4 
    45  validates_presence_of :content 
    56end 
  • actionpack/test/fixtures/replies.yml

    old new  
    11witty_retort: 
    22  id: 1 
    33  topic_id: 1 
     4  developer_id: 1 
    45  content: Birdman is better! 
    56  created_at: <%= 6.hours.ago.to_s(:db) %> 
    67  updated_at: nil 
     
    89another: 
    910  id: 2 
    1011  topic_id: 2 
     12  developer_id: 1 
    1113  content: Nuh uh! 
    1214  created_at: <%= 1.hour.ago.to_s(:db) %> 
    1315  updated_at: nil 
  • actionpack/test/activerecord/render_partial_with_record_identification_test.rb

    old new  
    1414      render :partial => @topic.replies 
    1515    end 
    1616     
     17    def render_with_has_many_through_association 
     18      @developer = Developer.find(:first) 
     19      render :partial => @developer.topics 
     20    end 
     21     
    1722    def render_with_belongs_to_association 
    1823      @reply = Reply.find(1) 
    1924      render :partial => @reply.topic 
     
    4752    assert_template 'replies/_reply' 
    4853  end 
    4954   
     55  def test_rendering_partial_with_has_many_association 
     56    get :render_with_has_many_through_association 
     57    assert_template 'topics/_topic' 
     58  end 
     59   
    5060  def test_rendering_partial_with_belongs_to_association 
    5161    get :render_with_belongs_to_association 
    5262    assert_template 'topics/_topic' 
  • actionpack/lib/action_view/partials.rb

    old new  
    119119          else 
    120120            render("#{path}/_#{partial_name}", local_assigns) 
    121121          end 
    122         when Array, ActiveRecord::Associations::AssociationCollection 
     122        when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::Associations::HasManyThroughAssociation 
    123123          if partial_path.any? 
    124124            path       = ActionController::RecordIdentifier.partial_path(partial_path.first) 
    125125            collection = partial_path