Merge pull request #53 from CuriousCurmudgeon/master
Options not passed to link_to_add_association when using a block
This commit is contained in:
commit
c8bf134032
@ -33,7 +33,7 @@ module Cocoon
|
||||
# :nodoc:
|
||||
def render_association(association, f, new_object, render_options={}, custom_partial=nil)
|
||||
partial = setup_partial(custom_partial, association)
|
||||
locals = render_options.delete(:locals)
|
||||
locals = render_options.delete(:locals) || {}
|
||||
method_name = f.respond_to?(:semantic_fields_for) ? :semantic_fields_for : (f.respond_to?(:simple_fields_for) ? :simple_fields_for : :fields_for)
|
||||
f.send(method_name, association, new_object, {:child_index => "new_#{association}"}.merge(render_options)) do |builder|
|
||||
partial_options = {:f => builder, :dynamic => true}.merge(locals)
|
||||
@ -58,7 +58,7 @@ module Cocoon
|
||||
association = args[1]
|
||||
html_options = args[2] || {}
|
||||
options = args[3] || {}
|
||||
link_to_add_association(capture(&block), f, association, html_options)
|
||||
link_to_add_association(capture(&block), f, association, html_options, options)
|
||||
else
|
||||
name = args[0]
|
||||
f = args[1]
|
||||
|
@ -45,6 +45,14 @@ describe Cocoon do
|
||||
result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="form<tag>">some long name</a>'
|
||||
end
|
||||
|
||||
it "accepts options and passes them to link_to" do
|
||||
@tester.unstub(:render_association)
|
||||
@tester.should_receive(:render_association).with(anything(), anything(), anything(), anything(), "shared/partial").and_return('partiallll')
|
||||
result = @tester.link_to_add_association( @form_obj, :comments, {:class => 'floppy disk'}, {:partial => "shared/partial"}) do
|
||||
"some long name"
|
||||
end
|
||||
result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="partiallll">some long name</a>'
|
||||
end
|
||||
end
|
||||
|
||||
context "with an irregular plural" do
|
||||
|
Loading…
Reference in New Issue
Block a user