padrino-helpers 0.13.3.2 → 0.13.3.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.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/test/helper.rb +2 -15
- data/test/test_asset_tag_helpers.rb +89 -94
- data/test/test_form_builder.rb +506 -503
- data/test/test_form_helpers.rb +516 -516
- data/test/test_output_helpers.rb +72 -72
- data/test/test_render_helpers.rb +94 -94
- data/test/test_rendering.rb +2 -2
- data/test/test_tag_helpers.rb +39 -39
- metadata +5 -5
data/test/test_form_builder.rb
CHANGED
@@ -31,33 +31,33 @@ describe "FormBuilder" do
|
|
31
31
|
describe 'for #form_for method' do
|
32
32
|
it 'should display correct form html' do
|
33
33
|
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { "Demo" }
|
34
|
-
|
35
|
-
|
34
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo")
|
35
|
+
assert_html_has_tag(actual_html, 'form input[type=hidden]', :name => '_method', :count => 0) # no method action field
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should display correct form html with fake object' do
|
39
39
|
actual_html = form_for(:markup_user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post')
|
41
|
+
assert_html_has_tag(actual_html, 'form input', :type => 'text', :name => 'markup_user[username]')
|
42
|
+
assert_html_has_tag(actual_html, 'form input[type=hidden]', :name => '_method', :count => 0) # no method action field
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should display correct form html for namespaced object' do
|
46
46
|
actual_html = form_for(Outer::UserAccount.new, '/register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.text_field :username }
|
47
|
-
|
48
|
-
|
47
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post')
|
48
|
+
assert_html_has_tag(actual_html, 'form input', :type => 'text', :name => 'outer_user_account[username]')
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should display form specifying default builder setting' do
|
52
52
|
self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder', :protect_from_csrf => false)).at_least_once
|
53
53
|
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
|
54
|
-
|
55
|
-
|
54
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post')
|
55
|
+
assert_html_has_tag(actual_html, 'span', :content => "bar")
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should display correct form html with remote option' do
|
59
59
|
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true) { "Demo" }
|
60
|
-
|
60
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true')
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should display correct form html with namespace option' do
|
@@ -65,9 +65,9 @@ describe "FormBuilder" do
|
|
65
65
|
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
assert_html_has_no_tag(actual_html, :form, :namespace => 'foo')
|
69
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'foo_user_first_name')
|
70
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name')
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should display correct form html with :as option' do
|
@@ -75,32 +75,32 @@ describe "FormBuilder" do
|
|
75
75
|
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
76
76
|
end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
assert_html_has_no_tag(actual_html, :form, :as => 'customer')
|
79
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'customer[first_name]', :id => 'customer_first_name')
|
80
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name')
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should display correct form html with remote option and method put' do
|
84
84
|
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :remote => true, :method => 'put') { "Demo" }
|
85
|
-
|
86
|
-
|
85
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true')
|
86
|
+
assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should display correct form html with method :put' do
|
90
90
|
actual_html = form_for(@user, '/update', :"accept-charset" => "UTF-8", :method => 'put') { "Demo" }
|
91
|
-
|
92
|
-
|
91
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post')
|
92
|
+
assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'put')
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should display correct form html with method :delete' do
|
96
96
|
actual_html = form_for(@user, '/destroy', :"accept-charset" => "UTF-8", :method => 'delete') { "Demo" }
|
97
|
-
|
98
|
-
|
97
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post')
|
98
|
+
assert_html_has_tag(actual_html, 'form input', :type => 'hidden', :name => "_method", :value => 'delete')
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should display correct form html with multipart' do
|
102
102
|
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => true) { "Demo" }
|
103
|
-
|
103
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should support changing form builder type' do
|
@@ -110,7 +110,7 @@ describe "FormBuilder" do
|
|
110
110
|
|
111
111
|
it 'should support using default standard builder' do
|
112
112
|
actual_html = form_for(@user, '/register') { |f| f.text_field_block(:name) }
|
113
|
-
|
113
|
+
assert_html_has_tag(actual_html, 'form p input[type=text]')
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should display fail for form with nil object' do
|
@@ -118,49 +118,49 @@ describe "FormBuilder" do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should display correct form in haml' do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
get "/haml/form_for"
|
122
|
+
assert_response_has_tag :form, :action => '/demo', :id => 'demo'
|
123
|
+
assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
124
|
+
assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
125
|
+
assert_response_has_tag :input, :name => 'authenticity_token'
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should display correct form in erb' do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
129
|
+
get "/erb/form_for"
|
130
|
+
assert_response_has_tag :form, :action => '/demo', :id => 'demo'
|
131
|
+
assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
132
|
+
assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
133
|
+
assert_response_has_tag :input, :name => 'authenticity_token'
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'should display correct form in slim' do
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
get "/slim/form_for"
|
138
|
+
assert_response_has_tag :form, :action => '/demo', :id => 'demo'
|
139
|
+
assert_response_has_tag :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
140
|
+
assert_response_has_tag :form, :action => '/third_demo', :id => 'demo3', :method => 'get'
|
141
|
+
assert_response_has_tag :input, :name => 'authenticity_token'
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'should have a class of "invalid" for fields with errors' do
|
145
145
|
actual_html = form_for(@user, '/register') {|f| f.text_field(:email) }
|
146
|
-
|
146
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid')
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'should not have a class of "invalid" for fields with no errors' do
|
150
150
|
actual_html = form_for(@user, '/register') {|f| f.text_field(:first_name) }
|
151
|
-
|
151
|
+
assert_html_has_no_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid')
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
describe 'for #fields_for method' do
|
156
156
|
it 'should display correct fields html' do
|
157
157
|
actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
|
158
|
-
|
158
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name')
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'should display correct fields html with symbol object' do
|
162
162
|
actual_html = fields_for(:markup_user) { |f| f.text_field(:first_name) }
|
163
|
-
|
163
|
+
assert_html_has_tag(actual_html, :input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name')
|
164
164
|
end
|
165
165
|
|
166
166
|
it 'should display fail for nil object' do
|
@@ -178,27 +178,27 @@ describe "FormBuilder" do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it 'should display correct simple fields in haml' do
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
181
|
+
get "/haml/fields_for"
|
182
|
+
assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
|
183
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
184
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
185
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'should display correct simple fields in erb' do
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
189
|
+
get "/erb/fields_for"
|
190
|
+
assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
|
191
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
192
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
193
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
194
194
|
end
|
195
195
|
|
196
196
|
it 'should display correct simple fields in slim' do
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
197
|
+
get "/slim/fields_for"
|
198
|
+
assert_response_has_tag :form, :action => '/demo1', :id => 'demo-fields-for'
|
199
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
200
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_edit]', :value => '1', :checked => 'checked'
|
201
|
+
assert_response_has_tag '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -214,50 +214,50 @@ describe "FormBuilder" do
|
|
214
214
|
|
215
215
|
it 'should display correct form html with valid record' do
|
216
216
|
actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
217
|
+
assert_html_has_tag(actual_html, '#field-errors h2', :content => "Demo form cannot be saved")
|
218
|
+
assert_html_has_tag(actual_html, '#field-errors ul li', :content => "B must be valid")
|
219
|
+
assert_html_has_tag(actual_html, '#field-errors ul li', :content => "A must be present")
|
220
|
+
assert_html_has_tag(actual_html, '#field-errors', :style => "foo:bar")
|
221
|
+
assert_html_has_tag(actual_html, '#field-errors', :class => "mine")
|
222
222
|
end
|
223
223
|
|
224
224
|
it 'should display correct form in haml' do
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
225
|
+
get "/haml/form_for"
|
226
|
+
assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
227
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
|
228
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
|
229
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
|
230
|
+
assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
231
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
232
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
|
233
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
234
|
+
assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
235
235
|
end
|
236
236
|
|
237
237
|
it 'should display correct form in erb' do
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
238
|
+
get "/erb/form_for"
|
239
|
+
assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
240
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
|
241
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
|
242
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
|
243
|
+
assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
244
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
245
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
|
246
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
247
|
+
assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
248
248
|
end
|
249
249
|
|
250
250
|
it 'should display correct form in slim' do
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
251
|
+
get "/slim/form_for"
|
252
|
+
assert_response_has_tag '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
253
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Fake must be valid"
|
254
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Second must be present"
|
255
|
+
assert_response_has_tag '#demo div.field-errors ul li', :content => "Third must be a number"
|
256
|
+
assert_response_has_tag '#demo2 div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
257
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Fake must be valid"
|
258
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Second must be present"
|
259
|
+
assert_response_has_tag '#demo2 div.field-errors ul li', :content => "Third must be a number"
|
260
|
+
assert_response_has_tag '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
@@ -269,431 +269,431 @@ describe "FormBuilder" do
|
|
269
269
|
|
270
270
|
it 'should display error for specified invalid object' do
|
271
271
|
actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
|
272
|
-
|
272
|
+
assert_html_has_tag(actual_html, 'span.error', :content => "foo must be present bar")
|
273
273
|
end
|
274
274
|
|
275
275
|
it 'should display error for specified invalid object not matching class name' do
|
276
276
|
@bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
|
277
277
|
actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
|
278
|
-
|
278
|
+
assert_html_has_tag(actual_html, 'span.error', :content => "foo must be bob bar")
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
282
|
describe 'for #label method' do
|
283
283
|
it 'should display correct label html' do
|
284
284
|
actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
|
285
|
-
|
286
|
-
|
285
|
+
assert_html_has_tag(actual_html, 'label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ")
|
286
|
+
assert_html_has_no_tag(actual_html, 'label#user_first_name')
|
287
287
|
end
|
288
288
|
|
289
289
|
it 'should set specific content inside the label if a block was provided' do
|
290
290
|
actual_html = standard_builder.label(:admin, :class => 'large') { input_tag :checkbox }
|
291
|
-
|
292
|
-
|
291
|
+
assert_html_has_tag(actual_html, 'label', :class => 'large', :for => 'user_admin', :content => "Admin: ")
|
292
|
+
assert_html_has_tag(actual_html, 'label input[type=checkbox]')
|
293
293
|
end
|
294
294
|
|
295
295
|
it 'should display correct label in haml' do
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
296
|
+
get "/haml/form_for"
|
297
|
+
assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
|
298
|
+
assert_response_has_tag '#demo label', :content => "About Me: "
|
299
|
+
assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
|
300
300
|
end
|
301
301
|
|
302
302
|
it 'should display correct label in erb' do
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
303
|
+
get "/erb/form_for"
|
304
|
+
assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
|
305
|
+
assert_response_has_tag '#demo label', :content => "About Me: "
|
306
|
+
assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
|
307
307
|
end
|
308
308
|
|
309
309
|
it 'should display correct label in slim' do
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
310
|
+
get "/slim/form_for"
|
311
|
+
assert_response_has_tag '#demo label', :content => "Login: ", :class => 'user-label'
|
312
|
+
assert_response_has_tag '#demo label', :content => "About Me: "
|
313
|
+
assert_response_has_tag '#demo2 label', :content => "Nickname: ", :class => 'label'
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
317
317
|
describe 'for #hidden_field method' do
|
318
318
|
it 'should display correct hidden field html' do
|
319
319
|
actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
|
320
|
-
|
320
|
+
assert_html_has_tag(actual_html, 'input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]')
|
321
321
|
end
|
322
322
|
|
323
323
|
it 'should display correct hidden field in haml' do
|
324
|
-
|
325
|
-
|
326
|
-
|
324
|
+
get "/haml/form_for"
|
325
|
+
assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
326
|
+
assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
327
327
|
end
|
328
328
|
|
329
329
|
it 'should display correct hidden field in erb' do
|
330
|
-
|
331
|
-
|
332
|
-
|
330
|
+
get "/erb/form_for"
|
331
|
+
assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
332
|
+
assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
333
333
|
end
|
334
334
|
|
335
335
|
it 'should display correct hidden field in slim' do
|
336
|
-
|
337
|
-
|
338
|
-
|
336
|
+
get "/slim/form_for"
|
337
|
+
assert_response_has_tag '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
338
|
+
assert_response_has_tag '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
342
|
describe 'for #text_field method' do
|
343
343
|
it 'should display correct text field html' do
|
344
344
|
actual_html = standard_builder.text_field(:first_name, :class => 'large')
|
345
|
-
|
345
|
+
assert_html_has_tag(actual_html, 'input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]')
|
346
346
|
end
|
347
347
|
|
348
348
|
it 'should display correct text field in haml' do
|
349
|
-
|
350
|
-
|
351
|
-
|
349
|
+
get "/haml/form_for"
|
350
|
+
assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
351
|
+
assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
352
352
|
end
|
353
353
|
|
354
354
|
it 'should display correct text field in erb' do
|
355
|
-
|
356
|
-
|
357
|
-
|
355
|
+
get "/erb/form_for"
|
356
|
+
assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
357
|
+
assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
358
358
|
end
|
359
359
|
|
360
360
|
it 'should display correct text field in slim' do
|
361
|
-
|
362
|
-
|
363
|
-
|
361
|
+
get "/slim/form_for"
|
362
|
+
assert_response_has_tag '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
363
|
+
assert_response_has_tag '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
367
367
|
describe 'for #number_field method' do
|
368
368
|
it 'should display correct number field html' do
|
369
369
|
actual_html = standard_builder.number_field(:age, :class => 'numeric')
|
370
|
-
|
370
|
+
assert_html_has_tag(actual_html, 'input.numeric[type=number]', :id => 'user_age', :name => 'user[age]')
|
371
371
|
end
|
372
372
|
|
373
373
|
it 'should display correct number field in haml' do
|
374
|
-
|
375
|
-
|
374
|
+
get "/haml/form_for"
|
375
|
+
assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
376
376
|
end
|
377
377
|
|
378
378
|
it 'should display correct number field in erb' do
|
379
|
-
|
380
|
-
|
379
|
+
get "/erb/form_for"
|
380
|
+
assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
381
381
|
end
|
382
382
|
|
383
383
|
it 'should display correct number field in slim' do
|
384
|
-
|
385
|
-
|
384
|
+
get "/slim/form_for"
|
385
|
+
assert_response_has_tag '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
386
386
|
end
|
387
387
|
end
|
388
388
|
|
389
389
|
describe 'for #telephone_field method' do
|
390
390
|
it 'should display correct telephone field html' do
|
391
391
|
actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
|
392
|
-
|
392
|
+
assert_html_has_tag(actual_html, 'input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]')
|
393
393
|
end
|
394
394
|
|
395
395
|
it 'should display correct telephone field in haml' do
|
396
|
-
|
397
|
-
|
396
|
+
get "/haml/form_for"
|
397
|
+
assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
398
398
|
end
|
399
399
|
|
400
400
|
it 'should display correct telephone field in erb' do
|
401
|
-
|
402
|
-
|
401
|
+
get "/erb/form_for"
|
402
|
+
assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
403
403
|
end
|
404
404
|
|
405
405
|
it 'should display correct telephone field in slim' do
|
406
|
-
|
407
|
-
|
406
|
+
get "/slim/form_for"
|
407
|
+
assert_response_has_tag '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
411
411
|
describe 'for #search_field method' do
|
412
412
|
it 'should display correct search field html' do
|
413
413
|
actual_html = standard_builder.search_field(:search, :class => 'string')
|
414
|
-
|
414
|
+
assert_html_has_tag(actual_html, 'input.string[type=search]', :id => 'user_search', :name => 'user[search]')
|
415
415
|
end
|
416
416
|
|
417
417
|
it 'should display correct search field in haml' do
|
418
|
-
|
419
|
-
|
418
|
+
get "/haml/form_for"
|
419
|
+
assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
|
420
420
|
end
|
421
421
|
|
422
422
|
it 'should display correct search field in erb' do
|
423
|
-
|
424
|
-
|
423
|
+
get "/erb/form_for"
|
424
|
+
assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
|
425
425
|
end
|
426
426
|
|
427
427
|
it 'should display correct search field in slim' do
|
428
|
-
|
429
|
-
|
428
|
+
get "/slim/form_for"
|
429
|
+
assert_response_has_tag '#demo input.string[type=search]', :id => 'markup_user_search'
|
430
430
|
end
|
431
431
|
end
|
432
432
|
|
433
433
|
describe 'for #email_field method' do
|
434
434
|
it 'should display correct email field html' do
|
435
435
|
actual_html = standard_builder.email_field(:email, :class => 'string')
|
436
|
-
|
436
|
+
assert_html_has_tag(actual_html, 'input.string[type=email]', :id => 'user_email', :name => 'user[email]')
|
437
437
|
end
|
438
438
|
|
439
439
|
it 'should display correct email field in haml' do
|
440
|
-
|
441
|
-
|
440
|
+
get "/haml/form_for"
|
441
|
+
assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
|
442
442
|
end
|
443
443
|
|
444
444
|
it 'should display correct email field in erb' do
|
445
|
-
|
446
|
-
|
445
|
+
get "/erb/form_for"
|
446
|
+
assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
|
447
447
|
end
|
448
448
|
|
449
449
|
it 'should display correct email field in slim' do
|
450
|
-
|
451
|
-
|
450
|
+
get "/slim/form_for"
|
451
|
+
assert_response_has_tag '#demo input.string[type=email]', :id => 'markup_user_email'
|
452
452
|
end
|
453
453
|
end
|
454
454
|
|
455
455
|
describe 'for #url_field method' do
|
456
456
|
it 'should display correct url field html' do
|
457
457
|
actual_html = standard_builder.url_field(:webpage, :class => 'string')
|
458
|
-
|
458
|
+
assert_html_has_tag(actual_html, 'input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]')
|
459
459
|
end
|
460
460
|
|
461
461
|
it 'should display correct url field in haml' do
|
462
|
-
|
463
|
-
|
462
|
+
get "/haml/form_for"
|
463
|
+
assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
464
464
|
end
|
465
465
|
|
466
466
|
it 'should display correct url field in erb' do
|
467
|
-
|
468
|
-
|
467
|
+
get "/erb/form_for"
|
468
|
+
assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
469
469
|
end
|
470
470
|
|
471
471
|
it 'should display correct url field in slim' do
|
472
|
-
|
473
|
-
|
472
|
+
get "/slim/form_for"
|
473
|
+
assert_response_has_tag '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
474
474
|
end
|
475
475
|
end
|
476
476
|
|
477
477
|
describe 'for #check_box method' do
|
478
478
|
it 'should display correct checkbox html' do
|
479
479
|
actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
|
480
|
-
|
481
|
-
|
480
|
+
assert_html_has_tag(actual_html, 'input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]')
|
481
|
+
assert_html_has_tag(actual_html, 'input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0')
|
482
482
|
end
|
483
483
|
|
484
484
|
it 'should display correct checkbox html when checked' do
|
485
485
|
actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
|
486
|
-
|
486
|
+
assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]')
|
487
487
|
end
|
488
488
|
|
489
489
|
it 'should display correct checkbox html as checked when object value matches' do
|
490
490
|
@user.stubs(:show_favorites => 'human')
|
491
491
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
492
|
-
|
492
|
+
assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
|
493
493
|
end
|
494
494
|
|
495
495
|
it 'should display correct checkbox html as checked when object value is true' do
|
496
496
|
@user.stubs(:show_favorites => true)
|
497
497
|
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
498
|
-
|
498
|
+
assert_html_has_tag(actual_html, 'input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]')
|
499
499
|
end
|
500
500
|
|
501
501
|
it 'should display correct checkbox html as unchecked when object value does not match' do
|
502
502
|
@user.stubs(:show_favorites => 'alien')
|
503
503
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
504
|
-
|
504
|
+
assert_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
|
505
505
|
end
|
506
506
|
|
507
507
|
it 'should display correct checkbox html as unchecked when object value is false' do
|
508
508
|
@user.stubs(:show_favorites => false)
|
509
509
|
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
510
|
-
|
510
|
+
assert_html_has_no_tag(actual_html, 'input[type=checkbox]', :checked => 'checked')
|
511
511
|
end
|
512
512
|
|
513
513
|
it 'should display correct unchecked hidden field when specified' do
|
514
514
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
|
515
|
-
|
515
|
+
assert_html_has_tag(actual_html, 'input[type=hidden]', :name => 'user[show_favorites]', :value => 'false')
|
516
516
|
end
|
517
517
|
|
518
518
|
it 'should display correct checkbox in haml' do
|
519
|
-
|
520
|
-
|
519
|
+
get "/haml/form_for"
|
520
|
+
assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
521
521
|
end
|
522
522
|
|
523
523
|
it 'should display correct checkbox in erb' do
|
524
|
-
|
525
|
-
|
524
|
+
get "/erb/form_for"
|
525
|
+
assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
526
526
|
end
|
527
527
|
|
528
528
|
it 'should display correct checkbox in slim' do
|
529
|
-
|
530
|
-
|
529
|
+
get "/slim/form_for"
|
530
|
+
assert_response_has_tag '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
531
531
|
end
|
532
532
|
end
|
533
533
|
|
534
534
|
describe 'for #check_box_group and #radio_button_group methods' do
|
535
535
|
it 'should display checkbox group html' do
|
536
536
|
checkboxes = standard_builder.check_box_group(:role, :collection => @user.role_types, :fields => [:name, :id], :selected => [2,3])
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
537
|
+
assert_html_has_tag(checkboxes, 'input[type=checkbox]', :value => '1')
|
538
|
+
assert_html_has_no_tag(checkboxes, 'input[type=checkbox][checked]', :value => '1')
|
539
|
+
assert_html_has_tag(checkboxes, 'input[type=checkbox]', :checked => 'checked', :value => '2')
|
540
|
+
assert_html_has_tag(checkboxes, 'label[for=user_role_3] input[name="user[role][]"][value="3"][checked]')
|
541
541
|
end
|
542
542
|
|
543
543
|
it 'should display checkbox group html and extract selected values from the object' do
|
544
544
|
checkboxes = standard_builder.check_box_group(:roles, :collection => @user.role_types, :fields => [:name, :id])
|
545
|
-
|
546
|
-
|
547
|
-
|
545
|
+
assert_html_has_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="1"][checked]')
|
546
|
+
assert_html_has_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="3"][checked]')
|
547
|
+
assert_html_has_no_tag(checkboxes, 'input[type=checkbox][name="user[roles][]"][value="2"][checked]')
|
548
548
|
end
|
549
549
|
|
550
550
|
it 'should display radio group html' do
|
551
551
|
radios = standard_builder.radio_button_group(:role, :options => %W(red yellow blue), :selected => 'yellow')
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
552
|
+
assert_html_has_tag(radios, 'input[type=radio]', :value => 'red')
|
553
|
+
assert_html_has_no_tag(radios, 'input[type=radio][checked]', :value => 'red')
|
554
|
+
assert_html_has_tag(radios, 'input[type=radio]', :checked => 'checked', :value => 'yellow')
|
555
|
+
assert_html_has_tag(radios, 'label[for=user_role_blue] input[name="user[role]"][value=blue]')
|
556
556
|
end
|
557
557
|
|
558
558
|
it 'should display radio group html and extract selected value from the object' do
|
559
559
|
radios = standard_builder.radio_button_group(:role, :collection => @user.role_types)
|
560
|
-
|
561
|
-
|
560
|
+
assert_html_has_tag(radios, 'input[type=radio][value="1"][checked]')
|
561
|
+
assert_html_has_no_tag(radios, 'input[type=radio][value="2"][checked]')
|
562
562
|
end
|
563
563
|
end
|
564
564
|
|
565
565
|
describe 'for #radio_button method' do
|
566
566
|
it 'should display correct radio button html' do
|
567
567
|
actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
|
568
|
-
|
568
|
+
assert_html_has_tag(actual_html, 'input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male')
|
569
569
|
end
|
570
570
|
|
571
571
|
it 'should display correct radio button html when checked' do
|
572
572
|
actual_html = standard_builder.radio_button(:gender, :checked => true)
|
573
|
-
|
573
|
+
assert_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
|
574
574
|
end
|
575
575
|
|
576
576
|
it 'should display correct radio button html as checked when object value matches' do
|
577
577
|
@user.stubs(:gender => 'male')
|
578
578
|
actual_html = standard_builder.radio_button(:gender, :value => 'male')
|
579
|
-
|
579
|
+
assert_html_has_tag(actual_html, 'input[type=radio]', :checked => 'checked', :name => 'user[gender]')
|
580
580
|
end
|
581
581
|
|
582
582
|
it 'should display correct radio button html as unchecked when object value does not match' do
|
583
583
|
@user.stubs(:gender => 'male')
|
584
584
|
actual_html = standard_builder.radio_button(:gender, :value => 'female')
|
585
|
-
|
585
|
+
assert_html_has_no_tag(actual_html, 'input[type=radio]', :checked => 'checked')
|
586
586
|
end
|
587
587
|
|
588
588
|
it 'should display correct radio button in haml' do
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
589
|
+
get "/haml/form_for"
|
590
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
591
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
592
|
+
assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
593
593
|
end
|
594
594
|
|
595
595
|
it 'should display correct radio button in erb' do
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
596
|
+
get "/erb/form_for"
|
597
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
598
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
599
|
+
assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
600
600
|
end
|
601
601
|
|
602
602
|
it 'should display correct radio button in slim' do
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
603
|
+
get "/slim/form_for"
|
604
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
605
|
+
assert_response_has_tag '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
606
|
+
assert_response_has_tag '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
607
607
|
end
|
608
608
|
end
|
609
609
|
|
610
610
|
describe 'for #text_area method' do
|
611
611
|
it 'should display correct text_area html' do
|
612
612
|
actual_html = standard_builder.text_area(:about, :class => 'large')
|
613
|
-
|
613
|
+
assert_html_has_tag(actual_html, 'textarea.large', :id => 'user_about', :name => 'user[about]')
|
614
614
|
end
|
615
615
|
|
616
616
|
it 'should display correct text_area html and content' do
|
617
617
|
actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
|
618
|
-
|
618
|
+
assert_html_has_tag(actual_html, 'textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6')
|
619
619
|
end
|
620
620
|
|
621
621
|
it 'should display correct text_area in haml' do
|
622
|
-
|
623
|
-
|
624
|
-
|
622
|
+
get "/haml/form_for"
|
623
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
624
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
625
625
|
end
|
626
626
|
|
627
627
|
it 'should display correct text_area in erb' do
|
628
|
-
|
629
|
-
|
630
|
-
|
628
|
+
get "/erb/form_for"
|
629
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
630
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
631
631
|
end
|
632
632
|
|
633
633
|
it 'should display correct text_area in slim' do
|
634
|
-
|
635
|
-
|
636
|
-
|
634
|
+
get "/slim/form_for"
|
635
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
636
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
637
637
|
end
|
638
638
|
end
|
639
639
|
|
640
640
|
describe 'for #password_field method' do
|
641
641
|
it 'should display correct password_field html' do
|
642
642
|
actual_html = standard_builder.password_field(:code, :class => 'large')
|
643
|
-
|
643
|
+
assert_html_has_tag(actual_html, 'input.large[type=password]', :id => 'user_code', :name => 'user[code]')
|
644
644
|
end
|
645
645
|
|
646
646
|
it 'should display correct password_field in haml' do
|
647
|
-
|
648
|
-
|
649
|
-
|
647
|
+
get "/haml/form_for"
|
648
|
+
assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
649
|
+
assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
650
650
|
end
|
651
651
|
|
652
652
|
it 'should display correct password_field in erb' do
|
653
|
-
|
654
|
-
|
655
|
-
|
653
|
+
get "/erb/form_for"
|
654
|
+
assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
655
|
+
assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
656
656
|
end
|
657
657
|
|
658
658
|
it 'should display correct password_field in slim' do
|
659
|
-
|
660
|
-
|
661
|
-
|
659
|
+
get "/slim/form_for"
|
660
|
+
assert_response_has_tag '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
661
|
+
assert_response_has_tag '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
662
662
|
end
|
663
663
|
end
|
664
664
|
|
665
665
|
describe 'for #file_field method' do
|
666
666
|
it 'should display correct file_field html' do
|
667
667
|
actual_html = standard_builder.file_field(:photo, :class => 'large')
|
668
|
-
|
668
|
+
assert_html_has_tag(actual_html, 'input.large[type=file]', :id => 'user_photo', :name => 'user[photo]')
|
669
669
|
end
|
670
670
|
|
671
671
|
it 'should display correct file_field in haml' do
|
672
|
-
|
673
|
-
|
674
|
-
|
672
|
+
get "/haml/form_for"
|
673
|
+
assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
674
|
+
assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
675
675
|
end
|
676
676
|
|
677
677
|
it 'should display correct file_field in erb' do
|
678
|
-
|
679
|
-
|
680
|
-
|
678
|
+
get "/erb/form_for"
|
679
|
+
assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
680
|
+
assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
681
681
|
end
|
682
682
|
|
683
683
|
it 'should display correct file_field in slim' do
|
684
|
-
|
685
|
-
|
686
|
-
|
684
|
+
get "/slim/form_for"
|
685
|
+
assert_response_has_tag '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
686
|
+
assert_response_has_tag '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
687
687
|
end
|
688
688
|
|
689
689
|
it 'should display correct form html with multipart, even if no multipart option is specified' do
|
690
690
|
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8") { |f| f.file_field :photo }
|
691
|
-
|
691
|
+
assert_html_has_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
|
692
692
|
end
|
693
693
|
|
694
694
|
it 'should display correct form html without multipart, if multipart option is specified false' do
|
695
695
|
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => false) { |f| f.file_field :photo }
|
696
|
-
|
696
|
+
assert_html_has_no_tag(actual_html, 'form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data")
|
697
697
|
end
|
698
698
|
|
699
699
|
end
|
@@ -701,28 +701,28 @@ describe "FormBuilder" do
|
|
701
701
|
describe 'for #select method' do
|
702
702
|
it 'should display correct select html' do
|
703
703
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
704
|
+
assert_html_has_tag(actual_html, 'select.selecty', :id => 'user_state', :name => 'user[state]')
|
705
|
+
assert_html_has_tag(actual_html, 'select.selecty option', :count => 3)
|
706
|
+
assert_html_has_tag(actual_html, 'select.selecty option', :value => 'California', :content => 'California')
|
707
|
+
assert_html_has_tag(actual_html, 'select.selecty option', :value => 'Texas', :content => 'Texas')
|
708
|
+
assert_html_has_tag(actual_html, 'select.selecty option', :value => 'Wyoming', :content => 'Wyoming')
|
709
709
|
end
|
710
710
|
|
711
711
|
it 'should display correct select html with selected item if it matches value' do
|
712
712
|
@user.stubs(:state => 'California')
|
713
713
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
|
714
|
-
|
715
|
-
|
716
|
-
|
714
|
+
assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
|
715
|
+
assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
|
716
|
+
assert_html_has_tag(actual_html, 'select option', :value => 'California', :selected => 'selected')
|
717
717
|
end
|
718
718
|
|
719
719
|
it 'should display correct select html with selected item if it matches full value' do
|
720
720
|
@user.stubs(:state => 'Cali')
|
721
721
|
actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
722
|
+
assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
|
723
|
+
assert_html_has_tag(actual_html, 'select option', :selected => 'selected', :count => 1)
|
724
|
+
assert_html_has_tag(actual_html, 'select option', :value => 'Cali', :selected => 'selected')
|
725
|
+
assert_html_has_tag(actual_html, 'select option', :value => 'California')
|
726
726
|
end
|
727
727
|
|
728
728
|
it 'should display correct select html with multiple selected items' do
|
@@ -730,92 +730,95 @@ describe "FormBuilder" do
|
|
730
730
|
actual_html = standard_builder.select(
|
731
731
|
:pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
|
732
732
|
)
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
733
|
+
assert_html_has_tag(actual_html, 'option', :value => 'foo', :content => 'Foo', :selected => 'selected')
|
734
|
+
assert_html_has_tag(actual_html, 'option', :value => 'bar', :content => 'Bar', :selected => 'selected')
|
735
|
+
assert_html_has_tag(actual_html, 'option', :value => 'baz', :content => 'Baz')
|
736
|
+
assert_html_has_tag(actual_html, 'option', :value => 'bar buz', :content => 'Bar Buz')
|
737
737
|
end
|
738
738
|
|
739
|
-
it 'should display correct select html with include_blank' do
|
739
|
+
it 'should display correct select html with include_blank true' do
|
740
740
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
741
|
+
assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
|
742
|
+
assert_html_has_tag(actual_html, 'select option', :count => 4)
|
743
|
+
assert_html_has_tag(actual_html, 'select option:first-child', :content => '')
|
744
|
+
assert_html_has_tag(actual_html, 'select option:first-child', :value => '')
|
745
|
+
end
|
746
|
+
|
747
|
+
it 'should display correct select html with include_blank string' do
|
745
748
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => 'Select')
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
749
|
+
assert_html_has_tag(actual_html, 'select', :id => 'user_state', :name => 'user[state]')
|
750
|
+
assert_html_has_tag(actual_html, 'select option', :count => 4)
|
751
|
+
assert_html_has_tag(actual_html, 'select option:first-child', :content => 'Select')
|
752
|
+
assert_html_has_tag(actual_html, 'select option:first-child', :value => '')
|
750
753
|
end
|
751
754
|
|
752
755
|
it 'should display correct select html with collection passed in' do
|
753
756
|
actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
757
|
+
assert_html_has_tag(actual_html, 'select', :id => 'user_role', :name => 'user[role]')
|
758
|
+
assert_html_has_tag(actual_html, 'select option', :count => 3)
|
759
|
+
assert_html_has_tag(actual_html, 'select option', :value => '1', :content => 'Admin', :selected => 'selected')
|
760
|
+
assert_html_has_tag(actual_html, 'select option', :value => '2', :content => 'Moderate')
|
761
|
+
assert_html_has_tag(actual_html, 'select option', :value => '3', :content => 'Limited')
|
759
762
|
end
|
760
763
|
|
761
764
|
it 'should display correct select in haml' do
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
+
get "/haml/form_for"
|
766
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
767
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
765
768
|
end
|
766
769
|
|
767
770
|
it 'should display correct select in erb' do
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
+
get "/erb/form_for"
|
772
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
773
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
771
774
|
end
|
772
775
|
|
773
776
|
it 'should display correct select in slim' do
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
+
get "/slim/form_for"
|
778
|
+
assert_response_has_tag '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
779
|
+
assert_response_has_tag '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
777
780
|
end
|
778
781
|
end
|
779
782
|
|
780
783
|
describe 'for #submit method' do
|
781
784
|
it 'should display correct submit button html with no options' do
|
782
785
|
actual_html = standard_builder.submit
|
783
|
-
|
786
|
+
assert_html_has_tag(actual_html, 'input[type=submit]', :value => "Submit")
|
784
787
|
end
|
785
788
|
|
786
789
|
|
787
790
|
it 'should display correct submit button html with no caption' do
|
788
791
|
actual_html = standard_builder.submit(:class => 'btn')
|
789
|
-
|
792
|
+
assert_html_has_tag(actual_html, 'input.btn[type=submit]', :value => "Submit")
|
790
793
|
end
|
791
794
|
|
792
795
|
it 'should display correct submit button html with nil caption' do
|
793
796
|
actual_html = standard_builder.submit(nil, :class => 'btn')
|
794
|
-
|
797
|
+
assert_html_has_tag(actual_html, 'input.btn[type=submit]')
|
795
798
|
assert actual_html !~ %r{ value \* = }x
|
796
799
|
end
|
797
800
|
|
798
801
|
it 'should display correct submit button html' do
|
799
802
|
actual_html = standard_builder.submit("Commit", :class => 'large')
|
800
|
-
|
803
|
+
assert_html_has_tag(actual_html, 'input.large[type=submit]', :value => "Commit")
|
801
804
|
end
|
802
805
|
|
803
806
|
it 'should display correct submit button in haml' do
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
+
get "/haml/form_for"
|
808
|
+
assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
809
|
+
assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
807
810
|
end
|
808
811
|
|
809
812
|
it 'should display correct submit button in erb' do
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
+
get "/erb/form_for"
|
814
|
+
assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
815
|
+
assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
813
816
|
end
|
814
817
|
|
815
818
|
it 'should display correct submit button in slim' do
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
+
get "/slim/form_for"
|
820
|
+
assert_response_has_tag '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
821
|
+
assert_response_has_tag '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
819
822
|
end
|
820
823
|
end
|
821
824
|
|
@@ -826,30 +829,30 @@ describe "FormBuilder" do
|
|
826
829
|
|
827
830
|
it 'should display correct image submit button html with no options' do
|
828
831
|
actual_html = standard_builder.image_submit('buttons/ok.png')
|
829
|
-
|
832
|
+
assert_html_has_tag(actual_html, 'input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
|
830
833
|
end
|
831
834
|
|
832
835
|
it 'should display correct image submit button html' do
|
833
836
|
actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
|
834
|
-
|
837
|
+
assert_html_has_tag(actual_html, 'input.large[type=image]', :src => "/system/ok.png")
|
835
838
|
end
|
836
839
|
|
837
840
|
it 'should display correct image submit button in haml' do
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
+
get "/haml/form_for"
|
842
|
+
assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
843
|
+
assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
841
844
|
end
|
842
845
|
|
843
846
|
it 'should display correct image submit button in erb' do
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
+
get "/erb/form_for"
|
848
|
+
assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
849
|
+
assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
847
850
|
end
|
848
851
|
|
849
852
|
it 'should display correct image submit button in slim' do
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
+
get "/slim/form_for"
|
854
|
+
assert_response_has_tag '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
855
|
+
assert_response_has_tag '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
853
856
|
end
|
854
857
|
end
|
855
858
|
|
@@ -870,10 +873,10 @@ describe "FormBuilder" do
|
|
870
873
|
child_form.text_field(:number) +
|
871
874
|
child_form.check_box('_destroy')
|
872
875
|
end
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
876
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_telephone_attributes_number')
|
877
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_telephone_attributes_number', :name => 'user[telephone_attributes][number]', :value => "4568769876")
|
878
|
+
assert_html_has_tag(actual_html, 'input', :type => 'hidden', :name => 'user[telephone_attributes][_destroy]', :value => '0')
|
879
|
+
assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1')
|
877
880
|
end
|
878
881
|
|
879
882
|
it 'should display nested children fields one-to-many within form' do
|
@@ -883,15 +886,15 @@ describe "FormBuilder" do
|
|
883
886
|
html << child_form.text_field(:name)
|
884
887
|
end
|
885
888
|
# Address 1 (Saved)
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
889
|
+
assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20')
|
890
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
|
891
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]')
|
892
|
+
assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]')
|
890
893
|
# Address 2 (New)
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
894
|
+
assert_html_has_no_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_1_id')
|
895
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_name', :content => 'Name')
|
896
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_name', :name => 'user[addresses_attributes][1][name]')
|
897
|
+
assert_html_has_no_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy')
|
895
898
|
end
|
896
899
|
|
897
900
|
it 'should display fields for explicit instance object' do
|
@@ -901,10 +904,10 @@ describe "FormBuilder" do
|
|
901
904
|
html << child_form.text_field(:name)
|
902
905
|
html << child_form.check_box('_destroy')
|
903
906
|
end
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
907
|
+
assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '40')
|
908
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
|
909
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Page")
|
910
|
+
assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1')
|
908
911
|
end
|
909
912
|
|
910
913
|
it 'should display fields for collection object' do
|
@@ -915,15 +918,15 @@ describe "FormBuilder" do
|
|
915
918
|
child_form.check_box('_destroy')
|
916
919
|
end
|
917
920
|
# Address 1
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
921
|
+
assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_0_id', :name => "user[addresses_attributes][0][id]", :value => '20')
|
922
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_0_name', :content => 'Name')
|
923
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_0_name', :name => 'user[addresses_attributes][0][name]', :value => "Foo")
|
924
|
+
assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]')
|
922
925
|
# Address 3
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
926
|
+
assert_html_has_tag(actual_html, 'input', :type => 'hidden', :id => 'user_addresses_attributes_2_id', :value => '50')
|
927
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_2_name', :content => 'Name')
|
928
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_2_name', :name => 'user[addresses_attributes][2][name]', :value => "Walter")
|
929
|
+
assert_html_has_tag(actual_html, 'input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy')
|
927
930
|
end
|
928
931
|
|
929
932
|
it 'should display fields for arbitrarily deep nested forms' do
|
@@ -934,8 +937,8 @@ describe "FormBuilder" do
|
|
934
937
|
second_child_form.check_box('_destroy')
|
935
938
|
end
|
936
939
|
end
|
937
|
-
|
938
|
-
|
940
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_businesses_attributes_0_name', :content => 'Name')
|
941
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]')
|
939
942
|
end
|
940
943
|
|
941
944
|
it 'should display fields for nested forms with custom indices' do
|
@@ -951,59 +954,59 @@ describe "FormBuilder" do
|
|
951
954
|
html
|
952
955
|
end
|
953
956
|
|
954
|
-
|
955
|
-
|
957
|
+
assert_html_has_tag(actual_html, 'label', :for => 'user_addresses_attributes_1_businesses_attributes_a_name', :content => 'Name')
|
958
|
+
assert_html_has_tag(actual_html, 'input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]')
|
956
959
|
end
|
957
960
|
|
958
961
|
it 'should display nested children fields in erb' do
|
959
|
-
|
962
|
+
get "/erb/fields_for"
|
960
963
|
# Telephone
|
961
|
-
|
962
|
-
|
964
|
+
assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
|
965
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
963
966
|
# Address 1 (Saved)
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
967
|
+
assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
968
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
969
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
970
|
+
assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
968
971
|
# Address 2 (New)
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
972
|
+
assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
973
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
974
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
975
|
+
assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
973
976
|
end
|
974
977
|
|
975
978
|
it 'should display nested children fields in haml' do
|
976
|
-
|
979
|
+
get "/haml/fields_for"
|
977
980
|
# Telephone
|
978
|
-
|
979
|
-
|
981
|
+
assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
|
982
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
980
983
|
# Address 1 (Saved)
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
984
|
+
assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
985
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
986
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
987
|
+
assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
985
988
|
# Address 2 (New)
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
989
|
+
assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
990
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
991
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
992
|
+
assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
990
993
|
end
|
991
994
|
|
992
995
|
it 'should display nested children fields in slim' do
|
993
|
-
|
996
|
+
get "/slim/fields_for"
|
994
997
|
# Telephone
|
995
|
-
|
996
|
-
|
998
|
+
assert_response_has_tag('label', :for => 'markup_user_telephone_attributes_number')
|
999
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_telephone_attributes_number', :name => 'markup_user[telephone_attributes][number]', :value => "62634576545")
|
997
1000
|
# Address 1 (Saved)
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1001
|
+
assert_response_has_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_0_id', :name => "markup_user[addresses_attributes][0][id]", :value => '25')
|
1002
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_0_name', :content => 'Name')
|
1003
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_0_name', :name => 'markup_user[addresses_attributes][0][name]')
|
1004
|
+
assert_response_has_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_0__destroy', :name => 'markup_user[addresses_attributes][0][_destroy]')
|
1002
1005
|
# Address 2 (New)
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1006
|
+
assert_response_has_no_tag('input', :type => 'hidden', :id => 'markup_user_addresses_attributes_1_id')
|
1007
|
+
assert_response_has_tag('label', :for => 'markup_user_addresses_attributes_1_name', :content => 'Name')
|
1008
|
+
assert_response_has_tag('input', :type => 'text', :id => 'markup_user_addresses_attributes_1_name', :name => 'markup_user[addresses_attributes][1][name]')
|
1009
|
+
assert_response_has_no_tag('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
1007
1010
|
end
|
1008
1011
|
end
|
1009
1012
|
|
@@ -1014,182 +1017,182 @@ describe "FormBuilder" do
|
|
1014
1017
|
describe 'for #text_field_block method' do
|
1015
1018
|
it 'should display correct text field block html' do
|
1016
1019
|
actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
|
1017
|
-
|
1018
|
-
|
1020
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_first_name', :content => "FName")
|
1021
|
+
assert_html_has_tag(actual_html, 'p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]')
|
1019
1022
|
end
|
1020
1023
|
|
1021
1024
|
it 'should display correct text field block in haml' do
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
+
get "/haml/form_for"
|
1026
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1027
|
+
assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1025
1028
|
end
|
1026
1029
|
|
1027
1030
|
it 'should display correct text field block in erb' do
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
+
get "/erb/form_for"
|
1032
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1033
|
+
assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1031
1034
|
end
|
1032
1035
|
|
1033
1036
|
it 'should display correct text field block in slim' do
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
+
get "/slim/form_for"
|
1038
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1039
|
+
assert_response_has_tag '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1037
1040
|
end
|
1038
1041
|
end
|
1039
1042
|
|
1040
1043
|
describe 'for #text_area_block method' do
|
1041
1044
|
it 'should display correct text area block html' do
|
1042
1045
|
actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
|
1043
|
-
|
1044
|
-
|
1046
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_about', :content => "About Me")
|
1047
|
+
assert_html_has_tag(actual_html, 'p textarea', :id => 'user_about', :name => 'user[about]')
|
1045
1048
|
end
|
1046
1049
|
|
1047
1050
|
it 'should display correct text area block in haml' do
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
+
get "/haml/form_for"
|
1052
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1053
|
+
assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1051
1054
|
end
|
1052
1055
|
|
1053
1056
|
it 'should display correct text area block in erb' do
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
+
get "/erb/form_for"
|
1058
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1059
|
+
assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1057
1060
|
end
|
1058
1061
|
|
1059
1062
|
it 'should display correct text area block in slim' do
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
+
get "/slim/form_for"
|
1064
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1065
|
+
assert_response_has_tag '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1063
1066
|
end
|
1064
1067
|
end
|
1065
1068
|
|
1066
1069
|
describe 'for #password_field_block method' do
|
1067
1070
|
it 'should display correct password field block html' do
|
1068
1071
|
actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
|
1069
|
-
|
1070
|
-
|
1072
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_keycode', :content => "Code: ")
|
1073
|
+
assert_html_has_tag(actual_html, 'p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]')
|
1071
1074
|
end
|
1072
1075
|
|
1073
1076
|
it 'should display correct password field block in haml' do
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
+
get "/haml/form_for"
|
1078
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1079
|
+
assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1077
1080
|
end
|
1078
1081
|
|
1079
1082
|
it 'should display correct password field block in erb' do
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
+
get "/erb/form_for"
|
1084
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1085
|
+
assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1083
1086
|
end
|
1084
1087
|
|
1085
1088
|
it 'should display correct password field block in slim' do
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
+
get "/slim/form_for"
|
1090
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1091
|
+
assert_response_has_tag '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1089
1092
|
end
|
1090
1093
|
end
|
1091
1094
|
|
1092
1095
|
describe 'for #file_field_block method' do
|
1093
1096
|
it 'should display correct file field block html' do
|
1094
1097
|
actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
|
1095
|
-
|
1096
|
-
|
1098
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_photo', :content => "Photo: ")
|
1099
|
+
assert_html_has_tag(actual_html, 'p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]')
|
1097
1100
|
end
|
1098
1101
|
|
1099
1102
|
it 'should display correct file field block in haml' do
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
+
get "/haml/form_for"
|
1104
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1105
|
+
assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1103
1106
|
end
|
1104
1107
|
|
1105
1108
|
it 'should display correct file field block in erb' do
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
+
get "/erb/form_for"
|
1110
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1111
|
+
assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1109
1112
|
end
|
1110
1113
|
|
1111
1114
|
it 'should display correct file field block in slim' do
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
+
get "/slim/form_for"
|
1116
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1117
|
+
assert_response_has_tag '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1115
1118
|
end
|
1116
1119
|
end
|
1117
1120
|
|
1118
1121
|
describe 'for #check_box_block method' do
|
1119
1122
|
it 'should display correct check box block html' do
|
1120
1123
|
actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
|
1121
|
-
|
1122
|
-
|
1124
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_remember_me', :content => "Remember session?")
|
1125
|
+
assert_html_has_tag(actual_html, 'p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]')
|
1123
1126
|
end
|
1124
1127
|
|
1125
1128
|
it 'should display correct check box block in haml' do
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
+
get "/haml/form_for"
|
1130
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1131
|
+
assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1129
1132
|
end
|
1130
1133
|
|
1131
1134
|
it 'should display correct check box block in erb' do
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
+
get "/erb/form_for"
|
1136
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1137
|
+
assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1135
1138
|
end
|
1136
1139
|
|
1137
1140
|
it 'should display correct check box block in slim' do
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
+
get "/slim/form_for"
|
1142
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1143
|
+
assert_response_has_tag '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1141
1144
|
end
|
1142
1145
|
end
|
1143
1146
|
|
1144
1147
|
describe 'for #select_block method' do
|
1145
1148
|
it 'should display correct select_block block html' do
|
1146
1149
|
actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1150
|
+
assert_html_has_tag(actual_html, 'p label', :for => 'user_country', :content => "Your country")
|
1151
|
+
assert_html_has_tag(actual_html, 'p select', :id => 'user_country', :name => 'user[country]')
|
1152
|
+
assert_html_has_tag(actual_html, 'p select option', :content => 'USA')
|
1153
|
+
assert_html_has_tag(actual_html, 'p select option', :content => 'Canada')
|
1151
1154
|
end
|
1152
1155
|
|
1153
1156
|
it 'should display correct select_block block in haml' do
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1157
|
+
get "/haml/form_for"
|
1158
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1159
|
+
assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1160
|
+
assert_response_has_tag '#demo2 p select option', :content => 'California'
|
1161
|
+
assert_response_has_tag '#demo2 p select option', :content => 'Texas'
|
1159
1162
|
end
|
1160
1163
|
|
1161
1164
|
it 'should display correct select_block block in erb' do
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
+
get "/erb/form_for"
|
1166
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1167
|
+
assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1165
1168
|
end
|
1166
1169
|
|
1167
1170
|
it 'should display correct select_block block in slim' do
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
+
get "/slim/form_for"
|
1172
|
+
assert_response_has_tag '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1173
|
+
assert_response_has_tag '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1171
1174
|
end
|
1172
1175
|
end
|
1173
1176
|
|
1174
1177
|
describe 'for #submit_block method' do
|
1175
1178
|
it 'should display correct submit block html' do
|
1176
1179
|
actual_html = standard_builder.submit_block("Update", :class => 'large')
|
1177
|
-
|
1180
|
+
assert_html_has_tag(actual_html, 'p input.large[type=submit]', :value => 'Update')
|
1178
1181
|
end
|
1179
1182
|
|
1180
1183
|
it 'should display correct submit block in haml' do
|
1181
|
-
|
1182
|
-
|
1184
|
+
get "/haml/form_for"
|
1185
|
+
assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
|
1183
1186
|
end
|
1184
1187
|
|
1185
1188
|
it 'should display correct submit block in erb' do
|
1186
|
-
|
1187
|
-
|
1189
|
+
get "/erb/form_for"
|
1190
|
+
assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
|
1188
1191
|
end
|
1189
1192
|
|
1190
1193
|
it 'should display correct submit block in slim' do
|
1191
|
-
|
1192
|
-
|
1194
|
+
get "/slim/form_for"
|
1195
|
+
assert_response_has_tag '#demo2 p input', :type => 'submit', :class => 'button'
|
1193
1196
|
end
|
1194
1197
|
end
|
1195
1198
|
|
@@ -1200,24 +1203,24 @@ describe "FormBuilder" do
|
|
1200
1203
|
|
1201
1204
|
it 'should display correct image submit block html' do
|
1202
1205
|
actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
|
1203
|
-
|
1206
|
+
assert_html_has_tag(actual_html, 'p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}")
|
1204
1207
|
end
|
1205
1208
|
|
1206
1209
|
it 'should display correct image submit block in haml' do
|
1207
|
-
|
1208
|
-
|
1210
|
+
get "/haml/form_for"
|
1211
|
+
assert_response_has_tag '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1209
1212
|
end
|
1210
1213
|
|
1211
1214
|
it 'should display correct image submit block in slim' do
|
1212
|
-
|
1213
|
-
|
1215
|
+
get "/slim/form_for"
|
1216
|
+
assert_response_has_tag '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1214
1217
|
end
|
1215
1218
|
end
|
1216
1219
|
|
1217
1220
|
describe 'for #datetime_field method' do
|
1218
1221
|
it 'should display correct datetime field html' do
|
1219
1222
|
actual_html = standard_builder.datetime_field(:datetime)
|
1220
|
-
|
1223
|
+
assert_html_has_tag(actual_html, 'input[type=datetime]', :id => 'user_datetime', :name => 'user[datetime]')
|
1221
1224
|
end
|
1222
1225
|
|
1223
1226
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1231,29 +1234,29 @@ describe "FormBuilder" do
|
|
1231
1234
|
:min => "1993-02-24T12:30:45.000+0000",
|
1232
1235
|
:value => "2000-04-01T12:00:00.000+0000"
|
1233
1236
|
}
|
1234
|
-
|
1237
|
+
assert_html_has_tag(actual_html, 'input[type=datetime]', expected)
|
1235
1238
|
end
|
1236
1239
|
|
1237
1240
|
it 'should display correct datetime field in haml' do
|
1238
|
-
|
1239
|
-
|
1241
|
+
get "/haml/form_for"
|
1242
|
+
assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
|
1240
1243
|
end
|
1241
1244
|
|
1242
1245
|
it 'should display correct datetime field in erb' do
|
1243
|
-
|
1244
|
-
|
1246
|
+
get "/erb/form_for"
|
1247
|
+
assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
|
1245
1248
|
end
|
1246
1249
|
|
1247
1250
|
it 'should display correct datetime field in slim' do
|
1248
|
-
|
1249
|
-
|
1251
|
+
get "/slim/form_for"
|
1252
|
+
assert_response_has_tag '#demo input[type=datetime]', :id => 'markup_user_datetime', :max => "2000-04-01T12:00:00.000+0000"
|
1250
1253
|
end
|
1251
1254
|
end
|
1252
1255
|
|
1253
1256
|
describe 'for #datetime_local_field method' do
|
1254
1257
|
it 'should display correct datetime-local field html' do
|
1255
1258
|
actual_html = standard_builder.datetime_local_field(:datetime_local)
|
1256
|
-
|
1259
|
+
assert_html_has_tag(actual_html, 'input[type=datetime-local]', :id => 'user_datetime_local', :name => 'user[datetime_local]')
|
1257
1260
|
end
|
1258
1261
|
|
1259
1262
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1267,29 +1270,29 @@ describe "FormBuilder" do
|
|
1267
1270
|
:min => "1993-02-24T12:30:45",
|
1268
1271
|
:value => "2000-04-01T12:00:00"
|
1269
1272
|
}
|
1270
|
-
|
1273
|
+
assert_html_has_tag(actual_html, 'input[type=datetime-local]', expected)
|
1271
1274
|
end
|
1272
1275
|
|
1273
1276
|
it 'should display correct datetime-local field in haml' do
|
1274
|
-
|
1275
|
-
|
1277
|
+
get "/haml/form_for"
|
1278
|
+
assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
|
1276
1279
|
end
|
1277
1280
|
|
1278
1281
|
it 'should display correct datetime-local field in erb' do
|
1279
|
-
|
1280
|
-
|
1282
|
+
get "/erb/form_for"
|
1283
|
+
assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
|
1281
1284
|
end
|
1282
1285
|
|
1283
1286
|
it 'should display correct datetime-local field in slim' do
|
1284
|
-
|
1285
|
-
|
1287
|
+
get "/slim/form_for"
|
1288
|
+
assert_response_has_tag '#demo input[type=datetime-local]', :id => 'markup_user_datetime_local'
|
1286
1289
|
end
|
1287
1290
|
end
|
1288
1291
|
|
1289
1292
|
describe 'for #date_field method' do
|
1290
1293
|
it 'should display correct date field html' do
|
1291
1294
|
actual_html = standard_builder.date_field(:date)
|
1292
|
-
|
1295
|
+
assert_html_has_tag(actual_html, 'input[type=date]', :id => 'user_date', :name => 'user[date]')
|
1293
1296
|
end
|
1294
1297
|
|
1295
1298
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1303,29 +1306,29 @@ describe "FormBuilder" do
|
|
1303
1306
|
:min => "1993-02-24",
|
1304
1307
|
:value => "2000-04-01"
|
1305
1308
|
}
|
1306
|
-
|
1309
|
+
assert_html_has_tag(actual_html, 'input[type=date]', expected)
|
1307
1310
|
end
|
1308
1311
|
|
1309
1312
|
it 'should display correct date field in haml' do
|
1310
|
-
|
1311
|
-
|
1313
|
+
get "/haml/form_for"
|
1314
|
+
assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
|
1312
1315
|
end
|
1313
1316
|
|
1314
1317
|
it 'should display correct date field in erb' do
|
1315
|
-
|
1316
|
-
|
1318
|
+
get "/erb/form_for"
|
1319
|
+
assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
|
1317
1320
|
end
|
1318
1321
|
|
1319
1322
|
it 'should display correct date field in slim' do
|
1320
|
-
|
1321
|
-
|
1323
|
+
get "/slim/form_for"
|
1324
|
+
assert_response_has_tag '#demo input[type=date]', :id => 'markup_user_date'
|
1322
1325
|
end
|
1323
1326
|
end
|
1324
1327
|
|
1325
1328
|
describe 'for #month_field method' do
|
1326
1329
|
it 'should display correct month field html' do
|
1327
1330
|
actual_html = standard_builder.month_field(:month)
|
1328
|
-
|
1331
|
+
assert_html_has_tag(actual_html, 'input[type=month]', :id => 'user_month', :name => 'user[month]')
|
1329
1332
|
end
|
1330
1333
|
|
1331
1334
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1339,29 +1342,29 @@ describe "FormBuilder" do
|
|
1339
1342
|
:min => "1993-02",
|
1340
1343
|
:value => "2000-04"
|
1341
1344
|
}
|
1342
|
-
|
1345
|
+
assert_html_has_tag(actual_html, 'input[type=month]', expected)
|
1343
1346
|
end
|
1344
1347
|
|
1345
1348
|
it 'should display correct month field in haml' do
|
1346
|
-
|
1347
|
-
|
1349
|
+
get "/haml/form_for"
|
1350
|
+
assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
|
1348
1351
|
end
|
1349
1352
|
|
1350
1353
|
it 'should display correct month field in erb' do
|
1351
|
-
|
1352
|
-
|
1354
|
+
get "/erb/form_for"
|
1355
|
+
assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
|
1353
1356
|
end
|
1354
1357
|
|
1355
1358
|
it 'should display correct month field in slim' do
|
1356
|
-
|
1357
|
-
|
1359
|
+
get "/slim/form_for"
|
1360
|
+
assert_response_has_tag '#demo input[type=month]', :id => 'markup_user_month'
|
1358
1361
|
end
|
1359
1362
|
end
|
1360
1363
|
|
1361
1364
|
describe 'for #week_field method' do
|
1362
1365
|
it 'should display correct week field html' do
|
1363
1366
|
actual_html = standard_builder.week_field(:week)
|
1364
|
-
|
1367
|
+
assert_html_has_tag(actual_html, 'input[type=week]', :id => 'user_week', :name => 'user[week]')
|
1365
1368
|
end
|
1366
1369
|
|
1367
1370
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1375,29 +1378,29 @@ describe "FormBuilder" do
|
|
1375
1378
|
:min => "1993-W08",
|
1376
1379
|
:value => "2000-W13"
|
1377
1380
|
}
|
1378
|
-
|
1381
|
+
assert_html_has_tag(actual_html, 'input[type=week]', expected)
|
1379
1382
|
end
|
1380
1383
|
|
1381
1384
|
it 'should display correct week field in haml' do
|
1382
|
-
|
1383
|
-
|
1385
|
+
get "/haml/form_for"
|
1386
|
+
assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
|
1384
1387
|
end
|
1385
1388
|
|
1386
1389
|
it 'should display correct week field in erb' do
|
1387
|
-
|
1388
|
-
|
1390
|
+
get "/erb/form_for"
|
1391
|
+
assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
|
1389
1392
|
end
|
1390
1393
|
|
1391
1394
|
it 'should display correct week field in slim' do
|
1392
|
-
|
1393
|
-
|
1395
|
+
get "/slim/form_for"
|
1396
|
+
assert_response_has_tag '#demo input[type=week]', :id => 'markup_user_week'
|
1394
1397
|
end
|
1395
1398
|
end
|
1396
1399
|
|
1397
1400
|
describe 'for #time_field method' do
|
1398
1401
|
it 'should display correct time field html' do
|
1399
1402
|
actual_html = standard_builder.time_field(:time)
|
1400
|
-
|
1403
|
+
assert_html_has_tag(actual_html, 'input[type=time]', :id => 'user_time', :name => 'user[time]')
|
1401
1404
|
end
|
1402
1405
|
|
1403
1406
|
it 'should format DateTime to correct value if min and max and value options exist' do
|
@@ -1411,44 +1414,44 @@ describe "FormBuilder" do
|
|
1411
1414
|
:min => "01:19:12.000",
|
1412
1415
|
:value => "13:30:00.000"
|
1413
1416
|
}
|
1414
|
-
|
1417
|
+
assert_html_has_tag(actual_html, 'input[type=time]', expected)
|
1415
1418
|
end
|
1416
1419
|
|
1417
1420
|
it 'should display correct time field in haml' do
|
1418
|
-
|
1419
|
-
|
1421
|
+
get "/haml/form_for"
|
1422
|
+
assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
|
1420
1423
|
end
|
1421
1424
|
|
1422
1425
|
it 'should display correct time field in erb' do
|
1423
|
-
|
1424
|
-
|
1426
|
+
get "/erb/form_for"
|
1427
|
+
assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
|
1425
1428
|
end
|
1426
1429
|
|
1427
1430
|
it 'should display correct time field in slim' do
|
1428
|
-
|
1429
|
-
|
1431
|
+
get "/slim/form_for"
|
1432
|
+
assert_response_has_tag '#demo input[type=time]', :id => 'markup_user_time'
|
1430
1433
|
end
|
1431
1434
|
end
|
1432
1435
|
|
1433
1436
|
describe 'for #color_field method' do
|
1434
1437
|
it 'should display correct color field html' do
|
1435
1438
|
actual_html = standard_builder.color_field(:color)
|
1436
|
-
|
1439
|
+
assert_html_has_tag(actual_html, 'input[type=color]', :id => 'user_color', :name => 'user[color]')
|
1437
1440
|
end
|
1438
1441
|
|
1439
1442
|
it 'should display correct color field in haml' do
|
1440
|
-
|
1441
|
-
|
1443
|
+
get "/haml/form_for"
|
1444
|
+
assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
|
1442
1445
|
end
|
1443
1446
|
|
1444
1447
|
it 'should display correct color field in erb' do
|
1445
|
-
|
1446
|
-
|
1448
|
+
get "/erb/form_for"
|
1449
|
+
assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
|
1447
1450
|
end
|
1448
1451
|
|
1449
1452
|
it 'should display correct color field in slim' do
|
1450
|
-
|
1451
|
-
|
1453
|
+
get "/slim/form_for"
|
1454
|
+
assert_response_has_tag '#demo input[type=color]', :id => 'markup_user_color', :value => "#ff0000"
|
1452
1455
|
end
|
1453
1456
|
end
|
1454
1457
|
end
|