simple_form 1.2.2 → 1.3.0

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.

Files changed (36) hide show
  1. data/README.rdoc +80 -14
  2. data/lib/generators/simple_form/templates/_form.html.erb +1 -11
  3. data/lib/generators/simple_form/templates/simple_form.rb +31 -6
  4. data/lib/simple_form.rb +38 -2
  5. data/lib/simple_form/action_view_extensions/builder.rb +53 -20
  6. data/lib/simple_form/components.rb +6 -5
  7. data/lib/simple_form/components/errors.rb +4 -6
  8. data/lib/simple_form/components/hints.rb +2 -2
  9. data/lib/simple_form/components/labels.rb +3 -5
  10. data/lib/simple_form/components/placeholders.rb +22 -0
  11. data/lib/simple_form/components/wrapper.rb +7 -0
  12. data/lib/simple_form/error_notification.rb +4 -6
  13. data/lib/simple_form/form_builder.rb +61 -55
  14. data/lib/simple_form/has_errors.rb +14 -0
  15. data/lib/simple_form/inputs/base.rb +45 -17
  16. data/lib/simple_form/inputs/block_input.rb +3 -2
  17. data/lib/simple_form/inputs/collection_input.rb +42 -17
  18. data/lib/simple_form/inputs/date_time_input.rb +3 -1
  19. data/lib/simple_form/inputs/hidden_input.rb +11 -2
  20. data/lib/simple_form/inputs/mapping_input.rb +16 -3
  21. data/lib/simple_form/inputs/numeric_input.rb +45 -8
  22. data/lib/simple_form/inputs/string_input.rb +13 -9
  23. data/lib/simple_form/map_type.rb +4 -4
  24. data/lib/simple_form/version.rb +1 -1
  25. data/test/action_view_extensions/builder_test.rb +155 -51
  26. data/test/components/error_test.rb +10 -8
  27. data/test/components/hint_test.rb +4 -8
  28. data/test/components/label_test.rb +22 -9
  29. data/test/components/wrapper_test.rb +16 -7
  30. data/test/error_notification_test.rb +4 -3
  31. data/test/form_builder_test.rb +81 -34
  32. data/test/inputs_test.rb +242 -3
  33. data/test/support/misc_helpers.rb +6 -4
  34. data/test/support/models.rb +26 -3
  35. data/test/test_helper.rb +13 -5
  36. metadata +25 -8
@@ -8,10 +8,8 @@ module MiscHelpers
8
8
  end
9
9
  end
10
10
 
11
- def assert_no_select(*args)
12
- assert_raise Test::Unit::AssertionFailedError do
13
- assert_select(*args)
14
- end
11
+ def assert_no_select(selector, value = nil)
12
+ assert_select(selector, :text => value, :count => 0)
15
13
  end
16
14
 
17
15
  def swap(object, new_values)
@@ -26,4 +24,8 @@ module MiscHelpers
26
24
  object.send :"#{key}=", value
27
25
  end
28
26
  end
27
+
28
+ def with_concat_form_for(object, &block)
29
+ concat simple_form_for(object, &block)
30
+ end
29
31
  end
@@ -5,6 +5,7 @@ Association = Struct.new(:klass, :name, :macro, :options)
5
5
 
6
6
  class Company < Struct.new(:id, :name)
7
7
  extend ActiveModel::Naming
8
+ include ActiveModel::Conversion
8
9
 
9
10
  def self.all(options={})
10
11
  all = (1..3).map{|i| Company.new(i, "Company #{i}")}
@@ -26,17 +27,26 @@ end
26
27
 
27
28
  class Tag < Company
28
29
  extend ActiveModel::Naming
30
+ include ActiveModel::Conversion
29
31
 
30
32
  def self.all(options={})
31
33
  (1..3).map{|i| Tag.new(i, "Tag #{i}")}
32
34
  end
33
35
  end
34
36
 
35
- class User < OpenStruct
37
+ class User
36
38
  extend ActiveModel::Naming
39
+ include ActiveModel::Conversion
37
40
 
38
- # Get rid of deprecation warnings
39
- undef_method :id if respond_to?(:id)
41
+ attr_accessor :id, :name, :company, :company_id, :time_zone, :active, :description, :created_at, :updated_at,
42
+ :credit_limit, :age, :password, :delivery_time, :born_at, :special_company_id, :country, :url, :tag_ids,
43
+ :avatar, :email, :status, :residence_country, :phone_number, :post_count
44
+
45
+ def initialize(options={})
46
+ options.each do |key, value|
47
+ send("#{key}=", value)
48
+ end if options
49
+ end
40
50
 
41
51
  def new_record!
42
52
  @new_record = true
@@ -107,4 +117,17 @@ end
107
117
  class ValidatingUser < User
108
118
  include ActiveModel::Validations
109
119
  validates :name, :presence => true
120
+ validates :company, :presence => true
121
+ validates_numericality_of :age,
122
+ :greater_than_or_equal_to => 18,
123
+ :less_than_or_equal_to => 99,
124
+ :only_integer => true
125
+ end
126
+
127
+ class OtherValidatingUser < User
128
+ include ActiveModel::Validations
129
+ validates_numericality_of :age,
130
+ :greater_than => 17,
131
+ :less_than => 100,
132
+ :only_integer => true
110
133
  end
data/test/test_helper.rb CHANGED
@@ -27,10 +27,6 @@ else
27
27
  raise "Could not find country_select plugin in test/support. Please execute git submodule update --init."
28
28
  end
29
29
 
30
- class SimpleForm::FormBuilder
31
- attr_accessor :attribute_name, :column, :reflection, :input_type, :options
32
- end
33
-
34
30
  class ActionView::TestCase
35
31
  include MiscHelpers
36
32
  include SimpleForm::ActionViewExtensions::FormHelper
@@ -59,7 +55,18 @@ class ActionView::TestCase
59
55
  :id => 1,
60
56
  :name => 'New in Simple Form!',
61
57
  :description => 'Hello!',
62
- :created_at => Time.now
58
+ :created_at => Time.now,
59
+ :age => 19,
60
+ :company => 1
61
+ }.merge(options))
62
+
63
+ @other_validating_user = OtherValidatingUser.new({
64
+ :id => 1,
65
+ :name => 'New in Simple Form!',
66
+ :description => 'Hello!',
67
+ :created_at => Time.now,
68
+ :age => 19,
69
+ :company => 1
63
70
  }.merge(options))
64
71
  end
65
72
 
@@ -73,4 +80,5 @@ class ActionView::TestCase
73
80
  alias :users_path :user_path
74
81
  alias :super_user_path :user_path
75
82
  alias :validating_user_path :user_path
83
+ alias :other_validating_user_path :user_path
76
84
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 2
10
- version: 1.2.2
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -16,10 +16,25 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-07-27 00:00:00 +02:00
19
+ date: 2010-12-08 00:00:00 -02:00
20
20
  default_executable:
21
- dependencies: []
22
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ type: :runtime
25
+ name: rails
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 7
32
+ segments:
33
+ - 3
34
+ - 0
35
+ - 0
36
+ version: 3.0.0
37
+ requirement: *id001
23
38
  description: Forms made easy!
24
39
  email: contact@plataformatec.com.br
25
40
  executables: []
@@ -44,9 +59,11 @@ files:
44
59
  - lib/simple_form/components/hints.rb
45
60
  - lib/simple_form/components/label_input.rb
46
61
  - lib/simple_form/components/labels.rb
62
+ - lib/simple_form/components/placeholders.rb
47
63
  - lib/simple_form/components/wrapper.rb
48
64
  - lib/simple_form/error_notification.rb
49
65
  - lib/simple_form/form_builder.rb
66
+ - lib/simple_form/has_errors.rb
50
67
  - lib/simple_form/i18n_cache.rb
51
68
  - lib/simple_form/inputs.rb
52
69
  - lib/simple_form/inputs/base.rb
@@ -82,8 +99,8 @@ homepage: http://github.com/plataformatec/simple_form
82
99
  licenses: []
83
100
 
84
101
  post_install_message:
85
- rdoc_options:
86
- - --charset=UTF-8
102
+ rdoc_options: []
103
+
87
104
  require_paths:
88
105
  - lib
89
106
  required_ruby_version: !ruby/object:Gem::Requirement