diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-01 03:53:39 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-01 03:53:39 +0000 |
commit | a6a1dc967cb65ac3f842d15f89eef7e32f7547cf (patch) | |
tree | 0d49ee17962c31f2218b6dc3a45fe4b5281aa011 /actionpack/test/activerecord | |
parent | b05fc40b5d096695dad5b3282664512d7509a529 (diff) | |
download | rails-a6a1dc967cb65ac3f842d15f89eef7e32f7547cf.tar.gz rails-a6a1dc967cb65ac3f842d15f89eef7e32f7547cf.tar.bz2 rails-a6a1dc967cb65ac3f842d15f89eef7e32f7547cf.zip |
render :partial recognizes Active Record associations as Arrays. Closes #8538.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6920 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/activerecord')
-rw-r--r-- | actionpack/test/activerecord/render_partial_with_record_identification_test.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb new file mode 100644 index 0000000000..7aeb1192f1 --- /dev/null +++ b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb @@ -0,0 +1,64 @@ +require File.dirname(__FILE__) + '/../active_record_unit' + +class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase + fixtures :developers, :projects, :developers_projects, :topics, :replies + + class RenderPartialWithRecordIdentificationController < ActionController::Base + def render_with_has_many_and_belongs_to_association + @developer = Developer.find(1) + render :partial => @developer.projects + end + + def render_with_has_many_association + @topic = Topic.find(1) + render :partial => @topic.replies + end + + def render_with_belongs_to_association + @reply = Reply.find(1) + render :partial => @reply.topic + end + + def render_with_record + @developer = Developer.find(:first) + render :partial => @developer + end + + def render_with_record_collection + @developers = Developer.find(:all) + render :partial => @developers + end + end + + def setup + @controller = RenderPartialWithRecordIdentificationController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + super + end + + def test_rendering_partial_with_has_many_and_belongs_to_association + get :render_with_has_many_and_belongs_to_association + assert_template 'projects/_project' + end + + def test_rendering_partial_with_has_many_association + get :render_with_has_many_association + assert_template 'replies/_reply' + end + + def test_rendering_partial_with_belongs_to_association + get :render_with_belongs_to_association + assert_template 'topics/_topic' + end + + def test_render_with_record + get :render_with_record + assert_template 'developers/_developer' + end + + def test_render_with_record_collection + get :render_with_record_collection + assert_template 'developers/_developer' + end +end |