cocoon 1.0.20 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -105,8 +105,8 @@ Inside our `projects/_form` partial we then write:
105
105
  = render 'task_fields', :f => task
106
106
  .links
107
107
  = link_to_add_association 'add task', f, :tasks
108
- -f.buttons do
109
- = f.submit 'Save'
108
+ -f.actions do
109
+ = f.action :submit
110
110
  ````
111
111
 
112
112
  and inside the `_task_fields` partial we write:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.20
1
+ 1.0.21
data/cocoon.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cocoon"
8
- s.version = "1.0.20"
8
+ s.version = "1.0.21"
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"]
12
- s.date = "2012-04-09"
12
+ s.date = "2012-05-09"
13
13
  s.description = "Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven."
14
14
  s.email = "nathan@dixis.com"
15
15
  s.extra_rdoc_files = [
@@ -84,9 +84,13 @@ module Cocoon
84
84
  # will create new Comment with author "Admin"
85
85
 
86
86
  def create_object(f, association)
87
- assoc = f.object.class.reflect_on_association(association)
88
- conditions = assoc.respond_to?(:conditions) ? assoc.conditions.flatten : []
89
- new_object = assoc.klass.new(*conditions)
87
+ assoc = f.object.class.reflect_on_association(association)
88
+
89
+ if assoc.collection?
90
+ f.object.send(association).build
91
+ else
92
+ f.object.send("build_#{association}")
93
+ end
90
94
  end
91
95
 
92
96
  def get_partial_path(partial, association)
data/spec/cocoon_spec.rb CHANGED
@@ -175,11 +175,16 @@ describe Cocoon do
175
175
  end
176
176
  end
177
177
 
178
- context "association with conditions" do
179
- it "should create correct association" do
178
+ context "create_object" do
179
+ it "should create correct association with conditions" do
180
180
  result = @tester.create_object(@form_obj, :admin_comments)
181
181
  result.author.should == "Admin"
182
182
  end
183
+
184
+ it "should create correct association for belongs_to associations" do
185
+ result = @tester.create_object(stub(:object => Comment.new), :post)
186
+ result.should be_a Post
187
+ end
183
188
  end
184
189
 
185
190
  context "get_partial_path" do
@@ -1,3 +1,5 @@
1
1
  class Comment < ActiveRecord::Base
2
2
  belongs_to :post
3
+
4
+ attr_protected :author
3
5
  end
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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 20
10
- version: 1.0.20
9
+ - 21
10
+ version: 1.0.21
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan Van der Auwera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-09 00:00:00 Z
18
+ date: 2012-05-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement