simple_form 2.1.3 → 3.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (72) hide show
  1. data/CHANGELOG.md +6 -54
  2. data/README.md +129 -111
  3. data/lib/generators/simple_form/install_generator.rb +4 -4
  4. data/lib/generators/simple_form/templates/README +2 -2
  5. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +8 -11
  6. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +16 -16
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +3 -3
  8. data/lib/simple_form.rb +31 -47
  9. data/lib/simple_form/action_view_extensions/builder.rb +0 -319
  10. data/lib/simple_form/action_view_extensions/builder.rb.orig +247 -0
  11. data/lib/simple_form/action_view_extensions/form_helper.rb +1 -1
  12. data/lib/simple_form/components.rb +1 -1
  13. data/lib/simple_form/components/errors.rb +1 -7
  14. data/lib/simple_form/components/hints.rb +2 -7
  15. data/lib/simple_form/components/html5.rb +1 -1
  16. data/lib/simple_form/components/labels.rb +4 -4
  17. data/lib/simple_form/components/maxlength.rb +1 -8
  18. data/lib/simple_form/error_notification.rb +2 -2
  19. data/lib/simple_form/form_builder.rb +144 -46
  20. data/lib/simple_form/form_builder.rb.orig +486 -0
  21. data/lib/simple_form/helpers.rb +1 -1
  22. data/lib/simple_form/inputs/base.rb +3 -10
  23. data/lib/simple_form/inputs/block_input.rb +1 -1
  24. data/lib/simple_form/inputs/boolean_input.rb +6 -6
  25. data/lib/simple_form/inputs/collection_input.rb +7 -7
  26. data/lib/simple_form/inputs/numeric_input.rb +0 -6
  27. data/lib/simple_form/inputs/password_input.rb +0 -1
  28. data/lib/simple_form/inputs/string_input.rb +0 -1
  29. data/lib/simple_form/railtie.rb +7 -0
  30. data/lib/simple_form/tags.rb +61 -0
  31. data/lib/simple_form/version.rb +1 -1
  32. data/lib/simple_form/version.rb.orig +7 -0
  33. data/lib/simple_form/wrappers.rb +1 -1
  34. data/lib/simple_form/wrappers/builder.rb +5 -29
  35. data/lib/simple_form/wrappers/many.rb +1 -1
  36. data/lib/simple_form/wrappers/root.rb +1 -1
  37. data/test/action_view_extensions/builder_test.rb +67 -87
  38. data/test/action_view_extensions/form_helper_test.rb +16 -16
  39. data/test/components/label_test.rb +46 -46
  40. data/test/form_builder/association_test.rb +23 -23
  41. data/test/form_builder/button_test.rb +4 -4
  42. data/test/form_builder/error_notification_test.rb +8 -8
  43. data/test/form_builder/error_test.rb +18 -65
  44. data/test/form_builder/general_test.rb +45 -65
  45. data/test/form_builder/hint_test.rb +23 -29
  46. data/test/form_builder/input_field_test.rb +12 -12
  47. data/test/form_builder/label_test.rb +6 -16
  48. data/test/form_builder/wrapper_test.rb +21 -21
  49. data/test/inputs/boolean_input_test.rb +23 -35
  50. data/test/inputs/collection_check_boxes_input_test.rb +55 -55
  51. data/test/inputs/collection_radio_buttons_input_test.rb +70 -79
  52. data/test/inputs/collection_select_input_test.rb +45 -51
  53. data/test/inputs/datetime_input_test.rb +11 -11
  54. data/test/inputs/disabled_test.rb +10 -10
  55. data/test/inputs/discovery_test.rb +4 -4
  56. data/test/inputs/file_input_test.rb +1 -1
  57. data/test/inputs/general_test.rb +12 -12
  58. data/test/inputs/grouped_collection_select_input_test.rb +20 -20
  59. data/test/inputs/hidden_input_test.rb +1 -1
  60. data/test/inputs/numeric_input_test.rb +3 -3
  61. data/test/inputs/priority_input_test.rb +3 -3
  62. data/test/inputs/readonly_test.rb +12 -12
  63. data/test/inputs/required_test.rb +5 -5
  64. data/test/inputs/string_input_test.rb +10 -25
  65. data/test/inputs/text_input_test.rb +1 -1
  66. data/test/support/misc_helpers.rb +24 -24
  67. data/test/support/mock_controller.rb +6 -6
  68. data/test/support/models.rb +37 -46
  69. data/test/test_helper.rb +20 -20
  70. metadata +49 -24
  71. checksums.yaml +0 -7
  72. data/lib/simple_form/core_ext/hash.rb +0 -16
@@ -13,12 +13,12 @@ class MockController
13
13
  "http://example.com"
14
14
  end
15
15
 
16
- def url_helpers
17
- self
16
+ def url_options
17
+ {}
18
18
  end
19
19
 
20
- def hash_for_user_path(*args); end
21
- def hash_for_validating_user_path(*args); end
22
- def hash_for_other_validating_user_path(*args); end
23
- def hash_for_users_path(*args); end
20
+ def hash_for_user_path(*); end
21
+ def hash_for_validating_user_path(*); end
22
+ def hash_for_other_validating_user_path(*); end
23
+ def hash_for_users_path(*); end
24
24
  end
@@ -112,7 +112,7 @@ class User
112
112
  when :first_company
113
113
  Association.new(Company, association, :has_one, {})
114
114
  when :special_company
115
- Association.new(Company, association, :belongs_to, { :conditions => { :id => 1 } })
115
+ Association.new(Company, association, :belongs_to, { conditions: { id: 1 } })
116
116
  end
117
117
  end
118
118
 
@@ -120,11 +120,11 @@ class User
120
120
  @errors ||= begin
121
121
  hash = Hash.new { |h,k| h[k] = [] }
122
122
  hash.merge!(
123
- :name => ["can't be blank"],
124
- :description => ["must be longer than 15 characters"],
125
- :age => ["is not a number", "must be greater than 18"],
126
- :company => ["company must be present"],
127
- :company_id => ["must be valid"]
123
+ name: ["can't be blank"],
124
+ description: ["must be longer than 15 characters"],
125
+ age: ["is not a number", "must be greater than 18"],
126
+ company: ["company must be present"],
127
+ company_id: ["must be valid"]
128
128
  )
129
129
  end
130
130
  end
@@ -136,31 +136,31 @@ end
136
136
 
137
137
  class ValidatingUser < User
138
138
  include ActiveModel::Validations
139
- validates :name, :presence => true
140
- validates :company, :presence => true
141
- validates :age, :presence => true, :if => Proc.new { |user| user.name }
142
- validates :amount, :presence => true, :unless => Proc.new { |user| user.age }
139
+ validates :name, presence: true
140
+ validates :company, presence: true
141
+ validates :age, presence: true, if: Proc.new { |user| user.name }
142
+ validates :amount, presence: true, unless: Proc.new { |user| user.age }
143
143
 
144
- validates :action, :presence => true, :on => :create
145
- validates :credit_limit, :presence => true, :on => :save
146
- validates :phone_number, :presence => true, :on => :update
144
+ validates :action, presence: true, on: :create
145
+ validates :credit_limit, presence: true, on: :save
146
+ validates :phone_number, presence: true, on: :update
147
147
 
148
148
  validates_numericality_of :age,
149
- :greater_than_or_equal_to => 18,
150
- :less_than_or_equal_to => 99,
151
- :only_integer => true
149
+ greater_than_or_equal_to: 18,
150
+ less_than_or_equal_to: 99,
151
+ only_integer: true
152
152
  validates_numericality_of :amount,
153
- :greater_than => :min_amount,
154
- :less_than => :max_amount,
155
- :only_integer => true
153
+ greater_than: :min_amount,
154
+ less_than: :max_amount,
155
+ only_integer: true
156
156
  validates_numericality_of :attempts,
157
- :greater_than_or_equal_to => :min_attempts,
158
- :less_than_or_equal_to => :max_attempts,
159
- :only_integer => true
160
- validates_length_of :name, :maximum => 25
161
- validates_length_of :description, :maximum => 50
162
- validates_length_of :action, :maximum => 10, :tokenizer => lambda { |str| str.scan(/\w+/) }
163
- validates_length_of :home_picture, :is => 12
157
+ greater_than_or_equal_to: :min_attempts,
158
+ less_than_or_equal_to: :max_attempts,
159
+ only_integer: true
160
+ validates_length_of :name, maximum: 25
161
+ validates_length_of :description, maximum: 50
162
+ validates_length_of :action, maximum: 10, tokenizer: lambda { |str| str.scan(/\w+/) }
163
+ validates_length_of :home_picture, is: 12
164
164
 
165
165
  def min_amount
166
166
  10
@@ -182,26 +182,20 @@ end
182
182
  class OtherValidatingUser < User
183
183
  include ActiveModel::Validations
184
184
  validates_numericality_of :age,
185
- :greater_than => 17,
186
- :less_than => 100,
187
- :only_integer => true
185
+ greater_than: 17,
186
+ less_than: 100,
187
+ only_integer: true
188
188
  validates_numericality_of :amount,
189
- :greater_than => Proc.new { |user| user.age },
190
- :less_than => Proc.new { |user| user.age + 100},
191
- :only_integer => true
189
+ greater_than: Proc.new { |user| user.age },
190
+ less_than: Proc.new { |user| user.age + 100},
191
+ only_integer: true
192
192
  validates_numericality_of :attempts,
193
- :greater_than_or_equal_to => Proc.new { |user| user.age },
194
- :less_than_or_equal_to => Proc.new { |user| user.age + 100},
195
- :only_integer => true
193
+ greater_than_or_equal_to: Proc.new { |user| user.age },
194
+ less_than_or_equal_to: Proc.new { |user| user.age + 100},
195
+ only_integer: true
196
196
 
197
- validates_format_of :country, :with => /\w+/
198
-
199
- # TODO: Remove this check when we drop Rails 3.0 support
200
- if ActiveModel::VERSION::MAJOR == 3 && ActiveModel::VERSION::MINOR >= 1
201
- validates_format_of :name, :with => Proc.new { /\w+/ }
202
- else
203
- validates_format_of :name, :with => /\w+/
204
- end
197
+ validates_format_of :country, with: /\w+/
198
+ validates_format_of :name, with: Proc.new { /\w+/ }
205
199
  end
206
200
 
207
201
  class HashBackedAuthor < Hash
@@ -214,6 +208,3 @@ class HashBackedAuthor < Hash
214
208
  'hash backed author'
215
209
  end
216
210
  end
217
-
218
- class UserNumber1And2 < User
219
- end
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'bundler/setup'
3
3
 
4
4
  require 'test/unit'
5
- require 'mocha'
5
+ require 'mocha/setup'
6
6
 
7
7
  require 'active_model'
8
8
  require 'action_controller'
@@ -47,31 +47,31 @@ class ActionView::TestCase
47
47
 
48
48
  def setup_new_user(options={})
49
49
  @user = User.new({
50
- :id => 1,
51
- :name => 'New in SimpleForm!',
52
- :description => 'Hello!',
53
- :created_at => Time.now
50
+ id: 1,
51
+ name: 'New in SimpleForm!',
52
+ description: 'Hello!',
53
+ created_at: Time.now
54
54
  }.merge(options))
55
55
 
56
56
  @validating_user = ValidatingUser.new({
57
- :id => 1,
58
- :name => 'New in SimpleForm!',
59
- :description => 'Hello!',
60
- :home_picture => 'Home picture',
61
- :created_at => Time.now,
62
- :age => 19,
63
- :amount => 15,
64
- :attempts => 1,
65
- :company => [1]
57
+ id: 1,
58
+ name: 'New in SimpleForm!',
59
+ description: 'Hello!',
60
+ home_picture: 'Home picture',
61
+ created_at: Time.now,
62
+ age: 19,
63
+ amount: 15,
64
+ attempts: 1,
65
+ company: [1]
66
66
  }.merge(options))
67
67
 
68
68
  @other_validating_user = OtherValidatingUser.new({
69
- :id => 1,
70
- :name => 'New in SimpleForm!',
71
- :description => 'Hello!',
72
- :created_at => Time.now,
73
- :age => 19,
74
- :company => 1
69
+ id: 1,
70
+ name: 'New in SimpleForm!',
71
+ description: 'Hello!',
72
+ created_at: Time.now,
73
+ age: 19,
74
+ company: 1
75
75
  }.merge(options))
76
76
  end
77
77
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 3.0.0.beta1
5
+ prerelease: 6
5
6
  platform: ruby
6
7
  authors:
7
8
  - José Valim
@@ -10,36 +11,52 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-07-02 00:00:00.000000000 Z
14
+ date: 2013-02-26 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activemodel
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - "~>"
21
+ - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
- version: '3.0'
23
+ version: 4.0.0.beta
24
+ - - <
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
22
27
  type: :runtime
23
28
  prerelease: false
24
29
  version_requirements: !ruby/object:Gem::Requirement
30
+ none: false
25
31
  requirements:
26
- - - "~>"
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 4.0.0.beta
35
+ - - <
27
36
  - !ruby/object:Gem::Version
28
- version: '3.0'
37
+ version: '4.1'
29
38
  - !ruby/object:Gem::Dependency
30
39
  name: actionpack
31
40
  requirement: !ruby/object:Gem::Requirement
41
+ none: false
32
42
  requirements:
33
- - - "~>"
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 4.0.0.beta
46
+ - - <
34
47
  - !ruby/object:Gem::Version
35
- version: '3.0'
48
+ version: '4.1'
36
49
  type: :runtime
37
50
  prerelease: false
38
51
  version_requirements: !ruby/object:Gem::Requirement
52
+ none: false
39
53
  requirements:
40
- - - "~>"
54
+ - - ! '>='
41
55
  - !ruby/object:Gem::Version
42
- version: '3.0'
56
+ version: 4.0.0.beta
57
+ - - <
58
+ - !ruby/object:Gem::Version
59
+ version: '4.1'
43
60
  description: Forms made easy!
44
61
  email: contact@plataformatec.com.br
45
62
  executables: []
@@ -49,9 +66,7 @@ files:
49
66
  - CHANGELOG.md
50
67
  - MIT-LICENSE
51
68
  - README.md
52
- - lib/generators/simple_form/USAGE
53
69
  - lib/generators/simple_form/install_generator.rb
54
- - lib/generators/simple_form/templates/README
55
70
  - lib/generators/simple_form/templates/_form.html.erb
56
71
  - lib/generators/simple_form/templates/_form.html.haml
57
72
  - lib/generators/simple_form/templates/_form.html.slim
@@ -59,10 +74,11 @@ files:
59
74
  - lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb
60
75
  - lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb
61
76
  - lib/generators/simple_form/templates/config/locales/simple_form.en.yml
62
- - lib/simple_form.rb
77
+ - lib/generators/simple_form/templates/README
78
+ - lib/generators/simple_form/USAGE
63
79
  - lib/simple_form/action_view_extensions/builder.rb
80
+ - lib/simple_form/action_view_extensions/builder.rb.orig
64
81
  - lib/simple_form/action_view_extensions/form_helper.rb
65
- - lib/simple_form/components.rb
66
82
  - lib/simple_form/components/errors.rb
67
83
  - lib/simple_form/components/hints.rb
68
84
  - lib/simple_form/components/html5.rb
@@ -73,17 +89,17 @@ files:
73
89
  - lib/simple_form/components/pattern.rb
74
90
  - lib/simple_form/components/placeholders.rb
75
91
  - lib/simple_form/components/readonly.rb
76
- - lib/simple_form/core_ext/hash.rb
92
+ - lib/simple_form/components.rb
77
93
  - lib/simple_form/error_notification.rb
78
94
  - lib/simple_form/form_builder.rb
79
- - lib/simple_form/helpers.rb
95
+ - lib/simple_form/form_builder.rb.orig
80
96
  - lib/simple_form/helpers/autofocus.rb
81
97
  - lib/simple_form/helpers/disabled.rb
82
98
  - lib/simple_form/helpers/readonly.rb
83
99
  - lib/simple_form/helpers/required.rb
84
100
  - lib/simple_form/helpers/validators.rb
101
+ - lib/simple_form/helpers.rb
85
102
  - lib/simple_form/i18n_cache.rb
86
- - lib/simple_form/inputs.rb
87
103
  - lib/simple_form/inputs/base.rb
88
104
  - lib/simple_form/inputs/block_input.rb
89
105
  - lib/simple_form/inputs/boolean_input.rb
@@ -101,13 +117,18 @@ files:
101
117
  - lib/simple_form/inputs/range_input.rb
102
118
  - lib/simple_form/inputs/string_input.rb
103
119
  - lib/simple_form/inputs/text_input.rb
120
+ - lib/simple_form/inputs.rb
104
121
  - lib/simple_form/map_type.rb
122
+ - lib/simple_form/railtie.rb
123
+ - lib/simple_form/tags.rb
105
124
  - lib/simple_form/version.rb
106
- - lib/simple_form/wrappers.rb
125
+ - lib/simple_form/version.rb.orig
107
126
  - lib/simple_form/wrappers/builder.rb
108
127
  - lib/simple_form/wrappers/many.rb
109
128
  - lib/simple_form/wrappers/root.rb
110
129
  - lib/simple_form/wrappers/single.rb
130
+ - lib/simple_form/wrappers.rb
131
+ - lib/simple_form.rb
111
132
  - test/action_view_extensions/builder_test.rb
112
133
  - test/action_view_extensions/form_helper_test.rb
113
134
  - test/components/label_test.rb
@@ -146,26 +167,30 @@ files:
146
167
  - test/test_helper.rb
147
168
  homepage: https://github.com/plataformatec/simple_form
148
169
  licenses: []
149
- metadata: {}
150
170
  post_install_message:
151
171
  rdoc_options: []
152
172
  require_paths:
153
173
  - lib
154
174
  required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
155
176
  requirements:
156
- - - ">="
177
+ - - ! '>='
157
178
  - !ruby/object:Gem::Version
158
179
  version: '0'
180
+ segments:
181
+ - 0
182
+ hash: 2771371477718210215
159
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
160
185
  requirements:
161
- - - ">="
186
+ - - ! '>'
162
187
  - !ruby/object:Gem::Version
163
- version: '0'
188
+ version: 1.3.1
164
189
  requirements: []
165
190
  rubyforge_project: simple_form
166
- rubygems_version: 2.2.3
191
+ rubygems_version: 1.8.23
167
192
  signing_key:
168
- specification_version: 4
193
+ specification_version: 3
169
194
  summary: Forms made easy!
170
195
  test_files:
171
196
  - test/action_view_extensions/builder_test.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e0846cac8facbc990fc17731962d98598a2e40ee
4
- data.tar.gz: 4e1b4b5645eb07f7273b89b4a50007a6cc72fb82
5
- SHA512:
6
- metadata.gz: 0aeca7d6cf3e6ea92299c4a55f7483e5f9ef3c49fc9497840cb11109eb57872cebc98b71c49669b5334cd8409dae300e40409fae39c0d9f2634060fdf65fb95c
7
- data.tar.gz: 7c9fe5310c7403486fbbeeeb2f4633fb9e6987b6c22e663d727e6eacd41f357252a705ac31e5e91cf03575cc053b153f7fa1ff3f31b0545b9ce82ffb34510582
@@ -1,16 +0,0 @@
1
- # TODO: Delete this file when we drop support for Rails 3.0
2
- # This method is already implemented in active_support 3.1
3
-
4
- unless Hash.new.respond_to?(:deep_dup)
5
- class Hash
6
- # Returns a deep copy of hash.
7
- def deep_dup
8
- duplicate = self.dup
9
- duplicate.each_pair do |k,v|
10
- tv = duplicate[k]
11
- duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v
12
- end
13
- duplicate
14
- end
15
- end
16
- end