1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed render :partial => @collection.named_scope (nkallen) [#61 state:resolved]

This commit is contained in:
David Heinemeier Hansson 2008-04-30 14:42:44 -05:00
parent a6cca5d1fc
commit a3da293b33
3 changed files with 9 additions and 11 deletions

View file

@ -111,7 +111,7 @@ module ActionView
when ActionView::Helpers::FormBuilder when ActionView::Helpers::FormBuilder
builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '') builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '')
render_partial(builder_partial_path, object_assigns, (local_assigns || {}).merge(builder_partial_path.to_sym => partial_path)) render_partial(builder_partial_path, object_assigns, (local_assigns || {}).merge(builder_partial_path.to_sym => partial_path))
when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::Associations::HasManyThroughAssociation when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope
if partial_path.any? if partial_path.any?
collection = partial_path collection = partial_path
render_partial_collection(nil, collection, nil, local_assigns) render_partial_collection(nil, collection, nil, local_assigns)

View file

@ -14,6 +14,10 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
render :partial => @topic.replies render :partial => @topic.replies
end end
def render_with_named_scope
render :partial => Reply.base
end
def render_with_has_many_through_association def render_with_has_many_through_association
@developer = Developer.find(:first) @developer = Developer.find(:first)
render :partial => @developer.topics render :partial => @developer.topics
@ -53,16 +57,9 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
assert_template 'replies/_reply' assert_template 'replies/_reply'
end end
def test_rendering_partial_with_has_many_association def test_rendering_partial_with_named_scope
get :render_with_has_many_through_association get :render_with_named_scope
assert_template 'topics/_topic' assert_template 'replies/_reply'
end
def test_rendering_partial_with_belongs_to_association
topic = Reply.find(1).topic
get :render_with_belongs_to_association
assert_template 'topics/_topic'
assert_equal topic.title, @response.body
end end
def test_render_with_record def test_render_with_record

View file

@ -1,4 +1,5 @@
class Reply < ActiveRecord::Base class Reply < ActiveRecord::Base
named_scope :base
belongs_to :topic, :include => [:replies] belongs_to :topic, :include => [:replies]
belongs_to :developer belongs_to :developer