simple_form 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of simple_form might be problematic. Click here for more details.

@@ -1,3 +1,8 @@
1
+ == 1.5.2
2
+
3
+ * bug fix
4
+ * Remove the internal usage of deprecated `:components`
5
+
1
6
  == 1.5.1
2
7
 
3
8
  * enhancements
@@ -112,9 +112,12 @@ module SimpleForm
112
112
  # name="user[name]" size="100" type="text" value="Carlos" />
113
113
  #
114
114
  def input_field(attribute_name, options={})
115
+ column = find_attribute_column(attribute_name)
116
+ input_type = default_input_type(attribute_name, column, options)
117
+
115
118
  options[:input_html] = options.except(:as, :collection, :label_method, :value_method)
116
- options.merge!(:components => [:input], :wrapper => false)
117
- input(attribute_name, options)
119
+
120
+ find_mapping(input_type).new(self, attribute_name, column, input_type, options).input
118
121
  end
119
122
 
120
123
  # Helper for dealing with association selects/radios, generating the
@@ -1,3 +1,3 @@
1
1
  module SimpleForm
2
- VERSION = "1.5.1".freeze
2
+ VERSION = "1.5.2".freeze
3
3
  end
@@ -0,0 +1,7 @@
1
+ module Div
2
+ def div
3
+ template.content_tag(:div, 'Custom Component', :class => 'custom_input')
4
+ end
5
+ end
6
+
7
+ SimpleForm::Inputs::Base.send(:include, Div)
@@ -453,60 +453,50 @@ class FormBuilderTest < ActionView::TestCase
453
453
 
454
454
  # ONLY THE INPUT TAG
455
455
  test "builder input_field should only render the input tag, nothing else" do
456
- ActiveSupport::Deprecation.silence do
457
- with_concat_form_for(@user) do |f|
458
- f.input_field :name
459
- end
460
- assert_select 'form > input.required.string'
461
- assert_no_select 'div.string'
462
- assert_no_select 'label'
463
- assert_no_select '.hint'
456
+ with_concat_form_for(@user) do |f|
457
+ f.input_field :name
464
458
  end
459
+ assert_select 'form > input.required.string'
460
+ assert_no_select 'div.string'
461
+ assert_no_select 'label'
462
+ assert_no_select '.hint'
465
463
  end
466
464
 
467
465
  test 'builder input_field should allow overriding default input type' do
468
- ActiveSupport::Deprecation.silence do
469
- with_concat_form_for(@user) do |f|
470
- f.input_field :name, :as => :text
471
- end
472
-
473
- assert_no_select 'input#user_name'
474
- assert_select 'textarea#user_name.text'
466
+ with_concat_form_for(@user) do |f|
467
+ f.input_field :name, :as => :text
475
468
  end
469
+
470
+ assert_no_select 'input#user_name'
471
+ assert_select 'textarea#user_name.text'
476
472
  end
477
473
 
478
474
  test 'builder input_field should allow passing options to input tag' do
479
- ActiveSupport::Deprecation.silence do
480
- with_concat_form_for(@user) do |f|
481
- f.input_field :name, :id => 'name_input', :class => 'name'
482
- end
483
-
484
- assert_select 'input.string.name#name_input'
475
+ with_concat_form_for(@user) do |f|
476
+ f.input_field :name, :id => 'name_input', :class => 'name'
485
477
  end
478
+
479
+ assert_select 'input.string.name#name_input'
486
480
  end
487
481
 
488
482
  test 'builder input_field should generate an input tag with a clean HTML' do
489
- ActiveSupport::Deprecation.silence do
490
- with_concat_form_for(@user) do |f|
491
- f.input_field :name, :as => :integer, :class => 'name'
492
- end
493
-
494
- assert_no_select 'input.integer[input_html]'
495
- assert_no_select 'input.integer[as]'
483
+ with_concat_form_for(@user) do |f|
484
+ f.input_field :name, :as => :integer, :class => 'name'
496
485
  end
486
+
487
+ assert_no_select 'input.integer[input_html]'
488
+ assert_no_select 'input.integer[as]'
497
489
  end
498
490
 
499
491
  test 'builder collection input_field should generate input tag with a clean HTML' do
500
- ActiveSupport::Deprecation.silence do
501
- with_concat_form_for(@user) do |f|
502
- f.input_field :status, :collection => ['Open', 'Closed'], :class => 'status', :label_method => :to_s, :value_method => :to_s
503
- end
504
-
505
- assert_no_select 'select.status[input_html]'
506
- assert_no_select 'select.status[collection]'
507
- assert_no_select 'select.status[label_method]'
508
- assert_no_select 'select.status[value_method]'
492
+ with_concat_form_for(@user) do |f|
493
+ f.input_field :status, :collection => ['Open', 'Closed'], :class => 'status', :label_method => :to_s, :value_method => :to_s
509
494
  end
495
+
496
+ assert_no_select 'select.status[input_html]'
497
+ assert_no_select 'select.status[collection]'
498
+ assert_no_select 'select.status[label_method]'
499
+ assert_no_select 'select.status[value_method]'
510
500
  end
511
501
 
512
502
  # WITHOUT OBJECT
@@ -904,4 +894,37 @@ class FormBuilderTest < ActionView::TestCase
904
894
  assert_select 'form section input#user_age.numeric.integer'
905
895
  end
906
896
  end
897
+
898
+ # CUSTOM COMPONENTS
899
+ # Setup new components and remove them after the test.
900
+ def custom_component(components=[:label_input, :div])
901
+ swap SimpleForm, :components => components do
902
+ begin
903
+ load "custom_components.rb"
904
+ yield
905
+ ensure
906
+ Div.send(:undef_method, :div)
907
+ Object.send :remove_const, :Div
908
+ end
909
+ end
910
+ end
911
+
912
+ test 'builder should accept new components' do
913
+ custom_component do
914
+ with_form_for @user, :age
915
+ assert_select 'form input#user_age.numeric.integer'
916
+ assert_select 'form .custom_input'
917
+ end
918
+ end
919
+
920
+ test 'input field should render only the input' do
921
+ custom_component do
922
+ with_concat_form_for(@user) do |f|
923
+ f.input_field :age
924
+ end
925
+
926
+ assert_select 'form input#user_age.numeric.integer'
927
+ assert_no_select 'form .custom_input'
928
+ end
929
+ end
907
930
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 1
10
- version: 1.5.1
9
+ - 2
10
+ version: 1.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -16,13 +16,13 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-15 00:00:00 -03:00
19
+ date: 2011-09-23 00:00:00 -03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: activemodel
24
24
  prerelease: false
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
28
  - - ~>
@@ -33,11 +33,11 @@ dependencies:
33
33
  - 0
34
34
  version: "3.0"
35
35
  type: :runtime
36
- requirement: *id001
36
+ version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: actionpack
39
39
  prerelease: false
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -48,7 +48,7 @@ dependencies:
48
48
  - 0
49
49
  version: "3.0"
50
50
  type: :runtime
51
- requirement: *id002
51
+ version_requirements: *id002
52
52
  description: Forms made easy!
53
53
  email: contact@plataformatec.com.br
54
54
  executables: []
@@ -115,6 +115,7 @@ files:
115
115
  - test/components/hint_test.rb
116
116
  - test/components/label_test.rb
117
117
  - test/components/wrapper_test.rb
118
+ - test/custom_components.rb
118
119
  - test/discovery_inputs.rb
119
120
  - test/error_notification_test.rb
120
121
  - test/form_builder_test.rb
@@ -166,6 +167,7 @@ test_files:
166
167
  - test/components/hint_test.rb
167
168
  - test/components/label_test.rb
168
169
  - test/components/wrapper_test.rb
170
+ - test/custom_components.rb
169
171
  - test/discovery_inputs.rb
170
172
  - test/error_notification_test.rb
171
173
  - test/form_builder_test.rb