From a0c2d6db53f0d70bec0b89477792a310b297ad5c Mon Sep 17 00:00:00 2001 From: nathanvda Date: Sun, 8 Apr 2012 00:56:02 +0200 Subject: [PATCH] Make sure that we will not regress: when not passing locals to the partial, it should still work. This was reported in #54, but first fixed in #53. --- spec/cocoon_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/cocoon_spec.rb b/spec/cocoon_spec.rb index dc36ec2..bf2a2e1 100644 --- a/spec/cocoon_spec.rb +++ b/spec/cocoon_spec.rb @@ -81,14 +81,21 @@ describe Cocoon do end end - context "with extra render-options to pass locals to the partial" do - it "uses the correct plural" do + context "passing locals to the partial" do + it "when given: passes the locals to the partials" do @tester.unstub(:render_association) @form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call } @tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true, :alfred=>"Judoka"}).and_return ("partiallll") result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline', :locals => {:alfred => 'Judoka'}}) result.to_s.should == 'add something' end + it "if no locals are given it still works" do + @tester.unstub(:render_association) + @form_obj.should_receive(:fields_for) { | association, new_object, options_hash, &block| block.call } + @tester.should_receive(:render).with("person_fields", {:f=>nil, :dynamic=>true}).and_return ("partiallll") + result = @tester.link_to_add_association('add something', @form_obj, :people, :render_options => {:wrapper => 'inline'}) + result.to_s.should == 'add something' + end end