padrino-helpers 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/padrino-helpers.rb +4 -1
- data/lib/padrino-helpers/asset_tag_helpers.rb +17 -14
- data/lib/padrino-helpers/breadcrumb_helpers.rb +6 -6
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +119 -163
- data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +92 -0
- data/lib/padrino-helpers/form_helpers.rb +66 -347
- data/lib/padrino-helpers/form_helpers/errors.rb +138 -0
- data/lib/padrino-helpers/form_helpers/options.rb +97 -0
- data/lib/padrino-helpers/form_helpers/security.rb +70 -0
- data/lib/padrino-helpers/output_helpers.rb +1 -1
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
- data/lib/padrino-helpers/render_helpers.rb +10 -9
- data/lib/padrino-helpers/tag_helpers.rb +2 -1
- data/lib/padrino/rendering.rb +378 -0
- data/lib/padrino/rendering/extensions/erubis.rb +74 -0
- data/lib/padrino/rendering/extensions/haml.rb +29 -0
- data/lib/padrino/rendering/extensions/slim.rb +21 -0
- data/padrino-helpers.gemspec +2 -1
- data/test/fixtures/apps/.components +6 -0
- data/test/fixtures/apps/.gitignore +7 -0
- data/test/fixtures/apps/render.rb +25 -0
- data/test/fixtures/apps/views/article/comment/show.slim +1 -0
- data/test/fixtures/apps/views/blog/post.erb +1 -0
- data/test/fixtures/apps/views/layouts/specific.erb +1 -0
- data/test/fixtures/apps/views/test/post.erb +1 -0
- data/test/fixtures/layouts/layout.erb +1 -0
- data/test/fixtures/markup_app/app.rb +0 -1
- data/test/fixtures/render_app/app.rb +25 -1
- data/test/fixtures/render_app/views/_unsafe.html.builder +2 -0
- data/test/fixtures/render_app/views/_unsafe_object.html.builder +2 -0
- data/test/fixtures/render_app/views/ruby_block_capture_erb.erb +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_haml.haml +1 -0
- data/test/fixtures/render_app/views/ruby_block_capture_slim.slim +1 -0
- data/test/helper.rb +65 -1
- data/test/test_asset_tag_helpers.rb +83 -79
- data/test/test_breadcrumb_helpers.rb +20 -20
- data/test/test_form_builder.rb +196 -196
- data/test/test_form_helpers.rb +163 -163
- data/test/test_format_helpers.rb +65 -65
- data/test/test_locale.rb +1 -1
- data/test/test_number_helpers.rb +10 -11
- data/test/test_output_helpers.rb +28 -28
- data/test/test_render_helpers.rb +89 -35
- data/test/test_rendering.rb +683 -0
- data/test/test_rendering_extensions.rb +14 -0
- data/test/test_tag_helpers.rb +23 -23
- metadata +57 -5
@@ -9,31 +9,31 @@ describe "BreadcrumbHelpers" do
|
|
9
9
|
|
10
10
|
before(:each) { breadcrumb.reset! }
|
11
11
|
|
12
|
-
|
13
|
-
should
|
12
|
+
describe "for Breadcrumbs#breadcrumbs method" do
|
13
|
+
it 'should support breadcrumbs which is Padrino::Helpers::Breadcrumbs instance.' do
|
14
14
|
breadcrumb.add "foo", "/foo", "foo link"
|
15
15
|
assert_has_tag(:a, :content => "Foo link", :href => "/foo") { breadcrumbs(breadcrumb) }
|
16
16
|
end
|
17
17
|
|
18
|
-
should
|
18
|
+
it 'should support bootstrap' do
|
19
19
|
breadcrumb.add "foo", "/foo", "foo link"
|
20
20
|
assert_has_tag(:span, :content => "/", :class => "divider") { breadcrumbs(breadcrumb, true) }
|
21
21
|
end
|
22
22
|
|
23
|
-
should
|
23
|
+
it 'should support active' do
|
24
24
|
breadcrumb.add "foo", "/foo", "foo link"
|
25
25
|
assert_has_tag(:li, :class => "custom-active") { breadcrumbs(breadcrumb, nil, "custom-active") }
|
26
26
|
end
|
27
27
|
|
28
|
-
should
|
28
|
+
it 'should support options' do
|
29
29
|
assert_has_tag(:ul, :class => "breadcrumbs-class breadcrumb", :id => "breadcrumbs-id") do
|
30
30
|
breadcrumbs(breadcrumb, nil, nil, :id => "breadcrumbs-id", :class => "breadcrumbs-class")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
should
|
35
|
+
describe "for #add method" do
|
36
|
+
it 'should support name of string and symbol type' do
|
37
37
|
breadcrumb.add "foo", "/foo", "Foo Link"
|
38
38
|
breadcrumb.add :bar, "/bar", "Bar Link"
|
39
39
|
|
@@ -42,17 +42,17 @@ describe "BreadcrumbHelpers" do
|
|
42
42
|
assert_has_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
43
43
|
end
|
44
44
|
|
45
|
-
should
|
45
|
+
it 'should support url' do
|
46
46
|
breadcrumb.add :foo, "/foo", "Foo Link"
|
47
47
|
assert_has_tag(:a, :href => "/foo") { breadcrumbs(breadcrumb) }
|
48
48
|
end
|
49
49
|
|
50
|
-
should
|
50
|
+
it 'should support caption' do
|
51
51
|
breadcrumb.add :foo, "/foo", "Foo Link"
|
52
52
|
assert_has_tag(:a, :content => "Foo link") { breadcrumbs(breadcrumb) }
|
53
53
|
end
|
54
54
|
|
55
|
-
should
|
55
|
+
it 'should support options' do
|
56
56
|
breadcrumb.add :foo, "/foo", "Foo Link", :id => "foo-id", :class => "foo-class"
|
57
57
|
breadcrumb.add :bar, "/bar", "Bar Link", :id => "bar-id", :class => "bar-class"
|
58
58
|
|
@@ -62,8 +62,8 @@ describe "BreadcrumbHelpers" do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
should
|
65
|
+
describe "for #del method" do
|
66
|
+
it 'should support name of string type' do
|
67
67
|
breadcrumb.add "foo", "/foo", "Foo Link"
|
68
68
|
breadcrumb.add :bar, "/bar", "Bar Link"
|
69
69
|
|
@@ -75,7 +75,7 @@ describe "BreadcrumbHelpers" do
|
|
75
75
|
assert_has_no_tag(:a, :content => "Bar link", :href => "/bar") { actual_html }
|
76
76
|
end
|
77
77
|
|
78
|
-
should
|
78
|
+
it 'should support name of symbol type' do
|
79
79
|
breadcrumb.add "foo", "/foo", "Foo Link"
|
80
80
|
breadcrumb.add :bar, "/bar", "Bar Link"
|
81
81
|
|
@@ -88,13 +88,13 @@ describe "BreadcrumbHelpers" do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
should
|
91
|
+
describe "for #set_home method" do
|
92
|
+
it 'should modified home item elements.' do
|
93
93
|
breadcrumb.set_home("/custom", "Custom Home Page")
|
94
94
|
assert_has_tag(:a, :content => "Custom home page", :href => "/custom") { breadcrumbs(breadcrumb) }
|
95
95
|
end
|
96
96
|
|
97
|
-
should
|
97
|
+
it 'should support options' do
|
98
98
|
breadcrumb.set_home("/custom", "Custom Home Page", :id => "home-id")
|
99
99
|
|
100
100
|
actual_html = breadcrumbs(breadcrumb)
|
@@ -103,8 +103,8 @@ describe "BreadcrumbHelpers" do
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
|
107
|
-
should
|
106
|
+
describe "for #reset method" do
|
107
|
+
it 'should be #items which contains only home item.' do
|
108
108
|
breadcrumb.set_home("/custom", "Custom Home Page")
|
109
109
|
breadcrumb.add "foo", "/foo", "Foo Link"
|
110
110
|
breadcrumb.add :bar, "/bar", "Bar Link"
|
@@ -118,8 +118,8 @@ describe "BreadcrumbHelpers" do
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
|
122
|
-
should
|
121
|
+
describe "for #reset! method" do
|
122
|
+
it 'should be #items which contains only default home item.' do
|
123
123
|
breadcrumb.add "foo", "/foo", "foo link"
|
124
124
|
breadcrumb.add :bar, "/bar", "Bar Link"
|
125
125
|
|
data/test/test_form_builder.rb
CHANGED
@@ -28,39 +28,39 @@ describe "FormBuilder" do
|
|
28
28
|
Padrino::Helpers::FormBuilder::StandardFormBuilder.new(self, object)
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
should
|
31
|
+
describe 'for #form_for method' do
|
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
34
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
|
35
35
|
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
36
36
|
end
|
37
37
|
|
38
|
-
should
|
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
40
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :id => 'register', :method => 'post') { actual_html }
|
41
41
|
assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
|
42
42
|
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
43
43
|
end
|
44
44
|
|
45
|
-
should
|
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
47
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
48
48
|
assert_has_tag('form input', :type => 'text', :name => 'outer_user_account[username]') { actual_html }
|
49
49
|
end
|
50
50
|
|
51
|
-
should
|
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
54
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
55
55
|
assert_has_tag('span', :content => "bar") { actual_html }
|
56
56
|
end
|
57
57
|
|
58
|
-
should
|
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_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post', "data-remote" => 'true') { actual_html }
|
61
61
|
end
|
62
62
|
|
63
|
-
should
|
63
|
+
it 'should display correct form html with namespace option' do
|
64
64
|
actual_html = form_for(@user, '/update', :namespace => 'foo') do |f|
|
65
65
|
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
66
66
|
end
|
@@ -70,7 +70,7 @@ describe "FormBuilder" do
|
|
70
70
|
assert_has_tag(:input, :type => 'text', :name => 'user[role_types_attributes][0][name]', :id => 'foo_user_role_types_attributes_0_name') { actual_html }
|
71
71
|
end
|
72
72
|
|
73
|
-
should
|
73
|
+
it 'should display correct form html with :as option' do
|
74
74
|
actual_html = form_for(@user, '/update', :as => :customer) do |f|
|
75
75
|
f.text_field(:first_name) << f.fields_for(:role_types) { |role| role.text_field(:name) }
|
76
76
|
end
|
@@ -80,44 +80,44 @@ describe "FormBuilder" do
|
|
80
80
|
assert_has_tag(:input, :type => 'text', :name => 'customer[role_types_attributes][0][name]', :id => 'customer_role_types_attributes_0_name') { actual_html }
|
81
81
|
end
|
82
82
|
|
83
|
-
should
|
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
85
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :method => 'post', "data-remote" => 'true') { actual_html }
|
86
86
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
87
87
|
end
|
88
88
|
|
89
|
-
should
|
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
91
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/update', :method => 'post') { actual_html }
|
92
92
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'put') { actual_html }
|
93
93
|
end
|
94
94
|
|
95
|
-
should
|
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
97
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/destroy', :method => 'post') { actual_html }
|
98
98
|
assert_has_tag('form input', :type => 'hidden', :name => "_method", :value => 'delete') { actual_html }
|
99
99
|
end
|
100
100
|
|
101
|
-
should
|
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_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
104
104
|
end
|
105
105
|
|
106
|
-
should
|
106
|
+
it 'should support changing form builder type' do
|
107
107
|
form_html = proc { form_for(@user, '/register', :"accept-charset" => "UTF-8", :builder => "AbstractFormBuilder") { |f| f.text_field_block(:name) } }
|
108
108
|
assert_raises(NoMethodError) { form_html.call }
|
109
109
|
end
|
110
110
|
|
111
|
-
should
|
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_has_tag('form p input[type=text]') { actual_html }
|
114
114
|
end
|
115
115
|
|
116
|
-
should
|
116
|
+
it 'should display fail for form with nil object' do
|
117
117
|
assert_raises(RuntimeError) { form_for(@not_real, '/register', :id => 'register', :method => 'post') { "Demo" } }
|
118
118
|
end
|
119
119
|
|
120
|
-
should
|
120
|
+
it 'should display correct form in haml' do
|
121
121
|
visit '/haml/form_for'
|
122
122
|
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
123
123
|
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
@@ -125,7 +125,7 @@ describe "FormBuilder" do
|
|
125
125
|
assert_have_selector :input, :name => 'authenticity_token'
|
126
126
|
end
|
127
127
|
|
128
|
-
should
|
128
|
+
it 'should display correct form in erb' do
|
129
129
|
visit '/erb/form_for'
|
130
130
|
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
131
131
|
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
@@ -133,7 +133,7 @@ describe "FormBuilder" do
|
|
133
133
|
assert_have_selector :input, :name => 'authenticity_token'
|
134
134
|
end
|
135
135
|
|
136
|
-
should
|
136
|
+
it 'should display correct form in slim' do
|
137
137
|
visit '/slim/form_for'
|
138
138
|
assert_have_selector :form, :action => '/demo', :id => 'demo'
|
139
139
|
assert_have_selector :form, :action => '/another_demo', :id => 'demo2', :method => 'get'
|
@@ -141,33 +141,33 @@ describe "FormBuilder" do
|
|
141
141
|
assert_have_selector :input, :name => 'authenticity_token'
|
142
142
|
end
|
143
143
|
|
144
|
-
should
|
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_has_tag(:input, :type => 'text', :name => 'user[email]', :id => 'user_email', :class => 'invalid') {actual_html }
|
147
147
|
end
|
148
148
|
|
149
|
-
should
|
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_has_no_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name', :class => 'invalid') {actual_html }
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
|
156
|
-
should
|
155
|
+
describe 'for #fields_for method' do
|
156
|
+
it 'should display correct fields html' do
|
157
157
|
actual_html = fields_for(@user) { |f| f.text_field(:first_name) }
|
158
158
|
assert_has_tag(:input, :type => 'text', :name => 'user[first_name]', :id => 'user_first_name') { actual_html }
|
159
159
|
end
|
160
160
|
|
161
|
-
should
|
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_has_tag(:input, :type => 'text', :name => 'markup_user[first_name]', :id => 'markup_user_first_name') { actual_html }
|
164
164
|
end
|
165
165
|
|
166
|
-
should
|
166
|
+
it 'should display fail for nil object' do
|
167
167
|
assert_raises(RuntimeError) { fields_for(@not_real) { |f| "Demo" } }
|
168
168
|
end
|
169
169
|
|
170
|
-
should
|
170
|
+
it 'should display correct simple fields in haml' do
|
171
171
|
visit '/haml/fields_for'
|
172
172
|
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
173
173
|
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
@@ -175,7 +175,7 @@ describe "FormBuilder" do
|
|
175
175
|
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
176
176
|
end
|
177
177
|
|
178
|
-
should
|
178
|
+
it 'should display correct simple fields in erb' do
|
179
179
|
visit '/erb/fields_for'
|
180
180
|
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
181
181
|
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
@@ -183,7 +183,7 @@ describe "FormBuilder" do
|
|
183
183
|
assert_have_selector '#demo-fields-for input', :type => 'checkbox', :name => 'permission[can_delete]'
|
184
184
|
end
|
185
185
|
|
186
|
-
should
|
186
|
+
it 'should display correct simple fields in slim' do
|
187
187
|
visit '/slim/fields_for'
|
188
188
|
assert_have_selector :form, :action => '/demo1', :id => 'demo-fields-for'
|
189
189
|
assert_have_selector '#demo-fields-for input', :type => 'text', :name => 'markup_user[gender]', :value => 'male'
|
@@ -196,13 +196,13 @@ describe "FormBuilder" do
|
|
196
196
|
# AbstractFormBuilder
|
197
197
|
# ===========================
|
198
198
|
|
199
|
-
|
200
|
-
should
|
199
|
+
describe 'for #error_messages method' do
|
200
|
+
it 'should display correct form html with no record' do
|
201
201
|
actual_html = standard_builder(@user_none).error_messages(:header_message => "Demo form cannot be saved")
|
202
202
|
assert actual_html.blank?
|
203
203
|
end
|
204
204
|
|
205
|
-
should
|
205
|
+
it 'should display correct form html with valid record' do
|
206
206
|
actual_html = standard_builder.error_messages(:header_message => "Demo form cannot be saved", :style => "foo:bar", :class => "mine")
|
207
207
|
assert_has_tag('#field-errors h2', :content => "Demo form cannot be saved") { actual_html }
|
208
208
|
assert_has_tag('#field-errors ul li', :content => "B must be valid") { actual_html }
|
@@ -211,7 +211,7 @@ describe "FormBuilder" do
|
|
211
211
|
assert_has_tag('#field-errors', :class => "mine") { actual_html }
|
212
212
|
end
|
213
213
|
|
214
|
-
should
|
214
|
+
it 'should display correct form in haml' do
|
215
215
|
visit '/haml/form_for'
|
216
216
|
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
217
217
|
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
@@ -224,7 +224,7 @@ describe "FormBuilder" do
|
|
224
224
|
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
225
225
|
end
|
226
226
|
|
227
|
-
should
|
227
|
+
it 'should display correct form in erb' do
|
228
228
|
visit '/erb/form_for'
|
229
229
|
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
230
230
|
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
@@ -237,7 +237,7 @@ describe "FormBuilder" do
|
|
237
237
|
assert_have_selector '#demo input', :name => 'markup_user[email]', :class => 'string invalid'
|
238
238
|
end
|
239
239
|
|
240
|
-
should
|
240
|
+
it 'should display correct form in slim' do
|
241
241
|
visit '/slim/form_for'
|
242
242
|
assert_have_selector '#demo div.field-errors h2', :content => "custom MarkupUser cannot be saved!"
|
243
243
|
assert_have_selector '#demo div.field-errors ul li', :content => "Fake must be valid"
|
@@ -251,51 +251,51 @@ describe "FormBuilder" do
|
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
-
|
255
|
-
should
|
254
|
+
describe 'for #error_message_on method' do
|
255
|
+
it 'should display correct form html with no record' do
|
256
256
|
actual_html = standard_builder(@user_none).error_message_on(:name)
|
257
257
|
assert actual_html.blank?
|
258
258
|
end
|
259
259
|
|
260
|
-
should
|
260
|
+
it 'should display error for specified invalid object' do
|
261
261
|
actual_html = standard_builder(@user).error_message_on(:a, :prepend => "foo", :append => "bar")
|
262
262
|
assert_has_tag('span.error', :content => "foo must be present bar") { actual_html }
|
263
263
|
end
|
264
264
|
|
265
|
-
should
|
265
|
+
it 'should display error for specified invalid object not matching class name' do
|
266
266
|
@bob = mock_model("User", :first_name => "Frank", :errors => { :foo => "must be bob" })
|
267
267
|
actual_html = standard_builder(@bob).error_message_on(:foo, :prepend => "foo", :append => "bar")
|
268
268
|
assert_has_tag('span.error', :content => "foo must be bob bar") { actual_html }
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
272
|
-
|
273
|
-
should
|
272
|
+
describe 'for #label method' do
|
273
|
+
it 'should display correct label html' do
|
274
274
|
actual_html = standard_builder.label(:first_name, :class => 'large', :caption => "F. Name: ")
|
275
275
|
assert_has_tag('label', :class => 'large', :for => 'user_first_name', :content => "F. Name: ") { actual_html }
|
276
276
|
end
|
277
277
|
|
278
|
-
should
|
278
|
+
it 'should set specific content inside the label if a block was provided' do
|
279
279
|
actual_html = standard_builder.label(:admin, :class => 'large') { input_tag :checkbox }
|
280
280
|
assert_has_tag('label', :class => 'large', :for => 'user_admin', :content => "Admin: ") { actual_html }
|
281
281
|
assert_has_tag('label input[type=checkbox]') { actual_html }
|
282
282
|
end
|
283
283
|
|
284
|
-
should
|
284
|
+
it 'should display correct label in haml' do
|
285
285
|
visit '/haml/form_for'
|
286
286
|
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
287
287
|
assert_have_selector '#demo label', :content => "About Me: "
|
288
288
|
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
289
289
|
end
|
290
290
|
|
291
|
-
should
|
291
|
+
it 'should display correct label in erb' do
|
292
292
|
visit '/erb/form_for'
|
293
293
|
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
294
294
|
assert_have_selector '#demo label', :content => "About Me: "
|
295
295
|
assert_have_selector '#demo2 label', :content => "Nickname: ", :class => 'label'
|
296
296
|
end
|
297
297
|
|
298
|
-
should
|
298
|
+
it 'should display correct label in slim' do
|
299
299
|
visit '/slim/form_for'
|
300
300
|
assert_have_selector '#demo label', :content => "Login: ", :class => 'user-label'
|
301
301
|
assert_have_selector '#demo label', :content => "About Me: "
|
@@ -303,225 +303,225 @@ describe "FormBuilder" do
|
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
|
-
|
307
|
-
should
|
306
|
+
describe 'for #hidden_field method' do
|
307
|
+
it 'should display correct hidden field html' do
|
308
308
|
actual_html = standard_builder.hidden_field(:session_id, :class => 'hidden')
|
309
309
|
assert_has_tag('input.hidden[type=hidden]', :value => "54", :id => 'user_session_id', :name => 'user[session_id]') { actual_html }
|
310
310
|
end
|
311
311
|
|
312
|
-
should
|
312
|
+
it 'should display correct hidden field in haml' do
|
313
313
|
visit '/haml/form_for'
|
314
314
|
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
315
315
|
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
316
316
|
end
|
317
317
|
|
318
|
-
should
|
318
|
+
it 'should display correct hidden field in erb' do
|
319
319
|
visit '/erb/form_for'
|
320
320
|
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
321
321
|
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
322
322
|
end
|
323
323
|
|
324
|
-
should
|
324
|
+
it 'should display correct hidden field in slim' do
|
325
325
|
visit '/slim/form_for'
|
326
326
|
assert_have_selector '#demo input[type=hidden]', :id => 'markup_user_session_id', :value => "45"
|
327
327
|
assert_have_selector '#demo2 input', :type => 'hidden', :name => 'markup_user[session_id]'
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
331
|
-
|
332
|
-
should
|
331
|
+
describe 'for #text_field method' do
|
332
|
+
it 'should display correct text field html' do
|
333
333
|
actual_html = standard_builder.text_field(:first_name, :class => 'large')
|
334
334
|
assert_has_tag('input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
335
335
|
end
|
336
336
|
|
337
|
-
should
|
337
|
+
it 'should display correct text field in haml' do
|
338
338
|
visit '/haml/form_for'
|
339
339
|
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
340
340
|
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
341
341
|
end
|
342
342
|
|
343
|
-
should
|
343
|
+
it 'should display correct text field in erb' do
|
344
344
|
visit '/erb/form_for'
|
345
345
|
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
346
346
|
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
347
347
|
end
|
348
348
|
|
349
|
-
should
|
349
|
+
it 'should display correct text field in slim' do
|
350
350
|
visit '/slim/form_for'
|
351
351
|
assert_have_selector '#demo input.user-text[type=text]', :id => 'markup_user_username', :value => "John"
|
352
352
|
assert_have_selector '#demo2 input', :type => 'text', :class => 'input', :name => 'markup_user[username]'
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
|
-
|
357
|
-
should
|
356
|
+
describe 'for #number_field method' do
|
357
|
+
it 'should display correct number field html' do
|
358
358
|
actual_html = standard_builder.number_field(:age, :class => 'numeric')
|
359
359
|
assert_has_tag('input.numeric[type=number]', :id => 'user_age', :name => 'user[age]') { actual_html }
|
360
360
|
end
|
361
361
|
|
362
|
-
should
|
362
|
+
it 'should display correct number field in haml' do
|
363
363
|
visit '/haml/form_for'
|
364
364
|
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
365
365
|
end
|
366
366
|
|
367
|
-
should
|
367
|
+
it 'should display correct number field in erb' do
|
368
368
|
visit '/erb/form_for'
|
369
369
|
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
370
370
|
end
|
371
371
|
|
372
|
-
should
|
372
|
+
it 'should display correct number field in slim' do
|
373
373
|
visit '/slim/form_for'
|
374
374
|
assert_have_selector '#demo input.numeric[type=number]', :id => 'markup_user_age'
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
|
-
|
379
|
-
should
|
378
|
+
describe 'for #telephone_field method' do
|
379
|
+
it 'should display correct telephone field html' do
|
380
380
|
actual_html = standard_builder.telephone_field(:telephone, :class => 'numeric')
|
381
381
|
assert_has_tag('input.numeric[type=tel]', :id => 'user_telephone', :name => 'user[telephone]') { actual_html }
|
382
382
|
end
|
383
383
|
|
384
|
-
should
|
384
|
+
it 'should display correct telephone field in haml' do
|
385
385
|
visit '/haml/form_for'
|
386
386
|
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
387
387
|
end
|
388
388
|
|
389
|
-
should
|
389
|
+
it 'should display correct telephone field in erb' do
|
390
390
|
visit '/erb/form_for'
|
391
391
|
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
392
392
|
end
|
393
393
|
|
394
|
-
should
|
394
|
+
it 'should display correct telephone field in slim' do
|
395
395
|
visit '/slim/form_for'
|
396
396
|
assert_have_selector '#demo input.numeric[type=tel]', :id => 'markup_user_telephone'
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
400
|
-
|
401
|
-
should
|
400
|
+
describe 'for #search_field method' do
|
401
|
+
it 'should display correct search field html' do
|
402
402
|
actual_html = standard_builder.search_field(:search, :class => 'string')
|
403
403
|
assert_has_tag('input.string[type=search]', :id => 'user_search', :name => 'user[search]') { actual_html }
|
404
404
|
end
|
405
405
|
|
406
|
-
should
|
406
|
+
it 'should display correct search field in haml' do
|
407
407
|
visit '/haml/form_for'
|
408
408
|
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
409
409
|
end
|
410
410
|
|
411
|
-
should
|
411
|
+
it 'should display correct search field in erb' do
|
412
412
|
visit '/erb/form_for'
|
413
413
|
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
414
414
|
end
|
415
415
|
|
416
|
-
should
|
416
|
+
it 'should display correct search field in slim' do
|
417
417
|
visit '/slim/form_for'
|
418
418
|
assert_have_selector '#demo input.string[type=search]', :id => 'markup_user_search'
|
419
419
|
end
|
420
420
|
end
|
421
421
|
|
422
|
-
|
423
|
-
should
|
422
|
+
describe 'for #email_field method' do
|
423
|
+
it 'should display correct email field html' do
|
424
424
|
actual_html = standard_builder.email_field(:email, :class => 'string')
|
425
425
|
assert_has_tag('input.string[type=email]', :id => 'user_email', :name => 'user[email]') { actual_html }
|
426
426
|
end
|
427
427
|
|
428
|
-
should
|
428
|
+
it 'should display correct email field in haml' do
|
429
429
|
visit '/haml/form_for'
|
430
430
|
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
431
431
|
end
|
432
432
|
|
433
|
-
should
|
433
|
+
it 'should display correct email field in erb' do
|
434
434
|
visit '/erb/form_for'
|
435
435
|
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
436
436
|
end
|
437
437
|
|
438
|
-
should
|
438
|
+
it 'should display correct email field in slim' do
|
439
439
|
visit '/slim/form_for'
|
440
440
|
assert_have_selector '#demo input.string[type=email]', :id => 'markup_user_email'
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
444
|
-
|
445
|
-
should
|
444
|
+
describe 'for #url_field method' do
|
445
|
+
it 'should display correct url field html' do
|
446
446
|
actual_html = standard_builder.url_field(:webpage, :class => 'string')
|
447
447
|
assert_has_tag('input.string[type=url]', :id => 'user_webpage', :name => 'user[webpage]') { actual_html }
|
448
448
|
end
|
449
449
|
|
450
|
-
should
|
450
|
+
it 'should display correct url field in haml' do
|
451
451
|
visit '/haml/form_for'
|
452
452
|
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
453
453
|
end
|
454
454
|
|
455
|
-
should
|
455
|
+
it 'should display correct url field in erb' do
|
456
456
|
visit '/erb/form_for'
|
457
457
|
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
458
458
|
end
|
459
459
|
|
460
|
-
should
|
460
|
+
it 'should display correct url field in slim' do
|
461
461
|
visit '/slim/form_for'
|
462
462
|
assert_have_selector '#demo input.string[type=url]', :id => 'markup_user_webpage'
|
463
463
|
end
|
464
464
|
end
|
465
465
|
|
466
|
-
|
467
|
-
should
|
466
|
+
describe 'for #check_box method' do
|
467
|
+
it 'should display correct checkbox html' do
|
468
468
|
actual_html = standard_builder.check_box(:confirm_destroy, :class => 'large')
|
469
469
|
assert_has_tag('input.large[type=checkbox]', :id => 'user_confirm_destroy', :name => 'user[confirm_destroy]') { actual_html }
|
470
470
|
assert_has_tag('input[type=hidden]', :name => 'user[confirm_destroy]', :value => '0') { actual_html }
|
471
471
|
end
|
472
472
|
|
473
|
-
should
|
473
|
+
it 'should display correct checkbox html when checked' do
|
474
474
|
actual_html = standard_builder.check_box(:confirm_destroy, :checked => true)
|
475
475
|
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[confirm_destroy]') { actual_html }
|
476
476
|
end
|
477
477
|
|
478
|
-
should
|
478
|
+
it 'should display correct checkbox html as checked when object value matches' do
|
479
479
|
@user.stubs(:show_favorites => 'human')
|
480
480
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
481
481
|
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
482
482
|
end
|
483
483
|
|
484
|
-
should
|
484
|
+
it 'should display correct checkbox html as checked when object value is true' do
|
485
485
|
@user.stubs(:show_favorites => true)
|
486
486
|
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
487
487
|
assert_has_tag('input[type=checkbox]', :checked => 'checked', :name => 'user[show_favorites]') { actual_html }
|
488
488
|
end
|
489
489
|
|
490
|
-
should
|
490
|
+
it 'should display correct checkbox html as unchecked when object value does not match' do
|
491
491
|
@user.stubs(:show_favorites => 'alien')
|
492
492
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'human')
|
493
493
|
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
494
494
|
end
|
495
495
|
|
496
|
-
should
|
496
|
+
it 'should display correct checkbox html as unchecked when object value is false' do
|
497
497
|
@user.stubs(:show_favorites => false)
|
498
498
|
actual_html = standard_builder.check_box(:show_favorites, :value => '1')
|
499
499
|
assert_has_no_tag('input[type=checkbox]', :checked => 'checked') { actual_html }
|
500
500
|
end
|
501
501
|
|
502
|
-
should
|
502
|
+
it 'should display correct unchecked hidden field when specified' do
|
503
503
|
actual_html = standard_builder.check_box(:show_favorites, :value => 'female', :uncheck_value => 'false')
|
504
504
|
assert_has_tag('input[type=hidden]', :name => 'user[show_favorites]', :value => 'false') { actual_html }
|
505
505
|
end
|
506
506
|
|
507
|
-
should
|
507
|
+
it 'should display correct checkbox in haml' do
|
508
508
|
visit '/haml/form_for'
|
509
509
|
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
510
510
|
end
|
511
511
|
|
512
|
-
should
|
512
|
+
it 'should display correct checkbox in erb' do
|
513
513
|
visit '/erb/form_for'
|
514
514
|
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
515
515
|
end
|
516
516
|
|
517
|
-
should
|
517
|
+
it 'should display correct checkbox in slim' do
|
518
518
|
visit '/slim/form_for'
|
519
519
|
assert_have_selector '#demo input[type=checkbox]', :checked => 'checked', :id => 'markup_user_remember_me', :name => 'markup_user[remember_me]'
|
520
520
|
end
|
521
521
|
end
|
522
522
|
|
523
|
-
|
524
|
-
should
|
523
|
+
describe 'for #check_box_group and #radio_button_group methods' do
|
524
|
+
it 'should display checkbox group html' do
|
525
525
|
checkboxes = standard_builder.check_box_group(:role, :collection => @user.role_types, :fields => [:name, :id], :selected => [2,3])
|
526
526
|
assert_has_tag('input[type=checkbox]', :value => '1') { checkboxes }
|
527
527
|
assert_has_no_tag('input[type=checkbox][checked]', :value => '1') { checkboxes }
|
@@ -529,14 +529,14 @@ describe "FormBuilder" do
|
|
529
529
|
assert_has_tag('label[for=user_role_3] input[name="user[role][]"][value="3"][checked]') { checkboxes }
|
530
530
|
end
|
531
531
|
|
532
|
-
should
|
532
|
+
it 'should display checkbox group html and extract selected values from the object' do
|
533
533
|
checkboxes = standard_builder.check_box_group(:roles, :collection => @user.role_types, :fields => [:name, :id])
|
534
534
|
assert_has_tag('input[type=checkbox][name="user[roles][]"][value="1"][checked]') { checkboxes }
|
535
535
|
assert_has_tag('input[type=checkbox][name="user[roles][]"][value="3"][checked]') { checkboxes }
|
536
536
|
assert_has_no_tag('input[type=checkbox][name="user[roles][]"][value="2"][checked]') { checkboxes }
|
537
537
|
end
|
538
538
|
|
539
|
-
should
|
539
|
+
it 'should display radio group html' do
|
540
540
|
radios = standard_builder.radio_button_group(:role, :options => %W(red yellow blue), :selected => 'yellow')
|
541
541
|
assert_has_tag('input[type=radio]', :value => 'red') { radios }
|
542
542
|
assert_has_no_tag('input[type=radio][checked]', :value => 'red') { radios }
|
@@ -544,51 +544,51 @@ describe "FormBuilder" do
|
|
544
544
|
assert_has_tag('label[for=user_role_blue] input[name="user[role]"][value=blue]') { radios }
|
545
545
|
end
|
546
546
|
|
547
|
-
should
|
547
|
+
it 'should display radio group html and extract selected value from the object' do
|
548
548
|
radios = standard_builder.radio_button_group(:role, :collection => @user.role_types)
|
549
549
|
assert_has_tag('input[type=radio][value="1"][checked]') { radios }
|
550
550
|
assert_has_no_tag('input[type=radio][value="2"][checked]') { radios }
|
551
551
|
end
|
552
552
|
end
|
553
553
|
|
554
|
-
|
555
|
-
should
|
554
|
+
describe 'for #radio_button method' do
|
555
|
+
it 'should display correct radio button html' do
|
556
556
|
actual_html = standard_builder.radio_button(:gender, :value => 'male', :class => 'large')
|
557
557
|
assert_has_tag('input.large[type=radio]', :id => 'user_gender_male', :name => 'user[gender]', :value => 'male') { actual_html }
|
558
558
|
end
|
559
559
|
|
560
|
-
should
|
560
|
+
it 'should display correct radio button html when checked' do
|
561
561
|
actual_html = standard_builder.radio_button(:gender, :checked => true)
|
562
562
|
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
563
563
|
end
|
564
564
|
|
565
|
-
should
|
565
|
+
it 'should display correct radio button html as checked when object value matches' do
|
566
566
|
@user.stubs(:gender => 'male')
|
567
567
|
actual_html = standard_builder.radio_button(:gender, :value => 'male')
|
568
568
|
assert_has_tag('input[type=radio]', :checked => 'checked', :name => 'user[gender]') { actual_html }
|
569
569
|
end
|
570
570
|
|
571
|
-
should
|
571
|
+
it 'should display correct radio button html as unchecked when object value does not match' do
|
572
572
|
@user.stubs(:gender => 'male')
|
573
573
|
actual_html = standard_builder.radio_button(:gender, :value => 'female')
|
574
574
|
assert_has_no_tag('input[type=radio]', :checked => 'checked') { actual_html }
|
575
575
|
end
|
576
576
|
|
577
|
-
should
|
577
|
+
it 'should display correct radio button in haml' do
|
578
578
|
visit '/haml/form_for'
|
579
579
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
580
580
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
581
581
|
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
582
582
|
end
|
583
583
|
|
584
|
-
should
|
584
|
+
it 'should display correct radio button in erb' do
|
585
585
|
visit '/erb/form_for'
|
586
586
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
587
587
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
588
588
|
assert_have_selector '#demo input[type=radio][checked=checked]', :id => 'markup_user_gender_male'
|
589
589
|
end
|
590
590
|
|
591
|
-
should
|
591
|
+
it 'should display correct radio button in slim' do
|
592
592
|
visit '/slim/form_for'
|
593
593
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_male', :name => 'markup_user[gender]', :value => 'male'
|
594
594
|
assert_have_selector '#demo input[type=radio]', :id => 'markup_user_gender_female', :name => 'markup_user[gender]', :value => 'female'
|
@@ -596,99 +596,99 @@ describe "FormBuilder" do
|
|
596
596
|
end
|
597
597
|
end
|
598
598
|
|
599
|
-
|
600
|
-
should
|
599
|
+
describe 'for #text_area method' do
|
600
|
+
it 'should display correct text_area html' do
|
601
601
|
actual_html = standard_builder.text_area(:about, :class => 'large')
|
602
602
|
assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
|
603
603
|
end
|
604
604
|
|
605
|
-
should
|
605
|
+
it 'should display correct text_area html and content' do
|
606
606
|
actual_html = standard_builder.text_area(:about, :value => "Demo", :rows => '5', :cols => '6')
|
607
607
|
assert_has_tag('textarea', :id => 'user_about', :content => 'Demo', :rows => '5', :cols => '6') { actual_html }
|
608
608
|
end
|
609
609
|
|
610
|
-
should
|
610
|
+
it 'should display correct text_area in haml' do
|
611
611
|
visit '/haml/form_for'
|
612
612
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
613
613
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
614
614
|
end
|
615
615
|
|
616
|
-
should
|
616
|
+
it 'should display correct text_area in erb' do
|
617
617
|
visit '/erb/form_for'
|
618
618
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
619
619
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
620
620
|
end
|
621
621
|
|
622
|
-
should
|
622
|
+
it 'should display correct text_area in slim' do
|
623
623
|
visit '/slim/form_for'
|
624
624
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
625
625
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
626
626
|
end
|
627
627
|
end
|
628
628
|
|
629
|
-
|
630
|
-
should
|
629
|
+
describe 'for #password_field method' do
|
630
|
+
it 'should display correct password_field html' do
|
631
631
|
actual_html = standard_builder.password_field(:code, :class => 'large')
|
632
632
|
assert_has_tag('input.large[type=password]', :id => 'user_code', :name => 'user[code]') { actual_html }
|
633
633
|
end
|
634
634
|
|
635
|
-
should
|
635
|
+
it 'should display correct password_field in haml' do
|
636
636
|
visit '/haml/form_for'
|
637
637
|
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
638
638
|
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
639
639
|
end
|
640
640
|
|
641
|
-
should
|
641
|
+
it 'should display correct password_field in erb' do
|
642
642
|
visit '/erb/form_for'
|
643
643
|
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
644
644
|
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
645
645
|
end
|
646
646
|
|
647
|
-
should
|
647
|
+
it 'should display correct password_field in slim' do
|
648
648
|
visit '/slim/form_for'
|
649
649
|
assert_have_selector '#demo input', :type => 'password', :class => 'user-password', :value => 'secret'
|
650
650
|
assert_have_selector '#demo2 input', :type => 'password', :class => 'input', :name => 'markup_user[code]'
|
651
651
|
end
|
652
652
|
end
|
653
653
|
|
654
|
-
|
655
|
-
should
|
654
|
+
describe 'for #file_field method' do
|
655
|
+
it 'should display correct file_field html' do
|
656
656
|
actual_html = standard_builder.file_field(:photo, :class => 'large')
|
657
657
|
assert_has_tag('input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
658
658
|
end
|
659
659
|
|
660
|
-
should
|
660
|
+
it 'should display correct file_field in haml' do
|
661
661
|
visit '/haml/form_for'
|
662
662
|
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
663
663
|
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
664
664
|
end
|
665
665
|
|
666
|
-
should
|
666
|
+
it 'should display correct file_field in erb' do
|
667
667
|
visit '/erb/form_for'
|
668
668
|
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
669
669
|
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
670
670
|
end
|
671
671
|
|
672
|
-
should
|
672
|
+
it 'should display correct file_field in slim' do
|
673
673
|
visit '/slim/form_for'
|
674
674
|
assert_have_selector '#demo input.user-photo', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
675
675
|
assert_have_selector '#demo2 input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
676
676
|
end
|
677
677
|
|
678
|
-
should
|
678
|
+
it 'should display correct form html with multipart, even if no multipart option is specified' do
|
679
679
|
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8") { |f| f.file_field :photo }
|
680
680
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
681
681
|
end
|
682
682
|
|
683
|
-
should
|
683
|
+
it 'should display correct form html without multipart, if multipart option is specified false' do
|
684
684
|
actual_html = form_for(@user, '/register', :"accept-charset" => "UTF-8", :multipart => false) { |f| f.file_field :photo }
|
685
685
|
assert_has_no_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :enctype => "multipart/form-data") { actual_html }
|
686
686
|
end
|
687
687
|
|
688
688
|
end
|
689
689
|
|
690
|
-
|
691
|
-
should
|
690
|
+
describe 'for #select method' do
|
691
|
+
it 'should display correct select html' do
|
692
692
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :class => 'selecty')
|
693
693
|
assert_has_tag('select.selecty', :id => 'user_state', :name => 'user[state]') { actual_html }
|
694
694
|
assert_has_tag('select.selecty option', :count => 3) { actual_html }
|
@@ -697,7 +697,7 @@ describe "FormBuilder" do
|
|
697
697
|
assert_has_tag('select.selecty option', :value => 'Wyoming', :content => 'Wyoming') { actual_html }
|
698
698
|
end
|
699
699
|
|
700
|
-
should
|
700
|
+
it 'should display correct select html with selected item if it matches value' do
|
701
701
|
@user.stubs(:state => 'California')
|
702
702
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'])
|
703
703
|
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
@@ -705,7 +705,7 @@ describe "FormBuilder" do
|
|
705
705
|
assert_has_tag('select option', :value => 'California', :selected => 'selected') { actual_html }
|
706
706
|
end
|
707
707
|
|
708
|
-
should
|
708
|
+
it 'should display correct select html with selected item if it matches full value' do
|
709
709
|
@user.stubs(:state => 'Cali')
|
710
710
|
actual_html = standard_builder.select(:state, :options => ['Cali', 'California', 'Texas', 'Wyoming'])
|
711
711
|
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
@@ -714,7 +714,7 @@ describe "FormBuilder" do
|
|
714
714
|
assert_has_tag('select option', :value => 'California') { actual_html }
|
715
715
|
end
|
716
716
|
|
717
|
-
should
|
717
|
+
it 'should display correct select html with multiple selected items' do
|
718
718
|
@user.stubs(:pickles => ['foo', 'bar'])
|
719
719
|
actual_html = standard_builder.select(
|
720
720
|
:pickles, :options => [ ['Foo', 'foo'], ['Bar', 'bar'], ['Baz', 'baz'], ['Bar Buz', 'bar buz'] ]
|
@@ -725,7 +725,7 @@ describe "FormBuilder" do
|
|
725
725
|
assert_has_tag('option', :value => 'bar buz', :content => 'Bar Buz') { actual_html }
|
726
726
|
end
|
727
727
|
|
728
|
-
should
|
728
|
+
it 'should display correct select html with include_blank' do
|
729
729
|
actual_html = standard_builder.select(:state, :options => ['California', 'Texas', 'Wyoming'], :include_blank => true)
|
730
730
|
assert_has_tag('select', :id => 'user_state', :name => 'user[state]') { actual_html }
|
731
731
|
assert_has_tag('select option', :count => 4) { actual_html }
|
@@ -738,7 +738,7 @@ describe "FormBuilder" do
|
|
738
738
|
assert_has_tag('select option:first-child', :value => '') { actual_html }
|
739
739
|
end
|
740
740
|
|
741
|
-
should
|
741
|
+
it 'should display correct select html with collection passed in' do
|
742
742
|
actual_html = standard_builder.select(:role, :collection => @user.role_types, :fields => [:name, :id])
|
743
743
|
assert_has_tag('select', :id => 'user_role', :name => 'user[role]') { actual_html }
|
744
744
|
assert_has_tag('select option', :count => 3) { actual_html }
|
@@ -747,103 +747,103 @@ describe "FormBuilder" do
|
|
747
747
|
assert_has_tag('select option', :value => '3', :content => 'Limited') { actual_html }
|
748
748
|
end
|
749
749
|
|
750
|
-
should
|
750
|
+
it 'should display correct select in haml' do
|
751
751
|
visit '/haml/form_for'
|
752
752
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
753
753
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
754
754
|
end
|
755
755
|
|
756
|
-
should
|
756
|
+
it 'should display correct select in erb' do
|
757
757
|
visit '/erb/form_for'
|
758
758
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
759
759
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
760
760
|
end
|
761
761
|
|
762
|
-
should
|
762
|
+
it 'should display correct select in slim' do
|
763
763
|
visit '/slim/form_for'
|
764
764
|
assert_have_selector '#demo textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'user-about'
|
765
765
|
assert_have_selector '#demo2 textarea', :name => 'markup_user[about]', :id => 'markup_user_about', :class => 'textarea'
|
766
766
|
end
|
767
767
|
end
|
768
768
|
|
769
|
-
|
770
|
-
should
|
769
|
+
describe 'for #submit method' do
|
770
|
+
it 'should display correct submit button html with no options' do
|
771
771
|
actual_html = standard_builder.submit
|
772
772
|
assert_has_tag('input[type=submit]', :value => "Submit") { actual_html }
|
773
773
|
end
|
774
774
|
|
775
775
|
|
776
|
-
should
|
776
|
+
it 'should display correct submit button html with no caption' do
|
777
777
|
actual_html = standard_builder.submit(:class => 'btn')
|
778
778
|
assert_has_tag('input.btn[type=submit]', :value => "Submit") { actual_html }
|
779
779
|
end
|
780
780
|
|
781
|
-
should
|
781
|
+
it 'should display correct submit button html with nil caption' do
|
782
782
|
actual_html = standard_builder.submit(nil, :class => 'btn')
|
783
783
|
assert_has_tag('input.btn[type=submit]') { actual_html }
|
784
784
|
assert actual_html !~ %r{ value \* = }x
|
785
785
|
end
|
786
786
|
|
787
|
-
should
|
787
|
+
it 'should display correct submit button html' do
|
788
788
|
actual_html = standard_builder.submit("Commit", :class => 'large')
|
789
789
|
assert_has_tag('input.large[type=submit]', :value => "Commit") { actual_html }
|
790
790
|
end
|
791
791
|
|
792
|
-
should
|
792
|
+
it 'should display correct submit button in haml' do
|
793
793
|
visit '/haml/form_for'
|
794
794
|
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
795
795
|
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
796
796
|
end
|
797
797
|
|
798
|
-
should
|
798
|
+
it 'should display correct submit button in erb' do
|
799
799
|
visit '/erb/form_for'
|
800
800
|
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
801
801
|
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
802
802
|
end
|
803
803
|
|
804
|
-
should
|
804
|
+
it 'should display correct submit button in slim' do
|
805
805
|
visit '/slim/form_for'
|
806
806
|
assert_have_selector '#demo input', :type => 'submit', :id => 'demo-button', :class => 'success'
|
807
807
|
assert_have_selector '#demo2 input', :type => 'submit', :class => 'button', :value => "Create"
|
808
808
|
end
|
809
809
|
end
|
810
810
|
|
811
|
-
|
812
|
-
|
811
|
+
describe 'for #image_submit method' do
|
812
|
+
before do
|
813
813
|
@stamp = stop_time_for_test.to_i
|
814
814
|
end
|
815
815
|
|
816
|
-
should
|
816
|
+
it 'should display correct image submit button html with no options' do
|
817
817
|
actual_html = standard_builder.image_submit('buttons/ok.png')
|
818
818
|
assert_has_tag('input[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
819
819
|
end
|
820
820
|
|
821
|
-
should
|
821
|
+
it 'should display correct image submit button html' do
|
822
822
|
actual_html = standard_builder.image_submit('/system/ok.png', :class => 'large')
|
823
823
|
assert_has_tag('input.large[type=image]', :src => "/system/ok.png") { actual_html }
|
824
824
|
end
|
825
825
|
|
826
|
-
should
|
826
|
+
it 'should display correct image submit button in haml' do
|
827
827
|
visit '/haml/form_for'
|
828
828
|
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
829
829
|
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
830
830
|
end
|
831
831
|
|
832
|
-
should
|
832
|
+
it 'should display correct image submit button in erb' do
|
833
833
|
visit '/erb/form_for'
|
834
834
|
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
835
835
|
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
836
836
|
end
|
837
837
|
|
838
|
-
should
|
838
|
+
it 'should display correct image submit button in slim' do
|
839
839
|
visit '/slim/form_for'
|
840
840
|
assert_have_selector '#demo input', :type => 'image', :id => 'image-button', :src => "/images/buttons/post.png?#{@stamp}"
|
841
841
|
assert_have_selector '#demo2 input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
842
842
|
end
|
843
843
|
end
|
844
844
|
|
845
|
-
|
846
|
-
|
845
|
+
describe 'for #fields_for method' do
|
846
|
+
before do
|
847
847
|
@telephone = mock_model("Telephone", :number => "4568769876")
|
848
848
|
@user.stubs(:telephone).returns(@telephone)
|
849
849
|
@businesses = [ mock_model("Business", :name => "Silver", :new_record? => false, :id => 20) ]
|
@@ -853,7 +853,7 @@ describe "FormBuilder" do
|
|
853
853
|
@user.stubs(:addresses).returns(@addresses)
|
854
854
|
end
|
855
855
|
|
856
|
-
should
|
856
|
+
it 'should display nested children fields one-to-one within form' do
|
857
857
|
actual_html = standard_builder.fields_for :telephone do |child_form|
|
858
858
|
child_form.label(:number) +
|
859
859
|
child_form.text_field(:number) +
|
@@ -865,7 +865,7 @@ describe "FormBuilder" do
|
|
865
865
|
assert_has_tag('input', :type => 'checkbox', :id => 'user_telephone_attributes__destroy', :name => 'user[telephone_attributes][_destroy]', :value => '1') { actual_html }
|
866
866
|
end
|
867
867
|
|
868
|
-
should
|
868
|
+
it 'should display nested children fields one-to-many within form' do
|
869
869
|
actual_html = standard_builder.fields_for(:addresses) do |child_form|
|
870
870
|
html = child_form.label(:name)
|
871
871
|
html << child_form.check_box('_destroy') unless child_form.object.new_record?
|
@@ -883,7 +883,7 @@ describe "FormBuilder" do
|
|
883
883
|
assert_has_no_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_1__destroy') { actual_html }
|
884
884
|
end
|
885
885
|
|
886
|
-
should
|
886
|
+
it 'should display fields for explicit instance object' do
|
887
887
|
address = mock_model("Address", :name => "Page", :new_record? => false, :id => 40)
|
888
888
|
actual_html = standard_builder.fields_for(:addresses, address) do |child_form|
|
889
889
|
html = child_form.label(:name)
|
@@ -896,7 +896,7 @@ describe "FormBuilder" do
|
|
896
896
|
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_0__destroy', :name => 'user[addresses_attributes][0][_destroy]', :value => '1') { actual_html }
|
897
897
|
end
|
898
898
|
|
899
|
-
should
|
899
|
+
it 'should display fields for collection object' do
|
900
900
|
addresses = @addresses + [mock_model("Address", :name => "Walter", :new_record? => false, :id => 50)]
|
901
901
|
actual_html = standard_builder.fields_for(:addresses, addresses) do |child_form|
|
902
902
|
child_form.label(:name) +
|
@@ -915,7 +915,7 @@ describe "FormBuilder" do
|
|
915
915
|
assert_has_tag('input', :type => 'checkbox', :id => 'user_addresses_attributes_2__destroy') { actual_html }
|
916
916
|
end
|
917
917
|
|
918
|
-
should
|
918
|
+
it 'should display fields for arbitrarily deep nested forms' do
|
919
919
|
actual_html = standard_builder.fields_for :addresses do |child_form|
|
920
920
|
child_form.fields_for(:businesses) do |second_child_form|
|
921
921
|
second_child_form.label(:name) +
|
@@ -927,7 +927,7 @@ describe "FormBuilder" do
|
|
927
927
|
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
|
928
928
|
end
|
929
929
|
|
930
|
-
should
|
930
|
+
it 'should display fields for nested forms with custom indices' do
|
931
931
|
actual_html = standard_builder.fields_for :addresses do |child_form|
|
932
932
|
html = ''.html_safe
|
933
933
|
child_form.object.businesses.each_with_index do |business, i|
|
@@ -944,7 +944,7 @@ describe "FormBuilder" do
|
|
944
944
|
assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]') { actual_html }
|
945
945
|
end
|
946
946
|
|
947
|
-
should
|
947
|
+
it 'should display nested children fields in erb' do
|
948
948
|
visit '/erb/fields_for'
|
949
949
|
# Telephone
|
950
950
|
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
@@ -961,7 +961,7 @@ describe "FormBuilder" do
|
|
961
961
|
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
962
962
|
end
|
963
963
|
|
964
|
-
should
|
964
|
+
it 'should display nested children fields in haml' do
|
965
965
|
visit '/haml/fields_for'
|
966
966
|
# Telephone
|
967
967
|
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
@@ -978,7 +978,7 @@ describe "FormBuilder" do
|
|
978
978
|
assert_have_no_selector('input', :type => 'checkbox', :id => 'markup_user_addresses_attributes_1__destroy')
|
979
979
|
end
|
980
980
|
|
981
|
-
should
|
981
|
+
it 'should display nested children fields in slim' do
|
982
982
|
visit '/slim/fields_for'
|
983
983
|
# Telephone
|
984
984
|
assert_have_selector('label', :for => 'markup_user_telephone_attributes_number')
|
@@ -1000,138 +1000,138 @@ describe "FormBuilder" do
|
|
1000
1000
|
# StandardFormBuilder
|
1001
1001
|
# ===========================
|
1002
1002
|
|
1003
|
-
|
1004
|
-
should
|
1003
|
+
describe 'for #text_field_block method' do
|
1004
|
+
it 'should display correct text field block html' do
|
1005
1005
|
actual_html = standard_builder.text_field_block(:first_name, :class => 'large', :caption => "FName")
|
1006
1006
|
assert_has_tag('p label', :for => 'user_first_name', :content => "FName") { actual_html }
|
1007
1007
|
assert_has_tag('p input.large[type=text]', :value => "Joe", :id => 'user_first_name', :name => 'user[first_name]') { actual_html }
|
1008
1008
|
end
|
1009
1009
|
|
1010
|
-
should
|
1010
|
+
it 'should display correct text field block in haml' do
|
1011
1011
|
visit '/haml/form_for'
|
1012
1012
|
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1013
1013
|
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1014
1014
|
end
|
1015
1015
|
|
1016
|
-
should
|
1016
|
+
it 'should display correct text field block in erb' do
|
1017
1017
|
visit '/erb/form_for'
|
1018
1018
|
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1019
1019
|
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1020
1020
|
end
|
1021
1021
|
|
1022
|
-
should
|
1022
|
+
it 'should display correct text field block in slim' do
|
1023
1023
|
visit '/slim/form_for'
|
1024
1024
|
assert_have_selector '#demo2 p label', :for => 'markup_user_username', :content => "Nickname: ", :class => 'label'
|
1025
1025
|
assert_have_selector '#demo2 p input', :type => 'text', :name => 'markup_user[username]', :id => 'markup_user_username'
|
1026
1026
|
end
|
1027
1027
|
end
|
1028
1028
|
|
1029
|
-
|
1030
|
-
should
|
1029
|
+
describe 'for #text_area_block method' do
|
1030
|
+
it 'should display correct text area block html' do
|
1031
1031
|
actual_html = standard_builder.text_area_block(:about, :class => 'large', :caption => "About Me")
|
1032
1032
|
assert_has_tag('p label', :for => 'user_about', :content => "About Me") { actual_html }
|
1033
1033
|
assert_has_tag('p textarea', :id => 'user_about', :name => 'user[about]') { actual_html }
|
1034
1034
|
end
|
1035
1035
|
|
1036
|
-
should
|
1036
|
+
it 'should display correct text area block in haml' do
|
1037
1037
|
visit '/haml/form_for'
|
1038
1038
|
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1039
1039
|
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1040
1040
|
end
|
1041
1041
|
|
1042
|
-
should
|
1042
|
+
it 'should display correct text area block in erb' do
|
1043
1043
|
visit '/erb/form_for'
|
1044
1044
|
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1045
1045
|
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1046
1046
|
end
|
1047
1047
|
|
1048
|
-
should
|
1048
|
+
it 'should display correct text area block in slim' do
|
1049
1049
|
visit '/slim/form_for'
|
1050
1050
|
assert_have_selector '#demo2 p label', :for => 'markup_user_about', :content => "About: "
|
1051
1051
|
assert_have_selector '#demo2 p textarea', :name => 'markup_user[about]', :id => 'markup_user_about'
|
1052
1052
|
end
|
1053
1053
|
end
|
1054
1054
|
|
1055
|
-
|
1056
|
-
should
|
1055
|
+
describe 'for #password_field_block method' do
|
1056
|
+
it 'should display correct password field block html' do
|
1057
1057
|
actual_html = standard_builder.password_field_block(:keycode, :class => 'large', :caption => "Code: ")
|
1058
1058
|
assert_has_tag('p label', :for => 'user_keycode', :content => "Code: ") { actual_html }
|
1059
1059
|
assert_has_tag('p input.large[type=password]', :id => 'user_keycode', :name => 'user[keycode]') { actual_html }
|
1060
1060
|
end
|
1061
1061
|
|
1062
|
-
should
|
1062
|
+
it 'should display correct password field block in haml' do
|
1063
1063
|
visit '/haml/form_for'
|
1064
1064
|
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1065
1065
|
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1066
1066
|
end
|
1067
1067
|
|
1068
|
-
should
|
1068
|
+
it 'should display correct password field block in erb' do
|
1069
1069
|
visit '/erb/form_for'
|
1070
1070
|
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1071
1071
|
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1072
1072
|
end
|
1073
1073
|
|
1074
|
-
should
|
1074
|
+
it 'should display correct password field block in slim' do
|
1075
1075
|
visit '/slim/form_for'
|
1076
1076
|
assert_have_selector '#demo2 p label', :for => 'markup_user_code', :content => "Code: "
|
1077
1077
|
assert_have_selector '#demo2 p input', :type => 'password', :name => 'markup_user[code]', :id => 'markup_user_code'
|
1078
1078
|
end
|
1079
1079
|
end
|
1080
1080
|
|
1081
|
-
|
1082
|
-
should
|
1081
|
+
describe 'for #file_field_block method' do
|
1082
|
+
it 'should display correct file field block html' do
|
1083
1083
|
actual_html = standard_builder.file_field_block(:photo, :class => 'large', :caption => "Photo: ")
|
1084
1084
|
assert_has_tag('p label', :for => 'user_photo', :content => "Photo: ") { actual_html }
|
1085
1085
|
assert_has_tag('p input.large[type=file]', :id => 'user_photo', :name => 'user[photo]') { actual_html }
|
1086
1086
|
end
|
1087
1087
|
|
1088
|
-
should
|
1088
|
+
it 'should display correct file field block in haml' do
|
1089
1089
|
visit '/haml/form_for'
|
1090
1090
|
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1091
1091
|
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1092
1092
|
end
|
1093
1093
|
|
1094
|
-
should
|
1094
|
+
it 'should display correct file field block in erb' do
|
1095
1095
|
visit '/erb/form_for'
|
1096
1096
|
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1097
1097
|
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1098
1098
|
end
|
1099
1099
|
|
1100
|
-
should
|
1100
|
+
it 'should display correct file field block in slim' do
|
1101
1101
|
visit '/slim/form_for'
|
1102
1102
|
assert_have_selector '#demo2 p label', :for => 'markup_user_photo', :content => "Photo: "
|
1103
1103
|
assert_have_selector '#demo2 p input.upload', :type => 'file', :name => 'markup_user[photo]', :id => 'markup_user_photo'
|
1104
1104
|
end
|
1105
1105
|
end
|
1106
1106
|
|
1107
|
-
|
1108
|
-
should
|
1107
|
+
describe 'for #check_box_block method' do
|
1108
|
+
it 'should display correct check box block html' do
|
1109
1109
|
actual_html = standard_builder.check_box_block(:remember_me, :class => 'large', :caption => "Remember session?")
|
1110
1110
|
assert_has_tag('p label', :for => 'user_remember_me', :content => "Remember session?") { actual_html }
|
1111
1111
|
assert_has_tag('p input.large[type=checkbox]', :id => 'user_remember_me', :name => 'user[remember_me]') { actual_html }
|
1112
1112
|
end
|
1113
1113
|
|
1114
|
-
should
|
1114
|
+
it 'should display correct check box block in haml' do
|
1115
1115
|
visit '/haml/form_for'
|
1116
1116
|
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1117
1117
|
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1118
1118
|
end
|
1119
1119
|
|
1120
|
-
should
|
1120
|
+
it 'should display correct check box block in erb' do
|
1121
1121
|
visit '/erb/form_for'
|
1122
1122
|
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1123
1123
|
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1124
1124
|
end
|
1125
1125
|
|
1126
|
-
should
|
1126
|
+
it 'should display correct check box block in slim' do
|
1127
1127
|
visit '/slim/form_for'
|
1128
1128
|
assert_have_selector '#demo2 p label', :for => 'markup_user_remember_me', :content => "Remember me: "
|
1129
1129
|
assert_have_selector '#demo2 p input.checker', :type => 'checkbox', :name => 'markup_user[remember_me]'
|
1130
1130
|
end
|
1131
1131
|
end
|
1132
1132
|
|
1133
|
-
|
1134
|
-
should
|
1133
|
+
describe 'for #select_block method' do
|
1134
|
+
it 'should display correct select_block block html' do
|
1135
1135
|
actual_html = standard_builder.select_block(:country, :options => ['USA', 'Canada'], :class => 'large', :caption => "Your country")
|
1136
1136
|
assert_has_tag('p label', :for => 'user_country', :content => "Your country") { actual_html }
|
1137
1137
|
assert_has_tag('p select', :id => 'user_country', :name => 'user[country]') { actual_html }
|
@@ -1139,7 +1139,7 @@ describe "FormBuilder" do
|
|
1139
1139
|
assert_has_tag('p select option', :content => 'Canada') { actual_html }
|
1140
1140
|
end
|
1141
1141
|
|
1142
|
-
should
|
1142
|
+
it 'should display correct select_block block in haml' do
|
1143
1143
|
visit '/haml/form_for'
|
1144
1144
|
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1145
1145
|
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
@@ -1147,57 +1147,57 @@ describe "FormBuilder" do
|
|
1147
1147
|
assert_have_selector '#demo2 p select option', :content => 'Texas'
|
1148
1148
|
end
|
1149
1149
|
|
1150
|
-
should
|
1150
|
+
it 'should display correct select_block block in erb' do
|
1151
1151
|
visit '/erb/form_for'
|
1152
1152
|
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1153
1153
|
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1154
1154
|
end
|
1155
1155
|
|
1156
|
-
should
|
1156
|
+
it 'should display correct select_block block in slim' do
|
1157
1157
|
visit '/slim/form_for'
|
1158
1158
|
assert_have_selector '#demo2 p label', :for => 'markup_user_state', :content => "State: "
|
1159
1159
|
assert_have_selector '#demo2 p select', :name => 'markup_user[state]', :id => 'markup_user_state'
|
1160
1160
|
end
|
1161
1161
|
end
|
1162
1162
|
|
1163
|
-
|
1164
|
-
should
|
1163
|
+
describe 'for #submit_block method' do
|
1164
|
+
it 'should display correct submit block html' do
|
1165
1165
|
actual_html = standard_builder.submit_block("Update", :class => 'large')
|
1166
1166
|
assert_has_tag('p input.large[type=submit]', :value => 'Update') { actual_html }
|
1167
1167
|
end
|
1168
1168
|
|
1169
|
-
should
|
1169
|
+
it 'should display correct submit block in haml' do
|
1170
1170
|
visit '/haml/form_for'
|
1171
1171
|
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1172
1172
|
end
|
1173
1173
|
|
1174
|
-
should
|
1174
|
+
it 'should display correct submit block in erb' do
|
1175
1175
|
visit '/erb/form_for'
|
1176
1176
|
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1177
1177
|
end
|
1178
1178
|
|
1179
|
-
should
|
1179
|
+
it 'should display correct submit block in slim' do
|
1180
1180
|
visit '/slim/form_for'
|
1181
1181
|
assert_have_selector '#demo2 p input', :type => 'submit', :class => 'button'
|
1182
1182
|
end
|
1183
1183
|
end
|
1184
1184
|
|
1185
|
-
|
1186
|
-
|
1185
|
+
describe 'for #image_submit_block method' do
|
1186
|
+
before do
|
1187
1187
|
@stamp = stop_time_for_test.to_i
|
1188
1188
|
end
|
1189
1189
|
|
1190
|
-
should
|
1190
|
+
it 'should display correct image submit block html' do
|
1191
1191
|
actual_html = standard_builder.image_submit_block("buttons/ok.png", :class => 'large')
|
1192
1192
|
assert_has_tag('p input.large[type=image]', :src => "/images/buttons/ok.png?#{@stamp}") { actual_html }
|
1193
1193
|
end
|
1194
1194
|
|
1195
|
-
should
|
1195
|
+
it 'should display correct image submit block in haml' do
|
1196
1196
|
visit '/haml/form_for'
|
1197
1197
|
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1198
1198
|
end
|
1199
1199
|
|
1200
|
-
should
|
1200
|
+
it 'should display correct image submit block in slim' do
|
1201
1201
|
visit '/slim/form_for'
|
1202
1202
|
assert_have_selector '#demo2 p input', :type => 'image', :class => 'image', :src => "/images/buttons/ok.png?#{@stamp}"
|
1203
1203
|
end
|