simple_form 1.1.2 → 1.1.3
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.
- data/README.rdoc +3 -12
- data/lib/simple_form/form_builder.rb +3 -30
- data/lib/simple_form/version.rb +1 -1
- data/test/action_view_extensions/builder_test.rb +36 -36
- data/test/action_view_extensions/form_helper_test.rb +6 -6
- data/test/components/error_test.rb +2 -2
- data/test/components/hint_test.rb +2 -2
- data/test/components/label_test.rb +2 -2
- data/test/form_builder_test.rb +14 -46
- data/test/inputs_test.rb +2 -2
- data/test/test_helper.rb +10 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -160,16 +160,7 @@ Simple enough right? This is going to render a :select input for choosing the :c
|
|
160
160
|
f.association :company, :as => :radio
|
161
161
|
f.association :roles, :as => :check_boxes
|
162
162
|
|
163
|
-
|
164
|
-
|
165
|
-
f.association :company, :order => 'name'
|
166
|
-
f.association :roles, :conditions => { :active => true }
|
167
|
-
|
168
|
-
You also have the ability to call named scopes using the association:
|
169
|
-
|
170
|
-
f.association :company, :scope => [:active, :available]
|
171
|
-
|
172
|
-
The association helper just invokes input under the hood, so all options available to :select, :radio and :check_boxes are also available to association. For example, you can specify the collection by hand, all together with the prompt:
|
163
|
+
The association helper just invokes input under the hood, so all options available to :select, :radio and :check_boxes are also available to association. Additionally, you can specify the collection by hand, all together with the prompt:
|
173
164
|
|
174
165
|
f.association :company, :collection => Company.active.all(:order => 'name'), :prompt => "Choose a Company"
|
175
166
|
|
@@ -235,8 +226,8 @@ SimpleForm comes with a lot of default mappings:
|
|
235
226
|
|
236
227
|
boolean check box boolean
|
237
228
|
string text field string
|
238
|
-
email email field string
|
239
|
-
url url field string
|
229
|
+
email email field string with name matching "email"
|
230
|
+
url url field string with name matching "url"
|
240
231
|
password password field string with name matching "password"
|
241
232
|
text text area text
|
242
233
|
file file field string, responding to file methods
|
@@ -96,36 +96,15 @@ module SimpleForm
|
|
96
96
|
# supported in input are also supported by association. Some extra options
|
97
97
|
# can also be given:
|
98
98
|
#
|
99
|
-
# == Options
|
100
|
-
#
|
101
|
-
# * :conditions - Given as conditions when retrieving the collection
|
102
|
-
#
|
103
|
-
# * :include - Given as include when retrieving the collection
|
104
|
-
#
|
105
|
-
# * :joins - Given as joins when retrieving the collection
|
106
|
-
#
|
107
|
-
# * :order - Given as order when retrieving the collection
|
108
|
-
#
|
109
|
-
# * :scope - Given as scopes when retrieving the collection
|
110
|
-
#
|
111
99
|
# == Examples
|
112
100
|
#
|
113
101
|
# simple_form_for @user do |f|
|
114
102
|
# f.association :company # Company.all
|
115
103
|
# end
|
116
104
|
#
|
117
|
-
# f.association :company, :order => 'name'
|
118
|
-
# # Company.all(:order => 'name')
|
119
|
-
#
|
120
|
-
# f.association :company, :conditions => { :active => true }
|
121
|
-
# # Company.all(:conditions => { :active => true })
|
122
|
-
#
|
123
105
|
# f.association :company, :collection => Company.all(:order => 'name')
|
124
106
|
# # Same as using :order option, but overriding collection
|
125
107
|
#
|
126
|
-
# f.association :company, :scope => [ :public, :not_broken ]
|
127
|
-
# # Same as doing Company.public.not_broken.all
|
128
|
-
#
|
129
108
|
# == Block
|
130
109
|
#
|
131
110
|
# When a block is given, association simple behaves as a proxy to
|
@@ -163,15 +142,9 @@ module SimpleForm
|
|
163
142
|
end
|
164
143
|
end
|
165
144
|
|
166
|
-
options[:collection] ||=
|
167
|
-
|
168
|
-
|
169
|
-
@reflection.options[:conditions])
|
170
|
-
klass = Array(options[:scope]).inject(@reflection.klass) do |klass, scope|
|
171
|
-
klass.send(scope)
|
172
|
-
end
|
173
|
-
klass.all(finders)
|
174
|
-
end
|
145
|
+
options[:collection] ||= @reflection.klass.all(
|
146
|
+
:conditions => @reflection.options[:conditions], :order => @reflection.options[:order]
|
147
|
+
)
|
175
148
|
|
176
149
|
returning(input(attribute, options)) { @reflection = nil }
|
177
150
|
end
|
data/lib/simple_form/version.rb
CHANGED
@@ -3,27 +3,27 @@ require 'test_helper'
|
|
3
3
|
class BuilderTest < ActionView::TestCase
|
4
4
|
# COLLECTION RADIO
|
5
5
|
test 'collection radio accepts a collection and generate inputs from value method' do
|
6
|
-
form_for @user do |f|
|
6
|
+
concat(form_for @user do |f|
|
7
7
|
concat f.collection_radio :active, [true, false], :to_s, :to_s
|
8
|
-
end
|
8
|
+
end)
|
9
9
|
|
10
10
|
assert_select 'form input[type=radio][value=true]#user_active_true'
|
11
11
|
assert_select 'form input[type=radio][value=false]#user_active_false'
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'collection radio accepts a collection and generate inputs from label method' do
|
15
|
-
form_for @user do |f|
|
15
|
+
concat(form_for @user do |f|
|
16
16
|
concat f.collection_radio :active, [true, false], :to_s, :to_s
|
17
|
-
end
|
17
|
+
end)
|
18
18
|
|
19
19
|
assert_select 'form label.collection_radio[for=user_active_true]', 'true'
|
20
20
|
assert_select 'form label.collection_radio[for=user_active_false]', 'false'
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'collection radio accepts checked item' do
|
24
|
-
form_for @user do |f|
|
24
|
+
concat(form_for @user do |f|
|
25
25
|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, :checked => true
|
26
|
-
end
|
26
|
+
end)
|
27
27
|
|
28
28
|
assert_select 'form input[type=radio][value=true][checked=checked]'
|
29
29
|
assert_no_select 'form input[type=radio][value=false][checked=checked]'
|
@@ -31,9 +31,9 @@ class BuilderTest < ActionView::TestCase
|
|
31
31
|
|
32
32
|
test 'collection radio accepts multiple disabled items' do
|
33
33
|
collection = [[1, true], [0, false], [2, 'other']]
|
34
|
-
form_for @user do |f|
|
34
|
+
concat(form_for @user do |f|
|
35
35
|
concat f.collection_radio :active, collection, :last, :first, :disabled => [true, false]
|
36
|
-
end
|
36
|
+
end)
|
37
37
|
|
38
38
|
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
39
39
|
assert_select 'form input[type=radio][value=false][disabled=disabled]'
|
@@ -42,18 +42,18 @@ class BuilderTest < ActionView::TestCase
|
|
42
42
|
|
43
43
|
test 'collection radio accepts single disable item' do
|
44
44
|
collection = [[1, true], [0, false]]
|
45
|
-
form_for @user do |f|
|
45
|
+
concat(form_for @user do |f|
|
46
46
|
concat f.collection_radio :active, collection, :last, :first, :disabled => true
|
47
|
-
end
|
47
|
+
end)
|
48
48
|
|
49
49
|
assert_select 'form input[type=radio][value=true][disabled=disabled]'
|
50
50
|
assert_no_select 'form input[type=radio][value=false][disabled=disabled]'
|
51
51
|
end
|
52
52
|
|
53
53
|
test 'collection radio accepts html options as input' do
|
54
|
-
form_for @user do |f|
|
54
|
+
concat(form_for @user do |f|
|
55
55
|
concat f.collection_radio :active, [[1, true], [0, false]], :last, :first, {}, :class => 'radio'
|
56
|
-
end
|
56
|
+
end)
|
57
57
|
|
58
58
|
assert_select 'form input[type=radio][value=true].radio#user_active_true'
|
59
59
|
assert_select 'form input[type=radio][value=false].radio#user_active_false'
|
@@ -62,9 +62,9 @@ class BuilderTest < ActionView::TestCase
|
|
62
62
|
# COLLECTION CHECK BOX
|
63
63
|
test 'collection check box accepts a collection and generate a serie of checkboxes for value method' do
|
64
64
|
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
|
65
|
-
form_for @user do |f|
|
65
|
+
concat(form_for @user do |f|
|
66
66
|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
|
67
|
-
end
|
67
|
+
end)
|
68
68
|
|
69
69
|
assert_select "form input[type=hidden][name='user[tag_ids][]'][value=]"
|
70
70
|
assert_select 'form input#user_tag_ids_1[type=checkbox][value=1]'
|
@@ -73,9 +73,9 @@ class BuilderTest < ActionView::TestCase
|
|
73
73
|
|
74
74
|
test 'collection check box accepts a collection and generate a serie of checkboxes with labels for label method' do
|
75
75
|
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
|
76
|
-
form_for @user do |f|
|
76
|
+
concat(form_for @user do |f|
|
77
77
|
concat f.collection_check_boxes :tag_ids, collection, :id, :name
|
78
|
-
end
|
78
|
+
end)
|
79
79
|
|
80
80
|
assert_select 'form label.collection_check_boxes[for=user_tag_ids_1]', 'Tag 1'
|
81
81
|
assert_select 'form label.collection_check_boxes[for=user_tag_ids_2]', 'Tag 2'
|
@@ -83,9 +83,9 @@ class BuilderTest < ActionView::TestCase
|
|
83
83
|
|
84
84
|
test 'collection check box accepts selected values as :checked option' do
|
85
85
|
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
86
|
-
form_for @user do |f|
|
86
|
+
concat(form_for @user do |f|
|
87
87
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => [1, 3]
|
88
|
-
end
|
88
|
+
end)
|
89
89
|
|
90
90
|
assert_select 'form input[type=checkbox][value=1][checked=checked]'
|
91
91
|
assert_select 'form input[type=checkbox][value=3][checked=checked]'
|
@@ -94,9 +94,9 @@ class BuilderTest < ActionView::TestCase
|
|
94
94
|
|
95
95
|
test 'collection check box accepts a single checked value' do
|
96
96
|
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
97
|
-
form_for @user do |f|
|
97
|
+
concat(form_for @user do |f|
|
98
98
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :checked => 3
|
99
|
-
end
|
99
|
+
end)
|
100
100
|
|
101
101
|
assert_select 'form input[type=checkbox][value=3][checked=checked]'
|
102
102
|
assert_no_select 'form input[type=checkbox][value=1][checked=checked]'
|
@@ -105,9 +105,9 @@ class BuilderTest < ActionView::TestCase
|
|
105
105
|
|
106
106
|
test 'collection check box accepts multiple disabled items' do
|
107
107
|
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
108
|
-
form_for @user do |f|
|
108
|
+
concat(form_for @user do |f|
|
109
109
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => [1, 3]
|
110
|
-
end
|
110
|
+
end)
|
111
111
|
|
112
112
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
113
113
|
assert_select 'form input[type=checkbox][value=3][disabled=disabled]'
|
@@ -116,9 +116,9 @@ class BuilderTest < ActionView::TestCase
|
|
116
116
|
|
117
117
|
test 'collection check box accepts single disable item' do
|
118
118
|
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
119
|
-
form_for @user do |f|
|
119
|
+
concat(form_for @user do |f|
|
120
120
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => 1
|
121
|
-
end
|
121
|
+
end)
|
122
122
|
|
123
123
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
124
124
|
assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]'
|
@@ -127,9 +127,9 @@ class BuilderTest < ActionView::TestCase
|
|
127
127
|
|
128
128
|
test 'collection check box accepts a proc to disabled items' do
|
129
129
|
collection = (1..3).map{|i| [i, "Tag #{i}"] }
|
130
|
-
form_for @user do |f|
|
130
|
+
concat(form_for @user do |f|
|
131
131
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 }
|
132
|
-
end
|
132
|
+
end)
|
133
133
|
|
134
134
|
assert_select 'form input[type=checkbox][value=1][disabled=disabled]'
|
135
135
|
assert_no_select 'form input[type=checkbox][value=3][disabled=disabled]'
|
@@ -138,9 +138,9 @@ class BuilderTest < ActionView::TestCase
|
|
138
138
|
|
139
139
|
test 'collection check box accepts html options' do
|
140
140
|
collection = [[1, 'Tag 1'], [2, 'Tag 2']]
|
141
|
-
form_for @user do |f|
|
141
|
+
concat(form_for @user do |f|
|
142
142
|
concat f.collection_check_boxes :tag_ids, collection, :first, :last, {}, :class => 'check'
|
143
|
-
end
|
143
|
+
end)
|
144
144
|
|
145
145
|
assert_select 'form input.check[type=checkbox][value=1]'
|
146
146
|
assert_select 'form input.check[type=checkbox][value=2]'
|
@@ -148,11 +148,11 @@ class BuilderTest < ActionView::TestCase
|
|
148
148
|
|
149
149
|
test 'collection check box with fields for' do
|
150
150
|
collection = [Tag.new(1, 'Tag 1'), Tag.new(2, 'Tag 2')]
|
151
|
-
form_for @user do |f|
|
152
|
-
f.fields_for :post do |p|
|
151
|
+
concat(form_for @user do |f|
|
152
|
+
concat(f.fields_for :post do |p|
|
153
153
|
concat p.collection_check_boxes :tag_ids, collection, :id, :name
|
154
|
-
end
|
155
|
-
end
|
154
|
+
end)
|
155
|
+
end)
|
156
156
|
|
157
157
|
assert_select 'form input#user_post_tag_ids_1[type=checkbox][value=1]'
|
158
158
|
assert_select 'form input#user_post_tag_ids_2[type=checkbox][value=2]'
|
@@ -163,10 +163,10 @@ class BuilderTest < ActionView::TestCase
|
|
163
163
|
|
164
164
|
# SIMPLE FIELDS
|
165
165
|
test 'simple fields for is available and yields an instance of FormBuilder' do
|
166
|
-
form_for @user do |f|
|
167
|
-
f.simple_fields_for :posts do |posts_form|
|
166
|
+
concat(form_for @user do |f|
|
167
|
+
concat(f.simple_fields_for :posts do |posts_form|
|
168
168
|
assert posts_form.instance_of?(SimpleForm::FormBuilder)
|
169
|
-
end
|
170
|
-
end
|
169
|
+
end)
|
170
|
+
end)
|
171
171
|
end
|
172
172
|
end
|
@@ -9,29 +9,29 @@ class FormHelperTest < ActionView::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test 'simple form should add default class to form' do
|
12
|
-
simple_form_for :user do |f| end
|
12
|
+
concat(simple_form_for :user do |f| end)
|
13
13
|
assert_select 'form.simple_form'
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'simple form should add object name as css class to form when object is not present' do
|
17
|
-
simple_form_for :user do |f| end
|
17
|
+
concat(simple_form_for :user do |f| end)
|
18
18
|
assert_select 'form.simple_form.user'
|
19
19
|
end
|
20
20
|
|
21
21
|
test 'simple form should add object class name as css class to form' do
|
22
|
-
simple_form_for @user do |f| end
|
22
|
+
concat(simple_form_for @user do |f| end)
|
23
23
|
assert_select 'form.simple_form.user'
|
24
24
|
end
|
25
25
|
|
26
26
|
test 'pass options to simple form' do
|
27
|
-
simple_form_for :user, :url => '/account', :html => { :id => 'my_form' } do |f| end
|
27
|
+
concat(simple_form_for :user, :url => '/account', :html => { :id => 'my_form' } do |f| end)
|
28
28
|
assert_select 'form#my_form'
|
29
29
|
assert_select 'form[action=/account]'
|
30
30
|
end
|
31
31
|
|
32
32
|
test 'fields for yields an instance of FormBuilder' do
|
33
|
-
simple_fields_for :user do |f|
|
33
|
+
concat(simple_fields_for :user do |f|
|
34
34
|
assert f.instance_of?(SimpleForm::FormBuilder)
|
35
|
-
end
|
35
|
+
end)
|
36
36
|
end
|
37
37
|
end
|
@@ -3,14 +3,14 @@ require 'test_helper'
|
|
3
3
|
class ErrorTest < ActionView::TestCase
|
4
4
|
|
5
5
|
def with_error_for(object, attribute_name, type, options={}, &block)
|
6
|
-
simple_form_for object do |f|
|
6
|
+
concat(simple_form_for object do |f|
|
7
7
|
f.attribute_name = attribute_name
|
8
8
|
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
|
9
9
|
f.input_type = type
|
10
10
|
f.options = options
|
11
11
|
|
12
12
|
concat(SimpleForm::Inputs::Base.new(f).error.to_s)
|
13
|
-
end
|
13
|
+
end)
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'error should not generate content for attribute without errors' do
|
@@ -3,14 +3,14 @@ require 'test_helper'
|
|
3
3
|
class HintTest < ActionView::TestCase
|
4
4
|
|
5
5
|
def with_hint_for(object, attribute_name, type, options={}, &block)
|
6
|
-
simple_form_for object do |f|
|
6
|
+
concat(simple_form_for object do |f|
|
7
7
|
f.attribute_name = attribute_name
|
8
8
|
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
|
9
9
|
f.input_type = type
|
10
10
|
f.options = options
|
11
11
|
|
12
12
|
concat(SimpleForm::Inputs::Base.new(f).hint.to_s)
|
13
|
-
end
|
13
|
+
end)
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'hint should not be generated by default' do
|
@@ -7,14 +7,14 @@ class LabelTest < ActionView::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def with_label_for(object, attribute_name, type, options={})
|
10
|
-
simple_form_for object do |f|
|
10
|
+
concat(simple_form_for object do |f|
|
11
11
|
f.attribute_name = attribute_name
|
12
12
|
f.reflection = Association.new(Company, :company, {}) if options.delete(:setup_association)
|
13
13
|
f.input_type = type
|
14
14
|
f.options = options
|
15
15
|
|
16
16
|
concat(SimpleForm::Inputs::Base.new(f).label)
|
17
|
-
end
|
17
|
+
end)
|
18
18
|
end
|
19
19
|
|
20
20
|
test 'label should generate a default humanized description' do
|
data/test/form_builder_test.rb
CHANGED
@@ -3,39 +3,39 @@ require 'test_helper'
|
|
3
3
|
class FormBuilderTest < ActionView::TestCase
|
4
4
|
|
5
5
|
def with_form_for(object, *args, &block)
|
6
|
-
simple_form_for object do |f|
|
6
|
+
concat(simple_form_for object do |f|
|
7
7
|
concat f.input(*args, &block)
|
8
|
-
end
|
8
|
+
end)
|
9
9
|
end
|
10
10
|
|
11
11
|
def with_button_for(object, *args)
|
12
|
-
simple_form_for object do |f|
|
12
|
+
concat(simple_form_for object do |f|
|
13
13
|
concat f.button(*args)
|
14
|
-
end
|
14
|
+
end)
|
15
15
|
end
|
16
16
|
|
17
17
|
def with_error_for(object, *args)
|
18
|
-
simple_form_for object do |f|
|
18
|
+
concat(simple_form_for object do |f|
|
19
19
|
concat f.error(*args)
|
20
|
-
end
|
20
|
+
end)
|
21
21
|
end
|
22
22
|
|
23
23
|
def with_hint_for(object, *args)
|
24
|
-
simple_form_for object do |f|
|
24
|
+
concat(simple_form_for object do |f|
|
25
25
|
concat f.hint(*args)
|
26
|
-
end
|
26
|
+
end)
|
27
27
|
end
|
28
28
|
|
29
29
|
def with_label_for(object, *args)
|
30
|
-
simple_form_for object do |f|
|
30
|
+
concat(simple_form_for object do |f|
|
31
31
|
concat f.label(*args)
|
32
|
-
end
|
32
|
+
end)
|
33
33
|
end
|
34
34
|
|
35
35
|
def with_association_for(object, *args)
|
36
|
-
simple_form_for object do |f|
|
36
|
+
concat(simple_form_for object do |f|
|
37
37
|
concat f.association(*args)
|
38
|
-
end
|
38
|
+
end)
|
39
39
|
end
|
40
40
|
|
41
41
|
# All
|
@@ -267,9 +267,9 @@ class FormBuilderTest < ActionView::TestCase
|
|
267
267
|
end
|
268
268
|
|
269
269
|
test 'builder allows wrapper tag to be given on demand' do
|
270
|
-
simple_form_for @user do |f|
|
270
|
+
concat(simple_form_for @user do |f|
|
271
271
|
concat f.input :name, :wrapper_tag => :b
|
272
|
-
end
|
272
|
+
end)
|
273
273
|
assert_select 'form b.required.string'
|
274
274
|
end
|
275
275
|
|
@@ -414,14 +414,6 @@ class FormBuilderTest < ActionView::TestCase
|
|
414
414
|
end
|
415
415
|
|
416
416
|
# ASSOCIATIONS - FINDERS
|
417
|
-
test 'builder should allow passing conditions to find collection' do
|
418
|
-
with_association_for @user, :company, :conditions => { :id => 1 }
|
419
|
-
assert_select 'form select.select#user_company_id'
|
420
|
-
assert_select 'form select option[value=1]'
|
421
|
-
assert_no_select 'form select option[value=2]'
|
422
|
-
assert_no_select 'form select option[value=3]'
|
423
|
-
end
|
424
|
-
|
425
417
|
test 'builder should use reflection conditions to find collection' do
|
426
418
|
with_association_for @user, :special_company
|
427
419
|
assert_select 'form select.select#user_special_company_id'
|
@@ -430,30 +422,6 @@ class FormBuilderTest < ActionView::TestCase
|
|
430
422
|
assert_no_select 'form select option[value=3]'
|
431
423
|
end
|
432
424
|
|
433
|
-
test 'builder should allow passing order to find collection' do
|
434
|
-
with_association_for @user, :company, :order => 'name'
|
435
|
-
assert_select 'form select.select#user_company_id'
|
436
|
-
assert_no_select 'form select option[value=1]'
|
437
|
-
assert_no_select 'form select option[value=2]'
|
438
|
-
assert_select 'form select option[value=3]'
|
439
|
-
end
|
440
|
-
|
441
|
-
test 'builder should allow passing include option to find collection' do
|
442
|
-
with_association_for @user, :company, :include => :city
|
443
|
-
assert_select 'form select.select#user_company_id'
|
444
|
-
assert_select 'form select option[value=1]'
|
445
|
-
assert_select 'form select option[value=2]'
|
446
|
-
assert_no_select 'form select option[value=3]'
|
447
|
-
end
|
448
|
-
|
449
|
-
test 'builder should allow passing joins option to find collection' do
|
450
|
-
with_association_for @user, :company, :joins => :city
|
451
|
-
assert_select 'form select.select#user_company_id'
|
452
|
-
assert_select 'form select option[value=2]'
|
453
|
-
assert_select 'form select option[value=3]'
|
454
|
-
assert_no_select 'form select option[value=1]'
|
455
|
-
end
|
456
|
-
|
457
425
|
test 'builder should allow overriding collection to association input' do
|
458
426
|
with_association_for @user, :company, :include_blank => false,
|
459
427
|
:collection => [Company.new(999, 'Teste')]
|
data/test/inputs_test.rb
CHANGED
@@ -7,9 +7,9 @@ class InputTest < ActionView::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def with_input_for(object, attribute_name, type, options={})
|
10
|
-
simple_form_for object do |f|
|
10
|
+
concat(simple_form_for object do |f|
|
11
11
|
concat f.input(attribute_name, options.merge(:as => type))
|
12
|
-
end
|
12
|
+
end)
|
13
13
|
end
|
14
14
|
|
15
15
|
# ALL
|
data/test/test_helper.rb
CHANGED
@@ -3,6 +3,8 @@ require 'test/unit'
|
|
3
3
|
|
4
4
|
require 'active_model'
|
5
5
|
require 'action_controller'
|
6
|
+
require 'action_view'
|
7
|
+
require 'action_view/template'
|
6
8
|
require 'action_view/test_case'
|
7
9
|
|
8
10
|
begin
|
@@ -16,8 +18,14 @@ require 'simple_form'
|
|
16
18
|
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each { |f| require f }
|
17
19
|
I18n.default_locale = :en
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
country_select = "#{File.dirname(__FILE__)}/support/country_select/lib"
|
22
|
+
|
23
|
+
if File.exists?(country_select)
|
24
|
+
$:.unshift country_select
|
25
|
+
require 'country_select'
|
26
|
+
else
|
27
|
+
raise "Could not find country_select plugin in test/support. Please execute git submodule update --init."
|
28
|
+
end
|
21
29
|
|
22
30
|
class SimpleForm::FormBuilder
|
23
31
|
attr_accessor :attribute_name, :column, :reflection, :input_type, :options
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 3
|
9
|
+
version: 1.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Jos\xC3\xA9 Valim"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-03
|
18
|
+
date: 2010-04-03 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|