cocoon 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  class Comment < ActiveRecord::Base
2
2
  belongs_to :post
3
3
 
4
- attr_protected :author
4
+ unless Rails.rails4?
5
+ attr_protected :author
6
+ end
5
7
  end
@@ -1,5 +1,9 @@
1
1
  class Post < ActiveRecord::Base
2
2
  has_many :comments
3
- has_many :admin_comments, :class_name => "Comment", :conditions => { :author => "Admin" }
3
+ if Rails.rails4?
4
+ has_many :admin_comments, -> { where author: "Admin" }, :class_name => "Comment"
5
+ else
6
+ has_many :admin_comments, :class_name => "Comment", :conditions => { :author => "Admin" }
7
+ end
4
8
  has_many :people
5
9
  end
@@ -11,7 +11,7 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
14
+ #config.action_view.debug_rjs = true
15
15
  config.action_controller.perform_caching = false
16
16
 
17
17
  # Don't care if the mailer can't send
@@ -0,0 +1,6 @@
1
+ module Rails
2
+
3
+ def self.rails4?
4
+ Rails.version.start_with? '4'
5
+ end
6
+ end
@@ -1,7 +1,8 @@
1
- # Be sure to restart your server when you modify this file.
1
+ config = Rails.application.config
2
2
 
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '58698a8f83e3ccc8e503d18280e17a23008a8f08a6813472dca7873ad0b497428dc00f62ee2225f94bce0d8e04c4befa922e4372772a2e1de89cebaa98a18c0a'
3
+ if Rails.rails4?
4
+ config.secret_key_base = '58698a8f83e3ccc8e503d18280e17a23008a8f08a6813472dca7873ad0b497428dc00f62ee2225f94bce0d8e04c4befa922e4372772a2e1de89cebaa98a18c0a'
5
+ else
6
+ config.secret_token = '58698a8f83e3ccc8e503d18280e17a23008a8f08a6813472dca7873ad0b497428dc00f62ee2225f94bce0d8e04c4befa922e4372772a2e1de89cebaa98a18c0a'
7
+ config.session_store :cookie_store, :key => "dummy"
8
+ end
@@ -0,0 +1,3 @@
1
+ def rails4?
2
+ Rails.version.start_with? '4'
3
+ end
@@ -0,0 +1,73 @@
1
+ # -*- encoding : utf-8 -*-
2
+ shared_examples_for "a correctly rendered add link" do |options|
3
+ context "the rendered link" do
4
+ before do
5
+ default_options = {
6
+ href: '#',
7
+ class: 'add_fields',
8
+ template: "form<tag>",
9
+ association: 'comment',
10
+ associations: 'comments',
11
+ text: 'add something',
12
+ extra_attributes: {}
13
+ }
14
+ @options = default_options.merge options
15
+
16
+ doc = Nokogiri::HTML(@html)
17
+ @link = doc.at('a')
18
+ end
19
+ it 'has a correct href' do
20
+ @link.attribute('href').value.should == @options[:href]
21
+ end
22
+ it 'has a correct class' do
23
+ @link.attribute('class').value.should == @options[:class]
24
+ end
25
+ it 'has a correct template' do
26
+ @link.attribute('data-association-insertion-template').value.should == @options[:template]
27
+ end
28
+ it 'has a correct associations' do
29
+ @link.attribute('data-association').value.should == @options[:association]
30
+ @link.attribute('data-associations').value.should == @options[:associations]
31
+ end
32
+ it 'has the correct text' do
33
+ @link.text.should == @options[:text]
34
+ end
35
+ it 'sets extra attributes correctly' do
36
+ @options[:extra_attributes].each do |key, value|
37
+ @link.attribute(key).value.should == value
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+ shared_examples_for "a correctly rendered remove link" do |options|
45
+ context "the rendered link" do
46
+ before do
47
+ default_options = {
48
+ href: '#',
49
+ class: 'remove_fields dynamic',
50
+ text: 'remove something',
51
+ extra_attributes: {}
52
+ }
53
+ @options = default_options.merge options
54
+
55
+ doc = Nokogiri::HTML(@html)
56
+ @link = doc.at('a')
57
+ end
58
+ it 'has a correct href' do
59
+ @link.attribute('href').value.should == @options[:href]
60
+ end
61
+ it 'has a correct class' do
62
+ @link.attribute('class').value.should == @options[:class]
63
+ end
64
+ it 'has the correct text' do
65
+ @link.text.should == @options[:text]
66
+ end
67
+ it 'sets extra attributes correctly' do
68
+ @options[:extra_attributes].each do |key, value|
69
+ @link.attribute(key).value.should == value
70
+ end
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,176 +1,192 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoon
3
3
  version: !ruby/object:Gem::Version
4
+ version: 1.2.0
4
5
  prerelease:
5
- version: 1.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Van der Auwera
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- prerelease: false
16
- type: :development
17
15
  name: rails
18
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
19
18
  requirements:
20
19
  - - ! '>='
21
20
  - !ruby/object:Gem::Version
22
- version: 3.0.0
23
- none: false
21
+ version: 4.0.0
22
+ type: :development
23
+ prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ! '>='
27
28
  - !ruby/object:Gem::Version
28
- version: 3.0.0
29
- none: false
29
+ version: 4.0.0
30
30
  - !ruby/object:Gem::Dependency
31
- prerelease: false
32
- type: :development
33
- name: sqlite3-ruby
31
+ name: sqlite3
34
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
35
34
  requirements:
36
35
  - - ! '>='
37
36
  - !ruby/object:Gem::Version
38
37
  version: '0'
39
- none: false
38
+ type: :development
39
+ prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
41
42
  requirements:
42
43
  - - ! '>='
43
44
  - !ruby/object:Gem::Version
44
45
  version: '0'
45
- none: false
46
46
  - !ruby/object:Gem::Dependency
47
- prerelease: false
48
- type: :development
49
47
  name: json_pure
50
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
51
50
  requirements:
52
51
  - - ! '>='
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
- none: false
54
+ type: :development
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
57
58
  requirements:
58
59
  - - ! '>='
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
61
- none: false
62
62
  - !ruby/object:Gem::Dependency
63
- prerelease: false
64
- type: :development
65
63
  name: jeweler
66
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
67
66
  requirements:
68
67
  - - ! '>='
69
68
  - !ruby/object:Gem::Version
70
69
  version: '0'
71
- none: false
70
+ type: :development
71
+ prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
73
74
  requirements:
74
75
  - - ! '>='
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
- none: false
78
78
  - !ruby/object:Gem::Dependency
79
- prerelease: false
80
- type: :development
81
79
  name: rspec-rails
82
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
83
82
  requirements:
84
83
  - - ! '>='
85
84
  - !ruby/object:Gem::Version
86
- version: 2.6.0
87
- none: false
85
+ version: 2.8.0
86
+ type: :development
87
+ prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
89
90
  requirements:
90
91
  - - ! '>='
91
92
  - !ruby/object:Gem::Version
92
- version: 2.6.0
93
- none: false
93
+ version: 2.8.0
94
94
  - !ruby/object:Gem::Dependency
95
- prerelease: false
96
- type: :development
97
95
  name: rspec
98
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
99
98
  requirements:
100
99
  - - ! '>='
101
100
  - !ruby/object:Gem::Version
102
- version: 2.6.0
103
- none: false
101
+ version: 2.8.0
102
+ type: :development
103
+ prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
105
106
  requirements:
106
107
  - - ! '>='
107
108
  - !ruby/object:Gem::Version
108
- version: 2.6.0
109
- none: false
109
+ version: 2.8.0
110
110
  - !ruby/object:Gem::Dependency
111
- prerelease: false
112
- type: :development
113
111
  name: actionpack
114
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
115
114
  requirements:
116
115
  - - ! '>='
117
116
  - !ruby/object:Gem::Version
118
- version: 3.0.0
119
- none: false
117
+ version: 4.0.0
118
+ type: :development
119
+ prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
121
122
  requirements:
122
123
  - - ! '>='
123
124
  - !ruby/object:Gem::Version
124
- version: 3.0.0
125
- none: false
125
+ version: 4.0.0
126
126
  - !ruby/object:Gem::Dependency
127
- prerelease: false
128
- type: :development
129
127
  name: simplecov
130
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
131
130
  requirements:
132
131
  - - ! '>='
133
132
  - !ruby/object:Gem::Version
134
133
  version: '0'
135
- none: false
134
+ type: :development
135
+ prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
137
138
  requirements:
138
139
  - - ! '>='
139
140
  - !ruby/object:Gem::Version
140
141
  version: '0'
141
- none: false
142
142
  - !ruby/object:Gem::Dependency
143
- prerelease: false
143
+ name: nokogiri
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
144
150
  type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
145
159
  name: generator_spec
146
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
147
162
  requirements:
148
163
  - - ! '>='
149
164
  - !ruby/object:Gem::Version
150
165
  version: '0'
151
- none: false
166
+ type: :development
167
+ prerelease: false
152
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
153
170
  requirements:
154
171
  - - ! '>='
155
172
  - !ruby/object:Gem::Version
156
173
  version: '0'
157
- none: false
158
174
  - !ruby/object:Gem::Dependency
159
- prerelease: false
160
- type: :development
161
175
  name: rspec
162
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
163
178
  requirements:
164
179
  - - ! '>='
165
180
  - !ruby/object:Gem::Version
166
181
  version: 2.0.0
167
- none: false
182
+ type: :development
183
+ prerelease: false
168
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
169
186
  requirements:
170
187
  - - ! '>='
171
188
  - !ruby/object:Gem::Version
172
189
  version: 2.0.0
173
- none: false
174
190
  description: Unobtrusive nested forms handling, using jQuery. Use this and discover
175
191
  cocoon-heaven.
176
192
  email: nathan@dixis.com
@@ -181,6 +197,7 @@ extra_rdoc_files:
181
197
  files:
182
198
  - .travis.yml
183
199
  - Gemfile
200
+ - Gemfile.lock
184
201
  - History.md
185
202
  - MIT-LICENSE
186
203
  - README.markdown
@@ -188,6 +205,8 @@ files:
188
205
  - VERSION
189
206
  - app/assets/javascripts/cocoon.js
190
207
  - cocoon.gemspec
208
+ - gemfiles/Gemfile.rails-3.2.13
209
+ - gemfiles/Gemfile.rails-3.2.13.lock
191
210
  - lib/cocoon.rb
192
211
  - lib/cocoon/view_helpers.rb
193
212
  - lib/generators/cocoon/install/install_generator.rb
@@ -211,6 +230,7 @@ files:
211
230
  - spec/dummy/config/initializers/backtrace_silencers.rb
212
231
  - spec/dummy/config/initializers/inflections.rb
213
232
  - spec/dummy/config/initializers/mime_types.rb
233
+ - spec/dummy/config/initializers/rails_version_helper.rb
214
234
  - spec/dummy/config/initializers/secret_token.rb
215
235
  - spec/dummy/config/initializers/session_store.rb
216
236
  - spec/dummy/config/locales/en.yml
@@ -234,6 +254,8 @@ files:
234
254
  - spec/generators/install_generator_spec.rb
235
255
  - spec/integration/navigation_spec.rb
236
256
  - spec/spec_helper.rb
257
+ - spec/support/rails_version_helper.rb
258
+ - spec/support/shared_examples.rb
237
259
  homepage: http://github.com/nathanvda/cocoon
238
260
  licenses: []
239
261
  post_install_message:
@@ -241,23 +263,23 @@ rdoc_options: []
241
263
  require_paths:
242
264
  - lib
243
265
  required_ruby_version: !ruby/object:Gem::Requirement
266
+ none: false
244
267
  requirements:
245
268
  - - ! '>='
246
269
  - !ruby/object:Gem::Version
247
270
  version: '0'
248
271
  segments:
249
272
  - 0
250
- hash: 2461844246300875574
251
- none: false
273
+ hash: 171754953178404834
252
274
  required_rubygems_version: !ruby/object:Gem::Requirement
275
+ none: false
253
276
  requirements:
254
277
  - - ! '>='
255
278
  - !ruby/object:Gem::Version
256
279
  version: '0'
257
- none: false
258
280
  requirements: []
259
281
  rubyforge_project:
260
- rubygems_version: 1.8.24
282
+ rubygems_version: 1.8.25
261
283
  signing_key:
262
284
  specification_version: 3
263
285
  summary: gem that enables easier nested forms with standard forms, formtastic and