cocoon 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.18
1
+ 1.0.19
data/cocoon.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cocoon"
8
- s.version = "1.0.18"
8
+ s.version = "1.0.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Van der Auwera"]
@@ -33,7 +33,7 @@ module Cocoon
33
33
  # :nodoc:
34
34
  def render_association(association, f, new_object, render_options={}, custom_partial=nil)
35
35
  partial = setup_partial(custom_partial, association)
36
- locals = render_options.delete(:locals)
36
+ locals = render_options.delete(:locals) || {}
37
37
  method_name = f.respond_to?(:semantic_fields_for) ? :semantic_fields_for : (f.respond_to?(:simple_fields_for) ? :simple_fields_for : :fields_for)
38
38
  f.send(method_name, association, new_object, {:child_index => "new_#{association}"}.merge(render_options)) do |builder|
39
39
  partial_options = {:f => builder, :dynamic => true}.merge(locals)
@@ -58,7 +58,7 @@ module Cocoon
58
58
  association = args[1]
59
59
  html_options = args[2] || {}
60
60
  options = args[3] || {}
61
- link_to_add_association(capture(&block), f, association, html_options)
61
+ link_to_add_association(capture(&block), f, association, html_options, options)
62
62
  else
63
63
  name = args[0]
64
64
  f = args[1]
data/spec/cocoon_spec.rb CHANGED
@@ -45,6 +45,14 @@ describe Cocoon do
45
45
  result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="form&lt;tag&gt;">some long name</a>'
46
46
  end
47
47
 
48
+ it "accepts options and passes them to link_to" do
49
+ @tester.unstub(:render_association)
50
+ @tester.should_receive(:render_association).with(anything(), anything(), anything(), anything(), "shared/partial").and_return('partiallll')
51
+ result = @tester.link_to_add_association( @form_obj, :comments, {:class => 'floppy disk'}, {:partial => "shared/partial"}) do
52
+ "some long name"
53
+ end
54
+ result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="partiallll">some long name</a>'
55
+ end
48
56
  end
49
57
 
50
58
  context "with an irregular plural" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 18
10
- version: 1.0.18
9
+ - 19
10
+ version: 1.0.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan Van der Auwera