nested_form_fields 0.7 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -1
- data/Gemfile +0 -2
- data/README.md +174 -73
- data/lib/assets/javascripts/nested_form_fields.js.coffee +20 -10
- data/lib/nested_form_fields/version.rb +1 -1
- data/lib/nested_form_fields.rb +21 -6
- data/nested_form_fields.gemspec +11 -7
- data/spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/application.css.scssc +0 -0
- data/spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/normalize.css.scssc +0 -0
- data/spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/users.css.scssc +0 -0
- data/spec/dummy/app/views/users/edit.html.haml +2 -1
- data/spec/dummy/log/development.log +273 -0
- data/spec/integration/nested_form_fields_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- metadata +83 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 236d8d7b63143d4f30595622869bee46712a055ef652de7fd57ae6b754d8e19f
|
4
|
+
data.tar.gz: fc404d3d852c8d65097a2559478e8fb7057cdf7d4aab93f151accec28366c3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b77de97deb51cbe1022d436f41d22f9fb89a559d22aa02477d5f7cd8c5d08eb500090c6c5a6771bc437567edffeca7a8edba99543b545693f5123f04570e11b4
|
7
|
+
data.tar.gz: ea3b05a99b66042edf6e48798bd8be2903dddad0638d7cb89cb0d370a4673abcd762d05d99453335efdd9e858a982c53f0e399e37578b17567e14535546ae44b
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,8 +5,8 @@ This Rails gem helps creating forms for models with nested has_many associations
|
|
5
5
|
It uses jQuery to dynamically add and remove nested associations.
|
6
6
|
|
7
7
|
- Works for arbitrarily deeply nested associations (tested up to 4 levels).
|
8
|
-
- Works with form builders like simple_form.
|
9
|
-
- Requires Ruby 1.9 and the Rails asset pipeline
|
8
|
+
- Works with form builders like [simple_form](https://github.com/plataformatec/simple_form).
|
9
|
+
- Requires Ruby 1.9+ and the Rails asset pipeline.
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -14,115 +14,216 @@ It uses jQuery to dynamically add and remove nested associations.
|
|
14
14
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'nested_form_fields'
|
19
|
+
```
|
18
20
|
|
19
21
|
And then execute:
|
20
22
|
|
21
|
-
|
23
|
+
```console
|
24
|
+
$ bundle
|
25
|
+
```
|
22
26
|
|
23
27
|
In your application.js file add:
|
24
28
|
|
25
|
-
|
29
|
+
```javascript
|
30
|
+
//= require nested_form_fields
|
31
|
+
```
|
32
|
+
|
33
|
+
### Rails 5.1+
|
34
|
+
|
35
|
+
You will need to install jQuery as Rails dropped it from its default stack.
|
36
|
+
|
37
|
+
Add to Gemfile:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
gem 'jquery-rails'
|
41
|
+
```
|
42
|
+
|
43
|
+
Execute:
|
44
|
+
|
45
|
+
```console
|
46
|
+
$ bundle
|
47
|
+
```
|
48
|
+
|
49
|
+
Add to application.js:
|
50
|
+
|
51
|
+
```javascript
|
52
|
+
//= require jquery3
|
53
|
+
//= require jquery_ujs
|
54
|
+
```
|
26
55
|
|
27
56
|
## Usage
|
28
57
|
|
29
58
|
Assume you have a user model with nested videos:
|
30
59
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
60
|
+
```ruby
|
61
|
+
class User < ActiveRecord::Base
|
62
|
+
has_many :videos
|
63
|
+
accepts_nested_attributes_for :videos, allow_destroy: true
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
Use the `nested_fields_for` helper inside your user form to add the video fields:
|
35
68
|
|
36
|
-
|
69
|
+
```haml
|
70
|
+
= form_for @user do |f|
|
71
|
+
= f.nested_fields_for :videos do |ff|
|
72
|
+
= ff.text_field :video_title
|
73
|
+
..
|
74
|
+
```
|
75
|
+
|
76
|
+
Links to add and remove fields can be added using the `add_nested_fields_link` and `remove_nested_fields_link` helpers:
|
37
77
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
78
|
+
```haml
|
79
|
+
= form_for @user do |f|
|
80
|
+
= f.nested_fields_for :videos do |ff|
|
81
|
+
= ff.remove_nested_fields_link
|
82
|
+
= ff.text_field :video_title
|
83
|
+
..
|
84
|
+
= f.add_nested_fields_link :videos
|
85
|
+
```
|
42
86
|
|
43
|
-
|
87
|
+
Note that `remove_nested_fields_link` needs to be called within the `nested_fields_for` call and `add_nested_fields_link` outside of it via the parent builder.
|
44
88
|
|
45
|
-
|
46
|
-
= f.nested_fields_for :videos do |ff|
|
47
|
-
= ff.remove_nested_fields_link
|
48
|
-
= ff.text_field :video_title
|
49
|
-
..
|
50
|
-
= f.add_nested_fields_link :videos
|
89
|
+
## Link Customization
|
51
90
|
|
52
|
-
|
91
|
+
You can change the link text of `remove_nested_fields_link` and `add_nested_fields_link` like this:
|
53
92
|
|
54
|
-
|
93
|
+
```haml
|
94
|
+
...
|
95
|
+
ff.remove_nested_fields_link 'Remove me'
|
96
|
+
...
|
97
|
+
f.add_nested_fields_link :videos, 'Add another funtastic video'
|
98
|
+
```
|
55
99
|
|
56
|
-
|
57
|
-
ff.remove_nested_fields_link 'Remove me'
|
58
|
-
...
|
59
|
-
f.add_nested_fields_link :videos, 'Add another funtastic video'
|
100
|
+
You can add classes/attributes to the `remove_nested_fields_link` and `add_nested_fields_link` like this:
|
60
101
|
|
61
|
-
|
102
|
+
```haml
|
103
|
+
...
|
104
|
+
ff.remove_nested_fields_link 'Remove me', class: 'btn btn-danger', role: 'button'
|
105
|
+
...
|
106
|
+
f.add_nested_fields_link :videos, 'Add another funtastic video', class: 'btn btn-primary', role: 'button'
|
107
|
+
```
|
62
108
|
|
63
|
-
|
64
|
-
ff.remove_nested_fields_link 'Remove me', class: 'btn btn-danger', role: 'button'
|
65
|
-
...
|
66
|
-
f.add_nested_fields_link :videos, 'Add another funtastic video', class: 'btn btn-primary', role: 'button'
|
109
|
+
You can supply a block to the `remove_nested_fields_link` and the `add_nested_fields_link` helpers, as you can with `link_to`:
|
67
110
|
|
68
|
-
|
111
|
+
```haml
|
112
|
+
= ff.remove_nested_fields_link do
|
113
|
+
Remove me %span.icon-trash
|
114
|
+
```
|
69
115
|
|
70
|
-
|
116
|
+
You can add a `data-confirm` attribute to the `remove_nested_fields_link` if you want the user to confirm whenever they remove a nested field:
|
117
|
+
|
118
|
+
```haml
|
119
|
+
= ff.remove_nested_fields_link 'Remove me', data: { confirm: 'Are you sure?' }
|
120
|
+
```
|
121
|
+
|
122
|
+
## Custom Container
|
123
|
+
|
124
|
+
You can specify a custom container to add nested forms into, by supplying an id via the `data-insert-into` attribute of the `add_nested_fields_link`:
|
125
|
+
|
126
|
+
```haml
|
127
|
+
f.add_nested_fields_link :videos, 'Add another funtastic video', data: { insert_into: '<container_id>' }
|
128
|
+
```
|
129
|
+
|
130
|
+
## Custom Fields Wrapper
|
131
|
+
|
132
|
+
You can change the type of the element wrapping the nested fields using the `wrapper_tag` option:
|
133
|
+
|
134
|
+
```haml
|
135
|
+
= f.nested_fields_for :videos, wrapper_tag: :div do |ff|
|
136
|
+
```
|
71
137
|
|
72
138
|
The default wrapper element is a fieldset. To add legend element to the fieldset use:
|
73
139
|
|
74
|
-
|
140
|
+
```haml
|
141
|
+
= f.nested_fields_for :videos, legend: "Video" do |ff|
|
142
|
+
```
|
75
143
|
|
76
144
|
You can pass options like you would to the `content_tag` method by nesting them in a `:wrapper_options` hash:
|
77
145
|
|
78
|
-
|
146
|
+
```haml
|
147
|
+
= f.nested_fields_for :videos, wrapper_options: { class: 'row' } do |ff|
|
148
|
+
```
|
149
|
+
|
150
|
+
## Rails 4 Parameter Whitelisting
|
79
151
|
|
80
|
-
If you are using Rails 4 remember to add
|
81
|
-
|
152
|
+
If you are using Rails 4 remember to add {{ NESTED_MODEL }}_attributes and the attributes to the permitted params.
|
153
|
+
If you want to destroy the nested model you should add `:_destroy` and `:id`.
|
82
154
|
For example:
|
83
155
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
= f.add_nested_fields_link :videos
|
91
|
-
|
92
|
-
# app/controllers/users_controller
|
156
|
+
```haml
|
157
|
+
# app/views/users/_form.haml.erb
|
158
|
+
= form_for @user do |f|
|
159
|
+
= f.nested_fields_for :videos do |ff|
|
160
|
+
= ff.remove_nested_fields_link
|
161
|
+
= ff.text_field :video_title
|
93
162
|
..
|
94
|
-
|
95
|
-
|
96
|
-
.permit(:name,:email,videos_attributes:[:video_title,:_destroy,:id])
|
97
|
-
# ^^^ ^^^ ^^^
|
98
|
-
# nested model attrs
|
99
|
-
# they will let you delete the nested model
|
100
|
-
end
|
163
|
+
= f.add_nested_fields_link :videos
|
164
|
+
```
|
101
165
|
|
166
|
+
```ruby
|
167
|
+
# app/controllers/users_controller
|
168
|
+
..
|
169
|
+
def user_params
|
170
|
+
params.require(:user)
|
171
|
+
.permit(:name,:email,videos_attributes:[:video_title,:_destroy,:id])
|
172
|
+
# ^^^ ^^^ ^^^
|
173
|
+
# nested model attrs
|
174
|
+
# they will let you delete the nested model
|
175
|
+
end
|
176
|
+
```
|
102
177
|
|
103
|
-
|
104
|
-
fields_adding, fields_added, fields_removing, fields_removed.
|
178
|
+
## Events
|
105
179
|
|
106
|
-
|
107
|
-
This makes it easy to add listeners when you have multiple nested_form_fields on the same page.
|
180
|
+
There are four JavaScript events firing before and after addition/removal of the fields in the `nested_form_fields` namespace:
|
108
181
|
|
109
|
-
|
182
|
+
- `fields_adding`
|
183
|
+
- `fields_added`
|
184
|
+
- `fields_removing`
|
185
|
+
- `fields_removed`
|
110
186
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
console.log event.target # The added field
|
116
|
-
console.log $(this) # $el
|
117
|
-
|
118
|
-
# Listen on document
|
119
|
-
$(document).on "fields_added.nested_form_fields", (event,param) ->
|
120
|
-
switch param.object_class
|
121
|
-
when "video"
|
122
|
-
console.log "Video object added"
|
123
|
-
else
|
124
|
-
console.log "INFO: Fields were successfully added, callback not handled."
|
187
|
+
The events `fields_added` and `fields_removed` are triggered on the element being added or removed. The events bubble up so you can listen for them on any parent element.
|
188
|
+
This makes it easy to add listeners when you have multiple `nested_form_fields` on the same page.
|
189
|
+
|
190
|
+
CoffeeScript samples:
|
125
191
|
|
192
|
+
```coffeescript
|
193
|
+
# Listen on an element
|
194
|
+
initializeSortable -> ($el)
|
195
|
+
$el.sortable(...)
|
196
|
+
$el.on 'fields_added.nested_form_fields', (event, param) ->
|
197
|
+
console.log event.target # The added field
|
198
|
+
console.log $(this) # $el
|
199
|
+
|
200
|
+
# Listen on document
|
201
|
+
$(document).on "fields_added.nested_form_fields", (event, param) ->
|
202
|
+
switch param.object_class
|
203
|
+
when "video"
|
204
|
+
console.log "Video object added"
|
205
|
+
else
|
206
|
+
console.log "INFO: Fields were successfully added, callback not handled."
|
207
|
+
```
|
208
|
+
|
209
|
+
You can pass any additional data to the event's callback. This may be useful if you trigger them programmatically. Example:
|
210
|
+
|
211
|
+
```coffeescript
|
212
|
+
# Trigger button click programmatically and pass an object `{hello: 'world'}`
|
213
|
+
$('.add_nested_fields_link').trigger('click', [{hello: 'world'}])
|
214
|
+
|
215
|
+
# Listen for the event
|
216
|
+
$(document).on "fields_added.nested_form_fields", (event, param) ->
|
217
|
+
console.log param.additional_data #=> {hello: 'world'}
|
218
|
+
```
|
219
|
+
|
220
|
+
## Index replacement string
|
221
|
+
|
222
|
+
Sometimes your code needs to know what index it has when it is instantiated onto the page.
|
223
|
+
HTML data elements may need to point to other form elements for instance. This is needed for integration
|
224
|
+
with rails3-jquery-autocomplete.
|
225
|
+
|
226
|
+
To enable string substitution with the current index use the magic string `__nested_field_for_replace_with_index__`.
|
126
227
|
|
127
228
|
## Contributing
|
128
229
|
|
@@ -2,20 +2,25 @@ window.nested_form_fields or= {}
|
|
2
2
|
|
3
3
|
nested_form_fields.bind_nested_forms_links = () ->
|
4
4
|
$('body').off("click", '.add_nested_fields_link')
|
5
|
-
$('body').on 'click', '.add_nested_fields_link', (event) ->
|
5
|
+
$('body').on 'click', '.add_nested_fields_link', (event, additional_data) ->
|
6
6
|
$link = $(this)
|
7
7
|
object_class = $link.data('object-class')
|
8
8
|
association_path = $link.data('association-path')
|
9
9
|
added_index = $(".nested_#{association_path}").length
|
10
|
-
$.event.trigger("fields_adding.nested_form_fields",{object_class: object_class, added_index: added_index, association_path: association_path});
|
11
|
-
|
12
|
-
|
10
|
+
$.event.trigger("fields_adding.nested_form_fields",{object_class: object_class, added_index: added_index, association_path: association_path, additional_data: additional_data});
|
11
|
+
if $link.data('scope')
|
12
|
+
$template = $("#{$link.data('scope')} ##{association_path}_template")
|
13
|
+
else
|
14
|
+
$template = $("##{association_path}_template")
|
15
|
+
target = $link.data('insert-into')
|
13
16
|
|
14
17
|
template_html = $template.html()
|
15
18
|
|
16
19
|
# insert association indexes
|
17
20
|
index_placeholder = "__#{association_path}_index__"
|
18
21
|
template_html = template_html.replace(new RegExp(index_placeholder,"g"), added_index)
|
22
|
+
# look for replacements in user defined code and substitute with the index
|
23
|
+
template_html = template_html.replace(new RegExp("__nested_field_for_replace_with_index__","g"), added_index)
|
19
24
|
|
20
25
|
# replace child template div tags with script tags to avoid form submission of templates
|
21
26
|
$parsed_template = $(template_html)
|
@@ -28,25 +33,30 @@ nested_form_fields.bind_nested_forms_links = () ->
|
|
28
33
|
$('#' + target).append($parsed_template)
|
29
34
|
else
|
30
35
|
$template.before( $parsed_template )
|
31
|
-
$parsed_template.trigger("fields_added.nested_form_fields", {object_class: object_class, added_index: added_index, association_path: association_path, event: event});
|
36
|
+
$parsed_template.trigger("fields_added.nested_form_fields", {object_class: object_class, added_index: added_index, association_path: association_path, event: event, additional_data: additional_data});
|
32
37
|
false
|
33
38
|
|
34
39
|
$('body').off("click", '.remove_nested_fields_link')
|
35
40
|
$('body').on 'click', '.remove_nested_fields_link', ->
|
36
41
|
$link = $(this)
|
37
|
-
return false unless $.rails.allowAction($link)
|
42
|
+
return false unless $.rails == undefined || $.rails.allowAction($link)
|
43
|
+
return false if $link.attr('disabled')
|
38
44
|
object_class = $link.data('object-class')
|
39
45
|
delete_association_field_name = $link.data('delete-association-field-name')
|
40
|
-
removed_index = parseInt(delete_association_field_name.match('(\\d+\\]\\[_destroy])')[0][0])
|
46
|
+
removed_index = parseInt(delete_association_field_name.match('(\\d+\\]\\[_destroy])')[0].match('\\d+')[0])
|
41
47
|
$.event.trigger("fields_removing.nested_form_fields",{object_class: object_class, delete_association_field_name: delete_association_field_name, removed_index: removed_index });
|
42
48
|
$nested_fields_container = $link.parents(".nested_fields").first()
|
43
|
-
$nested_fields_container.
|
49
|
+
delete_field = $nested_fields_container.find("input[type='hidden'][name='#{delete_association_field_name}']")
|
50
|
+
if delete_field.length > 0
|
51
|
+
delete_field.val('1')
|
52
|
+
else
|
53
|
+
$nested_fields_container.before "<input type='hidden' name='#{delete_association_field_name}' value='1' />"
|
44
54
|
$nested_fields_container.hide()
|
45
|
-
$nested_fields_container.find('input[required]:hidden').removeAttr('required')
|
55
|
+
$nested_fields_container.find('input[required]:hidden, select[required]:hidden, textarea[required]:hidden').removeAttr('required')
|
46
56
|
$nested_fields_container.trigger("fields_removed.nested_form_fields",{object_class: object_class, delete_association_field_name: delete_association_field_name, removed_index: removed_index});
|
47
57
|
false
|
48
58
|
|
49
|
-
$(document).on "page:change", ->
|
59
|
+
$(document).on "page:change turbolinks:load", ->
|
50
60
|
nested_form_fields.bind_nested_forms_links()
|
51
61
|
|
52
62
|
jQuery ->
|
data/lib/nested_form_fields.rb
CHANGED
@@ -24,13 +24,14 @@ module ActionView::Helpers
|
|
24
24
|
|
25
25
|
|
26
26
|
def add_nested_fields_link association, text = nil, html_options = {}, &block
|
27
|
+
html_options, text = text, nil if block_given? && text.is_a?(Hash)
|
27
28
|
html_class = html_options.delete(:class) || {}
|
28
29
|
html_data = html_options.delete(:data) || {}
|
29
30
|
|
30
31
|
args = []
|
31
32
|
args << (text || "Add #{association.to_s.singularize.humanize}") unless block_given?
|
32
33
|
args << ''
|
33
|
-
args << { class: "#{html_class} add_nested_fields_link",
|
34
|
+
args << { class: "#{html_class.empty? ? '' : html_class} add_nested_fields_link",
|
34
35
|
data: { association_path: association_path(association.to_s),
|
35
36
|
object_class: association.to_s.singularize }.merge(html_data)
|
36
37
|
}.merge(html_options)
|
@@ -39,13 +40,14 @@ module ActionView::Helpers
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def remove_nested_fields_link text = nil, html_options = {}, &block
|
43
|
+
html_options, text = text, nil if block_given? && text.is_a?(Hash)
|
42
44
|
html_class = html_options.delete(:class) || {}
|
43
45
|
html_data = html_options.delete(:data) || {}
|
44
46
|
|
45
47
|
args = []
|
46
48
|
args << (text || 'x') unless block_given?
|
47
49
|
args << ''
|
48
|
-
args << { class: "#{html_class} remove_nested_fields_link",
|
50
|
+
args << { class: "#{html_class.empty? ? '' : html_class} remove_nested_fields_link",
|
49
51
|
data: { delete_association_field_name: delete_association_field_name,
|
50
52
|
object_class: @object.class.name.underscore.downcase }.merge(html_data)
|
51
53
|
}.merge(html_options)
|
@@ -67,10 +69,18 @@ module ActionView::Helpers
|
|
67
69
|
end
|
68
70
|
|
69
71
|
output = ActiveSupport::SafeBuffer.new
|
70
|
-
association.
|
71
|
-
|
72
|
+
association.each_with_index do |child, index|
|
73
|
+
wrapper_options = options[:wrapper_options].clone || {}
|
74
|
+
if child._destroy == true
|
75
|
+
wrapper_options[:style] = wrapper_options[:style] ? wrapper_options[:style] + ';' + 'display:none' : 'display:none'
|
76
|
+
output << destroy_hidden_field(association_name, index)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Build the wrapper + content and do substitution with the current index allows JS functions to have proper references
|
80
|
+
wrapped_block = nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend], wrapper_options) do
|
72
81
|
fields_for_nested_model("#{name}[#{options[:child_index] || nested_child_index(name)}]", child, options, block)
|
73
82
|
end
|
83
|
+
output << wrapped_block.gsub('__nested_field_for_replace_with_index__', index.to_s).html_safe
|
74
84
|
end
|
75
85
|
|
76
86
|
output << nested_model_template(name, association_name, options, block)
|
@@ -93,7 +103,7 @@ module ActionView::Helpers
|
|
93
103
|
class: for_template ? 'form_template' : nil,
|
94
104
|
style: for_template ? 'display:none' : nil ) do
|
95
105
|
nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend], options[:wrapper_options]) do
|
96
|
-
association_class = (options[:class_name] || association_name).to_s.classify.constantize
|
106
|
+
association_class = (options[:class_name] || object.public_send(association_name).klass.name).to_s.classify.constantize
|
97
107
|
fields_for_nested_model("#{name}[#{index_placeholder(association_name)}]",
|
98
108
|
association_class.new,
|
99
109
|
options.merge(for_template: true), block)
|
@@ -106,7 +116,7 @@ module ActionView::Helpers
|
|
106
116
|
end
|
107
117
|
|
108
118
|
def association_path association_name
|
109
|
-
"#{object_name.gsub('][','_').gsub(/_attributes/,'').sub('[','_').sub(']','')}_#{association_name}"
|
119
|
+
"#{object_name.to_s.gsub('][','_').gsub(/_attributes/,'').sub('[','_').sub(']','')}_#{association_name}"
|
110
120
|
end
|
111
121
|
|
112
122
|
def index_placeholder association_name
|
@@ -124,6 +134,11 @@ module ActionView::Helpers
|
|
124
134
|
end
|
125
135
|
end
|
126
136
|
|
137
|
+
def destroy_hidden_field(association_name, index)
|
138
|
+
@template.hidden_field "#{object_name}[#{association_name}_attributes][#{index}]",
|
139
|
+
:_destroy, value: 1
|
140
|
+
end
|
141
|
+
|
127
142
|
def add_default_classes_to_wrapper_options(association_name, wrapper_options)
|
128
143
|
default_classes = ["nested_fields", "nested_#{association_path(association_name)}"]
|
129
144
|
wrapper_options[:class] = wrapper_options[:class].is_a?(String) ? wrapper_options[:class].split(" ") : wrapper_options[:class].to_a
|
data/nested_form_fields.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Nico Ritsche"]
|
6
6
|
gem.email = ["ncrdevmail@gmail.com"]
|
7
7
|
gem.description = %q{Rails gem for dynamically adding and removing nested has_many association fields in a form.
|
8
|
-
Uses jQuery and supports multiple nesting levels. Requires Ruby 1.9 and the asset pipeline.}
|
8
|
+
Uses jQuery and supports multiple nesting levels. Requires Ruby 1.9+ and the asset pipeline.}
|
9
9
|
gem.summary = %q{Rails gem for dynamically adding and removing nested has_many association fields in a form.}
|
10
10
|
gem.homepage = ""
|
11
11
|
|
@@ -18,15 +18,19 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.license = 'MIT'
|
19
19
|
|
20
20
|
gem.add_dependency 'rails', '>= 3.2.0'
|
21
|
+
gem.add_dependency 'coffee-rails', '>= 3.2.1'
|
22
|
+
gem.add_dependency 'jquery-rails'
|
21
23
|
|
22
|
-
gem.add_development_dependency '
|
23
|
-
gem.add_development_dependency '
|
24
|
+
gem.add_development_dependency 'rspec-rails', '~> 3.5'
|
25
|
+
gem.add_development_dependency 'nokogiri', '1.6.8.1'
|
24
26
|
gem.add_development_dependency 'assert_difference'
|
25
27
|
gem.add_development_dependency 'capybara'
|
26
|
-
gem.add_development_dependency '
|
27
|
-
gem.add_development_dependency '
|
28
|
+
gem.add_development_dependency 'geckodriver-helper'
|
29
|
+
gem.add_development_dependency 'selenium-webdriver', '> 3.0.5'
|
30
|
+
gem.add_development_dependency 'sqlite3', '~> 1.3.6'
|
28
31
|
gem.add_development_dependency 'haml', '>= 3.1.5'
|
29
|
-
gem.add_development_dependency 'haml-rails'
|
32
|
+
gem.add_development_dependency 'haml-rails', '~> 0.4.0'
|
30
33
|
gem.add_development_dependency 'sass-rails', '~> 3.2.3'
|
31
|
-
gem.add_development_dependency '
|
34
|
+
gem.add_development_dependency 'test-unit', '1.2.3'
|
35
|
+
gem.add_development_dependency 'public_suffix', '~> 1.4.6'
|
32
36
|
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,273 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
Started GET "/" for 127.0.0.1 at 2014-07-23 09:59:20 +0300
|
4
|
+
Connecting to database specified by database.yml
|
5
|
+
Processing by UsersController#new as HTML
|
6
|
+
Completed 500 Internal Server Error in 12.6ms
|
7
|
+
|
8
|
+
ActiveRecord::StatementInvalid (Could not find table 'users'):
|
9
|
+
app/controllers/users_controller.rb:23:in `new'
|
10
|
+
app/controllers/users_controller.rb:23:in `new'
|
11
|
+
|
12
|
+
|
13
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
|
14
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
|
15
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (6.8ms)
|
16
|
+
Connecting to database specified by database.yml
|
17
|
+
[1m[36m (1.7ms)[0m [1mselect sqlite_version(*)[0m
|
18
|
+
[1m[35m (1.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
19
|
+
[1m[36m (0.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
20
|
+
[1m[35m (1.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
21
|
+
Migrating to CreateUsers (20120518212100)
|
22
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
23
|
+
[1m[35m (0.2ms)[0m CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
24
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120518212100')[0m
|
25
|
+
[1m[35m (0.8ms)[0m commit transaction
|
26
|
+
Migrating to CreateProjects (20120523095218)
|
27
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
28
|
+
[1m[35m (0.2ms)[0m CREATE TABLE "projects" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" text, "user_id" integer)
|
29
|
+
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_projects_on_user_id" ON "projects" ("user_id")[0m
|
30
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20120523095218')
|
31
|
+
[1m[36m (0.7ms)[0m [1mcommit transaction[0m
|
32
|
+
Migrating to CreateTodos (20120523095357)
|
33
|
+
[1m[35m (0.0ms)[0m begin transaction
|
34
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "todos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "description" varchar(255), "model_with_todos_id" integer, "model_with_todos_type" varchar(255)) [0m
|
35
|
+
[1m[35m (0.1ms)[0m CREATE INDEX "index_todos_on_model_with_todos_id" ON "todos" ("model_with_todos_id")
|
36
|
+
[1m[36m (0.1ms)[0m [1mCREATE INDEX "index_todos_on_model_with_todos_type" ON "todos" ("model_with_todos_type")[0m
|
37
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20120523095357')
|
38
|
+
[1m[36m (0.8ms)[0m [1mcommit transaction[0m
|
39
|
+
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
40
|
+
|
41
|
+
|
42
|
+
Started GET "/" for 127.0.0.1 at 2014-07-23 10:00:25 +0300
|
43
|
+
Connecting to database specified by database.yml
|
44
|
+
Processing by UsersController#new as HTML
|
45
|
+
Completed 500 Internal Server Error in 38.8ms
|
46
|
+
|
47
|
+
ActionView::MissingTemplate (Missing template users/edit, application/edit with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
|
48
|
+
* "/Users/nico/Rails/nested_form_fields/spec/dummy/app/views"
|
49
|
+
):
|
50
|
+
app/controllers/users_controller.rb:24:in `new'
|
51
|
+
|
52
|
+
|
53
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (1.8ms)
|
54
|
+
|
55
|
+
|
56
|
+
Started GET "/users/new" for 127.0.0.1 at 2014-07-23 10:00:55 +0300
|
57
|
+
Processing by UsersController#new as HTML
|
58
|
+
Completed 500 Internal Server Error in 0.8ms
|
59
|
+
|
60
|
+
ActionView::MissingTemplate (Missing template users/edit, application/edit with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
|
61
|
+
* "/Users/nico/Rails/nested_form_fields/spec/dummy/app/views"
|
62
|
+
):
|
63
|
+
app/controllers/users_controller.rb:24:in `new'
|
64
|
+
|
65
|
+
|
66
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.3ms)
|
67
|
+
|
68
|
+
|
69
|
+
Started GET "/" for 127.0.0.1 at 2014-07-23 10:02:23 +0300
|
70
|
+
Processing by UsersController#new as HTML
|
71
|
+
Completed 500 Internal Server Error in 0.8ms
|
72
|
+
|
73
|
+
ActionView::MissingTemplate (Missing template users/edit, application/edit with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
|
74
|
+
* "/Users/nico/Rails/nested_form_fields/spec/dummy/app/views"
|
75
|
+
):
|
76
|
+
app/controllers/users_controller.rb:24:in `new'
|
77
|
+
|
78
|
+
|
79
|
+
Rendered /Users/nico/.rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.15/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.4ms)
|
80
|
+
|
81
|
+
|
82
|
+
Started GET "/" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
83
|
+
Connecting to database specified by database.yml
|
84
|
+
Processing by UsersController#new as HTML
|
85
|
+
Rendered users/edit.html.haml within layouts/application (45.9ms)
|
86
|
+
Compiled normalize.css (35ms) (pid 28243)
|
87
|
+
Compiled users.css (3ms) (pid 28243)
|
88
|
+
Compiled application.css (183ms) (pid 28243)
|
89
|
+
Compiled jquery.js (1ms) (pid 28243)
|
90
|
+
Compiled jquery_ujs.js (0ms) (pid 28243)
|
91
|
+
Compiled nested_form_fields.js (155ms) (pid 28243)
|
92
|
+
Compiled users.js (92ms) (pid 28243)
|
93
|
+
Compiled application.js (280ms) (pid 28243)
|
94
|
+
Rendered layouts/_navigation.html.haml (0.7ms)
|
95
|
+
Rendered layouts/_messages.html.haml (0.8ms)
|
96
|
+
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" ORDER BY name[0m
|
97
|
+
Completed 200 OK in 567.8ms (Views: 538.3ms | ActiveRecord: 1.8ms)
|
98
|
+
|
99
|
+
|
100
|
+
Started GET "/assets/normalize.css?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
101
|
+
Served asset /normalize.css - 200 OK (4ms)
|
102
|
+
|
103
|
+
|
104
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
105
|
+
Served asset /application.css - 200 OK (3ms)
|
106
|
+
|
107
|
+
|
108
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
109
|
+
Served asset /jquery_ujs.js - 200 OK (19ms)
|
110
|
+
|
111
|
+
|
112
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
113
|
+
Served asset /jquery.js - 200 OK (1ms)
|
114
|
+
|
115
|
+
|
116
|
+
Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
117
|
+
Served asset /users.css - 200 OK (1ms)
|
118
|
+
|
119
|
+
|
120
|
+
Started GET "/assets/nested_form_fields.js?body=1" for 127.0.0.1 at 2014-07-23 10:07:56 +0300
|
121
|
+
Served asset /nested_form_fields.js - 200 OK (1ms)
|
122
|
+
|
123
|
+
|
124
|
+
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2014-07-23 10:07:57 +0300
|
125
|
+
Served asset /users.js - 200 OK (1ms)
|
126
|
+
|
127
|
+
|
128
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-07-23 10:07:57 +0300
|
129
|
+
Served asset /application.js - 200 OK (3ms)
|
130
|
+
|
131
|
+
|
132
|
+
Started GET "/" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
133
|
+
Connecting to database specified by database.yml
|
134
|
+
Processing by UsersController#new as HTML
|
135
|
+
Rendered users/edit.html.haml within layouts/application (46.4ms)
|
136
|
+
Compiled nested_form_fields.js (161ms) (pid 29718)
|
137
|
+
Compiled application.js (3ms) (pid 29718)
|
138
|
+
Rendered layouts/_navigation.html.haml (0.6ms)
|
139
|
+
Rendered layouts/_messages.html.haml (0.7ms)
|
140
|
+
[1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" ORDER BY name[0m
|
141
|
+
Completed 200 OK in 272.5ms (Views: 243.3ms | ActiveRecord: 1.9ms)
|
142
|
+
|
143
|
+
|
144
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
145
|
+
Served asset /jquery.js - 200 OK (3ms)
|
146
|
+
|
147
|
+
|
148
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
149
|
+
Served asset /jquery_ujs.js - 200 OK (21ms)
|
150
|
+
|
151
|
+
|
152
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
153
|
+
Served asset /application.css - 200 OK (9ms)
|
154
|
+
|
155
|
+
|
156
|
+
Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
157
|
+
Served asset /users.css - 200 OK (1ms)
|
158
|
+
|
159
|
+
|
160
|
+
Started GET "/assets/nested_form_fields.js?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
161
|
+
Served asset /nested_form_fields.js - 200 OK (2ms)
|
162
|
+
|
163
|
+
|
164
|
+
Started GET "/assets/normalize.css?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
165
|
+
Served asset /normalize.css - 200 OK (1ms)
|
166
|
+
|
167
|
+
|
168
|
+
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
169
|
+
Served asset /users.js - 200 OK (2ms)
|
170
|
+
|
171
|
+
|
172
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-07-23 10:17:46 +0300
|
173
|
+
Served asset /application.js - 200 OK (7ms)
|
174
|
+
|
175
|
+
|
176
|
+
Started POST "/users" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
177
|
+
Processing by UsersController#create as HTML
|
178
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+9YZ/C5wvq3T0W4YNpL4hQxCZZEtmzQ8My5dcEckEBc=", "user"=>{"name"=>"", "projects_attributes"=>{"0"=>{"_destroy"=>"1", "name"=>"", "description"=>""}}}, "commit"=>"Create User"}
|
179
|
+
[1m[35m (0.1ms)[0m begin transaction
|
180
|
+
[1m[36mSQL (5.2ms)[0m [1mINSERT INTO "users" ("created_at", "name", "updated_at") VALUES (?, ?, ?)[0m [["created_at", Wed, 23 Jul 2014 07:18:52 UTC +00:00], ["name", ""], ["updated_at", Wed, 23 Jul 2014 07:18:52 UTC +00:00]]
|
181
|
+
[1m[35m (0.6ms)[0m commit transaction
|
182
|
+
Redirected to http://localhost:3000/users/1/edit
|
183
|
+
Completed 302 Found in 9.9ms (ActiveRecord: 5.9ms)
|
184
|
+
|
185
|
+
|
186
|
+
Started GET "/users/1/edit" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
187
|
+
Processing by UsersController#edit as HTML
|
188
|
+
Parameters: {"id"=>"1"}
|
189
|
+
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1[0m [["id", "1"]]
|
190
|
+
[1m[35mProject Load (0.1ms)[0m SELECT "projects".* FROM "projects" WHERE "projects"."user_id" = 1
|
191
|
+
Rendered users/edit.html.haml within layouts/application (10.1ms)
|
192
|
+
Rendered layouts/_navigation.html.haml (0.0ms)
|
193
|
+
Rendered layouts/_messages.html.haml (0.1ms)
|
194
|
+
[1m[36mUser Load (0.1ms)[0m [1mSELECT "users".* FROM "users" ORDER BY name[0m
|
195
|
+
Completed 200 OK in 27.9ms (Views: 26.0ms | ActiveRecord: 0.4ms)
|
196
|
+
|
197
|
+
|
198
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
199
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
200
|
+
|
201
|
+
|
202
|
+
Started GET "/assets/normalize.css?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
203
|
+
Served asset /normalize.css - 304 Not Modified (0ms)
|
204
|
+
|
205
|
+
|
206
|
+
Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
207
|
+
Served asset /users.css - 304 Not Modified (0ms)
|
208
|
+
|
209
|
+
|
210
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
211
|
+
Served asset /jquery.js - 304 Not Modified (0ms)
|
212
|
+
|
213
|
+
|
214
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
215
|
+
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
|
216
|
+
|
217
|
+
|
218
|
+
Started GET "/assets/nested_form_fields.js?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
219
|
+
Served asset /nested_form_fields.js - 304 Not Modified (0ms)
|
220
|
+
|
221
|
+
|
222
|
+
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
223
|
+
Served asset /users.js - 304 Not Modified (0ms)
|
224
|
+
|
225
|
+
|
226
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-07-23 10:18:52 +0300
|
227
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
228
|
+
|
229
|
+
|
230
|
+
Started PUT "/users/1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
231
|
+
Processing by UsersController#update as HTML
|
232
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+9YZ/C5wvq3T0W4YNpL4hQxCZZEtmzQ8My5dcEckEBc=", "user"=>{"name"=>"", "projects_attributes"=>{"0"=>{"_destroy"=>"1", "name"=>"", "description"=>""}}}, "commit"=>"Update User", "id"=>"1"}
|
233
|
+
[1m[35mUser Load (0.1ms)[0m SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", "1"]]
|
234
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
235
|
+
[1m[35m (0.0ms)[0m commit transaction
|
236
|
+
[1m[36mProject Load (0.1ms)[0m [1mSELECT "projects".* FROM "projects" WHERE "projects"."user_id" = 1[0m
|
237
|
+
Rendered users/edit.html.haml within layouts/application (5.7ms)
|
238
|
+
Rendered layouts/_navigation.html.haml (0.1ms)
|
239
|
+
Rendered layouts/_messages.html.haml (0.1ms)
|
240
|
+
[1m[35mUser Load (0.1ms)[0m SELECT "users".* FROM "users" ORDER BY name
|
241
|
+
Completed 200 OK in 30.2ms (Views: 27.5ms | ActiveRecord: 0.4ms)
|
242
|
+
|
243
|
+
|
244
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
245
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
246
|
+
|
247
|
+
|
248
|
+
Started GET "/assets/normalize.css?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
249
|
+
Served asset /normalize.css - 304 Not Modified (0ms)
|
250
|
+
|
251
|
+
|
252
|
+
Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
253
|
+
Served asset /users.css - 304 Not Modified (0ms)
|
254
|
+
|
255
|
+
|
256
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
257
|
+
Served asset /jquery.js - 304 Not Modified (0ms)
|
258
|
+
|
259
|
+
|
260
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
261
|
+
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
|
262
|
+
|
263
|
+
|
264
|
+
Started GET "/assets/nested_form_fields.js?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
265
|
+
Served asset /nested_form_fields.js - 304 Not Modified (0ms)
|
266
|
+
|
267
|
+
|
268
|
+
Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
269
|
+
Served asset /users.js - 304 Not Modified (0ms)
|
270
|
+
|
271
|
+
|
272
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-07-23 10:20:13 +0300
|
273
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
@@ -51,7 +51,7 @@ describe 'a form with nested projects with nested todos', :js => true do
|
|
51
51
|
visit edit_user_path(user)
|
52
52
|
|
53
53
|
page.should have_css('fieldset.nested_user_projects_0_todos')
|
54
|
-
page.find('.nested_user_projects_0_todos .remove_nested_fields_link').click
|
54
|
+
page.find('.nested_user_projects_0_todos .remove_nested_fields_link.test_class').click
|
55
55
|
page.should_not have_css('fieldset.nested_user_projects_0_todos')
|
56
56
|
|
57
57
|
page.all('.nested_user_projects .remove_nested_fields_link').count.should == 2
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,10 @@ ENV["RAILS_ENV"] = 'test'
|
|
9
9
|
require_relative "dummy/config/environment"
|
10
10
|
|
11
11
|
require 'rspec/rails'
|
12
|
+
|
13
|
+
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task see https://github.com/rspec/rspec-rails/issues/1171
|
14
|
+
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
15
|
+
|
12
16
|
require 'assert_difference'
|
13
17
|
require 'sqlite3'
|
14
18
|
|
@@ -26,6 +30,7 @@ RSpec.configure do |config|
|
|
26
30
|
config.include AssertDifference
|
27
31
|
config.use_transactional_fixtures = true
|
28
32
|
config.include Capybara::DSL
|
33
|
+
config.infer_spec_type_from_file_location!
|
29
34
|
end
|
30
35
|
|
31
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_form_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Ritsche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coffee-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: jquery-rails
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,7 +45,7 @@ dependencies:
|
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
|
-
type: :
|
48
|
+
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
@@ -40,18 +54,32 @@ dependencies:
|
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - '='
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
75
|
+
version: 1.6.8.1
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - '='
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 1.6.8.1
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: assert_difference
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +109,7 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: geckodriver-helper
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
@@ -94,20 +122,34 @@ dependencies:
|
|
94
122
|
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: selenium-webdriver
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.5
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.5
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: sqlite3
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
100
142
|
requirements:
|
101
|
-
- - "
|
143
|
+
- - "~>"
|
102
144
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
145
|
+
version: 1.3.6
|
104
146
|
type: :development
|
105
147
|
prerelease: false
|
106
148
|
version_requirements: !ruby/object:Gem::Requirement
|
107
149
|
requirements:
|
108
|
-
- - "
|
150
|
+
- - "~>"
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
152
|
+
version: 1.3.6
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: haml
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,16 +168,16 @@ dependencies:
|
|
126
168
|
name: haml-rails
|
127
169
|
requirement: !ruby/object:Gem::Requirement
|
128
170
|
requirements:
|
129
|
-
- - "
|
171
|
+
- - "~>"
|
130
172
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
173
|
+
version: 0.4.0
|
132
174
|
type: :development
|
133
175
|
prerelease: false
|
134
176
|
version_requirements: !ruby/object:Gem::Requirement
|
135
177
|
requirements:
|
136
|
-
- - "
|
178
|
+
- - "~>"
|
137
179
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
180
|
+
version: 0.4.0
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: sass-rails
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,22 +193,36 @@ dependencies:
|
|
151
193
|
- !ruby/object:Gem::Version
|
152
194
|
version: 3.2.3
|
153
195
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
196
|
+
name: test-unit
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.2.3
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 1.2.3
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: public_suffix
|
155
211
|
requirement: !ruby/object:Gem::Requirement
|
156
212
|
requirements:
|
157
213
|
- - "~>"
|
158
214
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
215
|
+
version: 1.4.6
|
160
216
|
type: :development
|
161
217
|
prerelease: false
|
162
218
|
version_requirements: !ruby/object:Gem::Requirement
|
163
219
|
requirements:
|
164
220
|
- - "~>"
|
165
221
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
222
|
+
version: 1.4.6
|
167
223
|
description: |-
|
168
224
|
Rails gem for dynamically adding and removing nested has_many association fields in a form.
|
169
|
-
Uses jQuery and supports multiple nesting levels. Requires Ruby 1.9 and the asset pipeline.
|
225
|
+
Uses jQuery and supports multiple nesting levels. Requires Ruby 1.9+ and the asset pipeline.
|
170
226
|
email:
|
171
227
|
- ncrdevmail@gmail.com
|
172
228
|
executables: []
|
@@ -184,6 +240,9 @@ files:
|
|
184
240
|
- lib/nested_form_fields.rb
|
185
241
|
- lib/nested_form_fields/version.rb
|
186
242
|
- nested_form_fields.gemspec
|
243
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/application.css.scssc
|
244
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/normalize.css.scssc
|
245
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/users.css.scssc
|
187
246
|
- spec/dummy/README.rdoc
|
188
247
|
- spec/dummy/Rakefile
|
189
248
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -225,6 +284,7 @@ files:
|
|
225
284
|
- spec/dummy/db/test.sqlite3
|
226
285
|
- spec/dummy/lib/assets/.gitkeep
|
227
286
|
- spec/dummy/log/.gitkeep
|
287
|
+
- spec/dummy/log/development.log
|
228
288
|
- spec/dummy/public/404.html
|
229
289
|
- spec/dummy/public/422.html
|
230
290
|
- spec/dummy/public/500.html
|
@@ -251,13 +311,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
311
|
- !ruby/object:Gem::Version
|
252
312
|
version: '0'
|
253
313
|
requirements: []
|
254
|
-
|
255
|
-
rubygems_version: 2.2.2
|
314
|
+
rubygems_version: 3.0.4
|
256
315
|
signing_key:
|
257
316
|
specification_version: 4
|
258
317
|
summary: Rails gem for dynamically adding and removing nested has_many association
|
259
318
|
fields in a form.
|
260
319
|
test_files:
|
320
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/application.css.scssc
|
321
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/normalize.css.scssc
|
322
|
+
- spec/dummy/.sass-cache/b3239b16cb7e494d5d4e969f1b84625be9aac82c/users.css.scssc
|
261
323
|
- spec/dummy/README.rdoc
|
262
324
|
- spec/dummy/Rakefile
|
263
325
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -299,6 +361,7 @@ test_files:
|
|
299
361
|
- spec/dummy/db/test.sqlite3
|
300
362
|
- spec/dummy/lib/assets/.gitkeep
|
301
363
|
- spec/dummy/log/.gitkeep
|
364
|
+
- spec/dummy/log/development.log
|
302
365
|
- spec/dummy/public/404.html
|
303
366
|
- spec/dummy/public/422.html
|
304
367
|
- spec/dummy/public/500.html
|