record_collection 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ee07c5d52e0e54488e931828ea1e6fa5fcfcf11
4
- data.tar.gz: 287f65ae03ea2093b1f8bfa8fecde2d5acb3d9c4
3
+ metadata.gz: f3fe45579a3c799ef4243d149102f0a79bb47378
4
+ data.tar.gz: ba95029f191c2412f2a0489418acd0d8735c974c
5
5
  SHA512:
6
- metadata.gz: af0f6e48b22e6456ceb5b74f3c8989df45e0cf8b19f67650aea3bcd2ed8d99aa15b9a7cbbaccafe7ba47ac1fd3be00c99937e138511ca0550e8d14e0e3293de1
7
- data.tar.gz: 302c8acc483678b28be818e928d6f5ad193c8a71f36ce1c3c94fb270f83bb90916701aed6c7f2ad8a75dc185bd17d7cbf13544ffd404f68f434da3084f7ab8ea
6
+ metadata.gz: 6234774ce4b5adfe5fc245e11f7331aa2c48ed38cc6e7e5ab21b6f38898754f22691a82ccba789c70ae4f09b58a73617be460b1ac47b425b8768549b892ee443
7
+ data.tar.gz: 0e72b14a8c8b3cb8ec56872cb2ce0b856220678dd63d37a9797652e030120fbbb8dc9a4c467365d283b5c71f6d251fd88efc00d49fd5847aea6caf24562a6454
@@ -15,7 +15,6 @@ class MultiSelect
15
15
  @options = options
16
16
  @on 'changed', options.changed if options.changed
17
17
 
18
- @set 'resource', table.data('resource')
19
18
  # Add an extra th to all header rows
20
19
  table.find('thead tr').each -> $(this).prepend("<th></th>")
21
20
 
@@ -102,7 +102,7 @@ class Optionals
102
102
 
103
103
  container.find('label').remove()
104
104
 
105
- activator_toggle.click() if container.hasClass('active')
105
+ activator_toggle.click() if container.hasClass('active') or one
106
106
  activator_toggle.hide() if one
107
107
 
108
108
  root = @
data/config/spring.rb ADDED
@@ -0,0 +1 @@
1
+ Spring.application_root = './spec/dummy'
@@ -42,7 +42,8 @@ class ActionView::Helpers::FormBuilder
42
42
  end
43
43
 
44
44
  def get_data_attributes(attr, options = {})
45
- one = object.respond_to?(:one?) && object.one?
45
+ one = true
46
+ one = object.one? if object.is_a? RecordCollection::Base
46
47
  {attribute: attr, one: one}
47
48
  end
48
49
 
@@ -56,7 +57,12 @@ class ActionView::Helpers::FormBuilder
56
57
  active = true unless object.public_send(attr).nil? # Activate if collection attribute is not nil
57
58
  classes = [options[:base_class] || 'optional-input', 'optional-attribute-container', attr]
58
59
  classes << (active ? 'active' : 'inactive')
59
- classes << 'one' if object.respond_to?(:one?) and object.one?
60
+ if object.is_a? RecordCollection::Base
61
+ classes << 'one' if object.one?
62
+ else
63
+ # Assume normal record, this always behaves like one
64
+ classes << 'one'
65
+ end
60
66
  classes << 'error' if object.errors[attr].present?
61
67
  classes
62
68
  end
@@ -1,3 +1,3 @@
1
1
  module RecordCollection
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
@@ -32,10 +32,13 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "jquery-rails"
33
33
  spec.add_development_dependency "js-routes"
34
34
  spec.add_development_dependency "capybara"
35
+ spec.add_development_dependency "capybara-screenshot"
35
36
  spec.add_development_dependency "poltergeist"
36
37
  spec.add_development_dependency "launchy"
37
38
  spec.add_development_dependency "database_cleaner"
38
39
  spec.add_development_dependency "spring"
40
+ spec.add_development_dependency "spring-commands-rspec"
41
+ spec.add_development_dependency "quiet_assets"
39
42
 
40
43
 
41
44
  spec.add_runtime_dependency 'active_attr', '~> 0.8'
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  <div class="field">
19
19
  <%= f.label :section %><br>
20
- <%= f.text_field :section %>
20
+ <%= f.optional_text_field :section %>
21
21
  </div>
22
22
  <div class="actions">
23
23
  <%= f.submit %>
@@ -20,4 +20,5 @@ RSpec.feature "Multi select", type: :feature do
20
20
  Employee.pluck(:admin).should be_none
21
21
 
22
22
  end
23
+
23
24
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.feature "Optional text_field with normal record", type: :feature do
4
+ scenario "Selecting all", js: true do
5
+ employee = Employee.create name: 'E1', admin: true, vegan: false
6
+ visit edit_employee_path(employee.id)
7
+
8
+ find('#employee_section').set 'SEC' # this is an optional
9
+ find('[name="commit"]').click
10
+
11
+ employee.reload
12
+
13
+ employee.section.should == 'SEC'
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.feature "Optionals with one record", type: :feature do
4
+ scenario "Selecting all", js: true do
5
+ employee = Employee.create name: 'E1', admin: true, vegan: false
6
+ visit collection_edit_employees_path(ids: [employee.id])
7
+
8
+ find('#collection_section').set 'SEC'
9
+ find('[name="commit"]').click
10
+
11
+ employee.reload
12
+
13
+ employee.section.should == 'SEC'
14
+ end
15
+
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin ter Kuile
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: capybara-screenshot
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: poltergeist
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +262,34 @@ dependencies:
248
262
  - - ">="
249
263
  - !ruby/object:Gem::Version
250
264
  version: '0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: spring-commands-rspec
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: quiet_assets
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
251
293
  - !ruby/object:Gem::Dependency
252
294
  name: active_attr
253
295
  requirement: !ruby/object:Gem::Requirement
@@ -314,6 +356,7 @@ files:
314
356
  - app/controllers/record_collection/application_controller.rb
315
357
  - app/helpers/record_collection/application_helper.rb
316
358
  - app/views/layouts/record_collection/application.html.erb
359
+ - config/spring.rb
317
360
  - lib/generators/collection_scaffold/collection_scaffold_generator.rb
318
361
  - lib/generators/collection_scaffold/templates/_form.html.haml
319
362
  - lib/generators/collection_scaffold/templates/_form.html.slim
@@ -408,6 +451,8 @@ files:
408
451
  - spec/dummy/public/500.html
409
452
  - spec/dummy/public/favicon.ico
410
453
  - spec/features/multi_select_spec.rb
454
+ - spec/features/optional_text_field_with_normal_resource_spec.rb
455
+ - spec/features/optionals_with_one_record_spec.rb
411
456
  - spec/features/translations_spec.rb
412
457
  - spec/fixtures/collections.rb
413
458
  - spec/rails/form_builder_spec.rb
@@ -507,6 +552,8 @@ test_files:
507
552
  - spec/dummy/public/500.html
508
553
  - spec/dummy/public/favicon.ico
509
554
  - spec/features/multi_select_spec.rb
555
+ - spec/features/optional_text_field_with_normal_resource_spec.rb
556
+ - spec/features/optionals_with_one_record_spec.rb
510
557
  - spec/features/translations_spec.rb
511
558
  - spec/fixtures/collections.rb
512
559
  - spec/rails/form_builder_spec.rb