padrino-helpers 0.11.3 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +1 -1
- data/lib/padrino-helpers.rb +3 -5
- data/lib/padrino-helpers/asset_tag_helpers.rb +32 -40
- data/lib/padrino-helpers/breadcrumb_helpers.rb +21 -39
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +121 -118
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +6 -9
- data/lib/padrino-helpers/form_helpers.rb +190 -193
- data/lib/padrino-helpers/format_helpers.rb +29 -42
- data/lib/padrino-helpers/locale/cs.yml +14 -14
- data/lib/padrino-helpers/locale/da.yml +1 -1
- data/lib/padrino-helpers/locale/de.yml +1 -1
- data/lib/padrino-helpers/locale/en.yml +16 -16
- data/lib/padrino-helpers/locale/es.yml +16 -16
- data/lib/padrino-helpers/locale/fr.yml +1 -2
- data/lib/padrino-helpers/locale/hu.yml +16 -16
- data/lib/padrino-helpers/locale/it.yml +2 -2
- data/lib/padrino-helpers/locale/ja.yml +16 -16
- data/lib/padrino-helpers/locale/lv.yml +16 -16
- data/lib/padrino-helpers/locale/nl.yml +1 -1
- data/lib/padrino-helpers/locale/no.yml +1 -1
- data/lib/padrino-helpers/locale/pl.yml +7 -7
- data/lib/padrino-helpers/locale/pt_br.yml +16 -16
- data/lib/padrino-helpers/locale/ro.yml +16 -16
- data/lib/padrino-helpers/locale/ru.yml +16 -16
- data/lib/padrino-helpers/locale/sv.yml +16 -16
- data/lib/padrino-helpers/locale/tr.yml +16 -16
- data/lib/padrino-helpers/locale/uk.yml +16 -16
- data/lib/padrino-helpers/locale/zh_cn.yml +16 -16
- data/lib/padrino-helpers/locale/zh_tw.yml +16 -16
- data/lib/padrino-helpers/number_helpers.rb +10 -15
- data/lib/padrino-helpers/output_helpers.rb +49 -57
- data/lib/padrino-helpers/output_helpers/abstract_handler.rb +16 -18
- data/lib/padrino-helpers/output_helpers/erb_handler.rb +11 -12
- data/lib/padrino-helpers/output_helpers/haml_handler.rb +9 -9
- data/lib/padrino-helpers/output_helpers/slim_handler.rb +11 -13
- data/lib/padrino-helpers/render_helpers.rb +5 -6
- data/lib/padrino-helpers/tag_helpers.rb +18 -21
- data/lib/padrino-helpers/translation_helpers.rb +4 -6
- data/test/fixtures/markup_app/app.rb +7 -3
- data/test/fixtures/render_app/app.rb +1 -0
- data/test/test_asset_tag_helpers.rb +1 -1
- data/test/test_form_builder.rb +5 -6
- data/test/test_form_helpers.rb +24 -12
- data/test/test_format_helpers.rb +3 -3
- data/test/test_number_helpers.rb +4 -0
- data/test/test_output_helpers.rb +1 -1
- data/test/test_render_helpers.rb +1 -1
- data/test/test_tag_helpers.rb +1 -1
- metadata +9 -15
@@ -25,18 +25,19 @@ module Padrino
|
|
25
25
|
template.block_is_haml?(block)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
##
|
29
|
+
# Captures the html from a block of template code for this handler.
|
29
30
|
#
|
30
31
|
# @example
|
31
32
|
# @handler.capture_from_template(&block) => "...html..."
|
32
33
|
#
|
33
34
|
def capture_from_template(*args, &block)
|
34
|
-
eval("_hamlout ||= @haml_buffer", block.binding)
|
35
|
+
eval("_hamlout ||= @haml_buffer", block.binding)
|
35
36
|
template.capture_haml(*args, &block)
|
36
37
|
end
|
37
38
|
|
38
39
|
##
|
39
|
-
# Outputs the given text to the templates buffer directly
|
40
|
+
# Outputs the given text to the templates buffer directly.
|
40
41
|
#
|
41
42
|
# @example
|
42
43
|
# @handler.concat_to_template("This will be output to the template buffer")
|
@@ -47,7 +48,7 @@ module Padrino
|
|
47
48
|
end
|
48
49
|
|
49
50
|
##
|
50
|
-
# Returns an array of engines used for the template
|
51
|
+
# Returns an array of engines used for the template.
|
51
52
|
#
|
52
53
|
# @example
|
53
54
|
# @handler.engines => [:haml]
|
@@ -55,9 +56,8 @@ module Padrino
|
|
55
56
|
def engines
|
56
57
|
@_engines ||= [:haml]
|
57
58
|
end
|
58
|
-
end
|
59
|
-
|
59
|
+
end
|
60
60
|
OutputHelpers.register(HamlHandler)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# Make slim works with sinatra/padrino
|
2
|
-
|
3
1
|
module Padrino
|
4
2
|
module Helpers
|
5
3
|
module OutputHelpers
|
@@ -24,7 +22,8 @@ module Padrino
|
|
24
22
|
!self.output_buffer.nil?
|
25
23
|
end
|
26
24
|
|
27
|
-
|
25
|
+
##
|
26
|
+
# Captures the html from a block of template code for this handler.
|
28
27
|
#
|
29
28
|
# @example
|
30
29
|
# @handler.capture_from_template(&block) => "...html..."
|
@@ -38,7 +37,7 @@ module Padrino
|
|
38
37
|
end
|
39
38
|
|
40
39
|
##
|
41
|
-
# Outputs the given text to the templates buffer directly
|
40
|
+
# Outputs the given text to the templates buffer directly.
|
42
41
|
#
|
43
42
|
# @example
|
44
43
|
# @handler.concat_to_template("This will be output to the template buffer")
|
@@ -59,7 +58,7 @@ module Padrino
|
|
59
58
|
end
|
60
59
|
|
61
60
|
##
|
62
|
-
# Returns an array of engines used for the template
|
61
|
+
# Returns an array of engines used for the template.
|
63
62
|
#
|
64
63
|
# @example
|
65
64
|
# @handler.engines => [:erb, :erubis]
|
@@ -69,12 +68,11 @@ module Padrino
|
|
69
68
|
end
|
70
69
|
|
71
70
|
protected
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
|
71
|
+
def output_buffer=(val)
|
72
|
+
template.instance_variable_set(:@_out_buf, val)
|
73
|
+
end
|
74
|
+
end
|
77
75
|
OutputHelpers.register(SlimHandler)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -5,7 +5,7 @@ module Padrino
|
|
5
5
|
#
|
6
6
|
module RenderHelpers
|
7
7
|
##
|
8
|
-
# Render a partials with collections support
|
8
|
+
# Render a partials with collections support.
|
9
9
|
#
|
10
10
|
# @param [String] template
|
11
11
|
# Relative path to partial template.
|
@@ -18,7 +18,7 @@ module Padrino
|
|
18
18
|
# @option options [Hash] :locals ({})
|
19
19
|
# Local variables accessible in the partial.
|
20
20
|
# @option options [Symbol] :engine
|
21
|
-
# Explicit rendering engine to use for this partial
|
21
|
+
# Explicit rendering engine to use for this partial.
|
22
22
|
#
|
23
23
|
# @return [String] The html generated from this partial.
|
24
24
|
#
|
@@ -30,7 +30,6 @@ module Padrino
|
|
30
30
|
#
|
31
31
|
# @note If using this from Sinatra, pass explicit +:engine+ option
|
32
32
|
#
|
33
|
-
# @api public
|
34
33
|
def partial(template, options={})
|
35
34
|
options.reverse_merge!(:locals => {}, :layout => false)
|
36
35
|
path = template.to_s.split(File::SEPARATOR)
|
@@ -55,6 +54,6 @@ module Padrino
|
|
55
54
|
end
|
56
55
|
end
|
57
56
|
alias :render_partial :partial
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -5,7 +5,7 @@ module Padrino
|
|
5
5
|
#
|
6
6
|
module TagHelpers
|
7
7
|
##
|
8
|
-
# Tag values escaped to html entities
|
8
|
+
# Tag values escaped to html entities.
|
9
9
|
#
|
10
10
|
ESCAPE_VALUES = {
|
11
11
|
"&" => "&",
|
@@ -62,13 +62,13 @@ module Padrino
|
|
62
62
|
NEWLINE = "\n".html_safe.freeze
|
63
63
|
|
64
64
|
##
|
65
|
-
# Creates an HTML tag with given name, content, and options
|
65
|
+
# Creates an HTML tag with given name, content, and options.
|
66
66
|
#
|
67
67
|
# @overload content_tag(name, content, options = nil)
|
68
68
|
# @param [Symbol] name
|
69
69
|
# The name of the HTML tag to create.
|
70
70
|
# @param [String] content
|
71
|
-
# The content inside of the
|
71
|
+
# The content inside of the tag.
|
72
72
|
# @param [Hash] options
|
73
73
|
# The HTML options to include in this tag.
|
74
74
|
#
|
@@ -99,7 +99,7 @@ module Padrino
|
|
99
99
|
# Specifies whether or not the element is editable.
|
100
100
|
#
|
101
101
|
# @return [String]
|
102
|
-
# Generated HTML with specified +options
|
102
|
+
# Generated HTML with specified +options+.
|
103
103
|
#
|
104
104
|
# @example
|
105
105
|
# content_tag(:p, 'Hello World', :class => 'light')
|
@@ -116,7 +116,6 @@ module Padrino
|
|
116
116
|
# # => <a href="http://www.padrinorb.com">Padrino</a>
|
117
117
|
# # => </p>
|
118
118
|
#
|
119
|
-
# @api public
|
120
119
|
def content_tag(name, content = nil, options = nil, &block)
|
121
120
|
if block_given?
|
122
121
|
options = content if content.is_a?(Hash)
|
@@ -139,7 +138,7 @@ module Padrino
|
|
139
138
|
|
140
139
|
##
|
141
140
|
# Like #content_tag, but assumes its input to be safe and doesn't
|
142
|
-
# escape. It also returns safe
|
141
|
+
# escape. It also returns safe HTML.
|
143
142
|
#
|
144
143
|
# @see #content_tag
|
145
144
|
#
|
@@ -148,7 +147,7 @@ module Padrino
|
|
148
147
|
end
|
149
148
|
|
150
149
|
##
|
151
|
-
# Creates an HTML input field with the given type and options
|
150
|
+
# Creates an HTML input field with the given type and options.
|
152
151
|
#
|
153
152
|
# @param [Symbol] type
|
154
153
|
# The type of input to create.
|
@@ -178,14 +177,14 @@ module Padrino
|
|
178
177
|
# @option options [Boolean] :autofocus
|
179
178
|
# Specifies whether or not the input should automatically get focus when the page loads.
|
180
179
|
# @option options [Boolean] :required
|
181
|
-
# Specifies whether or not the input is required to be
|
180
|
+
# Specifies whether or not the input is required to be completed before the form is submitted.
|
182
181
|
# @option options [Boolean] :readonly
|
183
182
|
# Specifies whether or not the input is read only.
|
184
183
|
# @option options [Boolean] :disabled
|
185
184
|
# Specifies whether or not the input is disabled.
|
186
185
|
#
|
187
186
|
# @return [String]
|
188
|
-
# Generated HTML with specified +options
|
187
|
+
# Generated HTML with specified +options+.
|
189
188
|
#
|
190
189
|
# @example
|
191
190
|
# input_tag :text, :name => 'handle'
|
@@ -200,13 +199,12 @@ module Padrino
|
|
200
199
|
# input_tag :number, :name => 'credit_card', :autocomplete => :off
|
201
200
|
# # => <input type="number" autocomplete="off" />
|
202
201
|
#
|
203
|
-
# @api semipublic
|
204
202
|
def input_tag(type, options = {})
|
205
203
|
tag(:input, options.reverse_merge!(:type => type))
|
206
204
|
end
|
207
205
|
|
208
206
|
##
|
209
|
-
# Creates an HTML tag with the given name and options
|
207
|
+
# Creates an HTML tag with the given name and options.
|
210
208
|
#
|
211
209
|
# @param [Symbol] name
|
212
210
|
# The name of the HTML tag to create.
|
@@ -216,7 +214,7 @@ module Padrino
|
|
216
214
|
# @macro global_html_attributes
|
217
215
|
#
|
218
216
|
# @return [String]
|
219
|
-
# Generated HTML with specified +options
|
217
|
+
# Generated HTML with specified +options+.
|
220
218
|
#
|
221
219
|
# @example
|
222
220
|
# tag :hr, :class => 'dotted'
|
@@ -231,7 +229,6 @@ module Padrino
|
|
231
229
|
# tag :img, :src => 'sinatra.jpg, :data => { :nsfw => false, :geo => [34.087, -118.407] }
|
232
230
|
# # => <img src="sinatra.jpg" data-nsfw="false" data-geo="34.087 -118.407" />
|
233
231
|
#
|
234
|
-
# @api public
|
235
232
|
def tag(name, options = nil, open = false)
|
236
233
|
options = parse_data_options(name, options)
|
237
234
|
attributes = tag_attributes(options)
|
@@ -240,8 +237,8 @@ module Padrino
|
|
240
237
|
|
241
238
|
private
|
242
239
|
##
|
243
|
-
# Returns a compiled list of HTML attributes
|
244
|
-
|
240
|
+
# Returns a compiled list of HTML attributes.
|
241
|
+
#
|
245
242
|
def tag_attributes(options)
|
246
243
|
return '' if options.nil?
|
247
244
|
attributes = options.map do |k, v|
|
@@ -259,13 +256,13 @@ module Padrino
|
|
259
256
|
|
260
257
|
##
|
261
258
|
# Escape tag values to their HTML/XML entities.
|
262
|
-
|
259
|
+
#
|
263
260
|
def escape_value(string)
|
264
261
|
string.to_s.gsub(ESCAPE_REGEXP) { |c| ESCAPE_VALUES[c] }
|
265
262
|
end
|
266
263
|
|
267
264
|
##
|
268
|
-
# Iterate through nested values
|
265
|
+
# Iterate through nested values.
|
269
266
|
#
|
270
267
|
def nested_values(attribute, hash)
|
271
268
|
hash.map do |k, v|
|
@@ -278,7 +275,7 @@ module Padrino
|
|
278
275
|
end
|
279
276
|
|
280
277
|
##
|
281
|
-
# Parses custom data attributes
|
278
|
+
# Parses custom data attributes.
|
282
279
|
#
|
283
280
|
def parse_data_options(tag, options)
|
284
281
|
return if options.nil?
|
@@ -290,6 +287,6 @@ module Padrino
|
|
290
287
|
end
|
291
288
|
parsed_options
|
292
289
|
end
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Padrino
|
2
2
|
module Helpers
|
3
3
|
##
|
4
|
-
# Helpers related to
|
4
|
+
# Helpers related to locale i18n translation within templates.
|
5
5
|
#
|
6
6
|
module TranslationHelpers
|
7
7
|
##
|
@@ -13,7 +13,6 @@ module Padrino
|
|
13
13
|
# @return [String]
|
14
14
|
# The translation for the specified keys.
|
15
15
|
#
|
16
|
-
# @api public
|
17
16
|
def translate(*args)
|
18
17
|
I18n.translate(*args)
|
19
18
|
end
|
@@ -28,11 +27,10 @@ module Padrino
|
|
28
27
|
# @return [String]
|
29
28
|
# The translation for the specified keys.
|
30
29
|
#
|
31
|
-
# @api public
|
32
30
|
def localize(*args)
|
33
31
|
I18n.localize(*args)
|
34
32
|
end
|
35
33
|
alias :l :localize
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -10,11 +10,15 @@ class MarkupDemo < Sinatra::Base
|
|
10
10
|
register Padrino::Helpers
|
11
11
|
|
12
12
|
configure do
|
13
|
+
set :logging, false
|
14
|
+
set :padrino_logging, false
|
15
|
+
set :environment, :test
|
13
16
|
set :root, File.dirname(__FILE__)
|
14
17
|
set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
|
15
18
|
set :haml, :escape_html => true
|
16
|
-
set :slim, :generator => Temple::Generators::RailsOutputBuffer,
|
17
|
-
|
19
|
+
set :slim, :generator => Temple::Generators::RailsOutputBuffer, :buffer => "out_buf"
|
20
|
+
set :sessions, true
|
21
|
+
set :protect_from_csrf, true
|
18
22
|
end
|
19
23
|
|
20
24
|
get '/:engine/:file' do
|
@@ -50,7 +54,7 @@ class MarkupDemo < Sinatra::Base
|
|
50
54
|
end
|
51
55
|
|
52
56
|
class MarkupUser
|
53
|
-
def errors; { :fake => "must be valid", :second => "must be present", :third => "must be a number", :email => "must be
|
57
|
+
def errors; { :fake => "must be valid", :second => "must be present", :third => "must be a number", :email => "must be an email"}; end
|
54
58
|
def session_id; 45; end
|
55
59
|
def gender; 'male'; end
|
56
60
|
def remember_me; '1'; end
|
@@ -16,6 +16,7 @@ class RenderDemo < Padrino::Application
|
|
16
16
|
configure do
|
17
17
|
set :logging, false
|
18
18
|
set :padrino_logging, false
|
19
|
+
set :environment, :test
|
19
20
|
set :erb, :engine_class => Padrino::Erubis::SafeBufferTemplate
|
20
21
|
set :haml, :escape_html => true
|
21
22
|
set :slim, :generator => Temple::Generators::RailsOutputBuffer
|
data/test/test_form_builder.rb
CHANGED
@@ -4,6 +4,10 @@ require File.expand_path(File.dirname(__FILE__) + '/fixtures/markup_app/app')
|
|
4
4
|
describe "FormBuilder" do
|
5
5
|
include Padrino::Helpers::FormHelpers
|
6
6
|
|
7
|
+
def app
|
8
|
+
MarkupDemo
|
9
|
+
end
|
10
|
+
|
7
11
|
# Dummy form builder for testing
|
8
12
|
module Padrino::Helpers::FormBuilder
|
9
13
|
class FakeFormBuilder < AbstractFormBuilder
|
@@ -11,10 +15,6 @@ describe "FormBuilder" do
|
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
|
-
def app
|
15
|
-
MarkupDemo.tap { |app| app.set :environment, :test }
|
16
|
-
end
|
17
|
-
|
18
18
|
def setup
|
19
19
|
role_types = [mock_model('Role', :name => "Admin", :id => 1),
|
20
20
|
mock_model('Role', :name => 'Moderate', :id => 2), mock_model('Role', :name => 'Limited', :id => 3)]
|
@@ -49,8 +49,7 @@ describe "FormBuilder" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
should "display form specifying default builder setting" do
|
52
|
-
self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder')).
|
53
|
-
actual_html = ""
|
52
|
+
self.expects(:settings).returns(stub(:default_builder => 'FakeFormBuilder', :protect_from_csrf => false)).at_least_once
|
54
53
|
actual_html = form_for(@user, '/register', :id => 'register', :"accept-charset" => "UTF-8", :method => 'post') { |f| f.foo_field }
|
55
54
|
assert_has_tag('form', :"accept-charset" => "UTF-8", :action => '/register', :method => 'post') { actual_html }
|
56
55
|
assert_has_tag('span', :content => "bar") { actual_html }
|
data/test/test_form_helpers.rb
CHANGED
@@ -5,12 +5,14 @@ describe "FormHelpers" do
|
|
5
5
|
include Padrino::Helpers::FormHelpers
|
6
6
|
|
7
7
|
def app
|
8
|
-
MarkupDemo
|
8
|
+
MarkupDemo
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
class UnprotectedApp
|
12
|
+
def protect_from_csrf; false; end
|
13
|
+
end
|
13
14
|
|
15
|
+
context 'for #form_tag method' do
|
14
16
|
should "display correct forms in ruby" do
|
15
17
|
actual_html = form_tag('/register', :"accept-charset" => "UTF-8", :class => 'test', :method => "post") { "Demo" }
|
16
18
|
assert_has_tag(:form, :"accept-charset" => "UTF-8", :class => "test") { actual_html }
|
@@ -73,19 +75,24 @@ describe "FormHelpers" do
|
|
73
75
|
assert_has_tag(:input, :name => 'authenticity_token') { actual_html }
|
74
76
|
end
|
75
77
|
|
76
|
-
should "
|
77
|
-
actual_html =
|
78
|
-
|
78
|
+
should "create csrf meta tags with token and param - #csrf_meta_tags" do
|
79
|
+
actual_html = csrf_meta_tags
|
80
|
+
assert_has_tag(:meta, :name => 'csrf-param') { actual_html }
|
81
|
+
assert_has_tag(:meta, :name => 'csrf-token') { actual_html }
|
79
82
|
end
|
80
83
|
|
81
|
-
should "have an authenticity_token
|
82
|
-
app.set :protect_from_csrf, nil
|
84
|
+
should "have an authenticity_token by default" do
|
83
85
|
actual_html = form_tag('/superadmindelete') { "Demo" }
|
84
86
|
assert_has_tag(:input, :name => 'authenticity_token') { actual_html }
|
85
87
|
end
|
86
88
|
|
89
|
+
should "not have an authenticity_token if passing protect_from_csrf: false" do
|
90
|
+
actual_html = form_tag('/superadmindelete', :protect_from_csrf => false) { "Demo" }
|
91
|
+
assert_has_no_tag(:input, :name => 'authenticity_token') { actual_html }
|
92
|
+
end
|
93
|
+
|
87
94
|
should "not have an authenticity_token if protect_from_csrf is false on app settings" do
|
88
|
-
|
95
|
+
self.expects(:settings).returns(UnprotectedApp.new)
|
89
96
|
actual_html = form_tag('/superadmindelete') { "Demo" }
|
90
97
|
assert_has_no_tag(:input, :name => 'authenticity_token') { actual_html }
|
91
98
|
end
|
@@ -166,7 +173,7 @@ describe "FormHelpers" do
|
|
166
173
|
assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
|
167
174
|
assert_have_selector 'form.advanced-form .field-errors ul'
|
168
175
|
assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
|
169
|
-
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be
|
176
|
+
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
|
170
177
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
|
171
178
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
|
172
179
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
|
@@ -180,7 +187,7 @@ describe "FormHelpers" do
|
|
180
187
|
assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
|
181
188
|
assert_have_selector 'form.advanced-form .field-errors ul'
|
182
189
|
assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
|
183
|
-
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be
|
190
|
+
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
|
184
191
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
|
185
192
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
|
186
193
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
|
@@ -194,7 +201,7 @@ describe "FormHelpers" do
|
|
194
201
|
assert_have_selector 'form.advanced-form .field-errors p', :content => "There were problems with the following fields:"
|
195
202
|
assert_have_selector 'form.advanced-form .field-errors ul'
|
196
203
|
assert_have_selector 'form.advanced-form .field-errors ul li', :count => 4
|
197
|
-
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be
|
204
|
+
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Email must be an email"
|
198
205
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Fake must be valid"
|
199
206
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Second must be present"
|
200
207
|
assert_have_selector 'form.advanced-form .field-errors ul li', :content => "Third must be a number"
|
@@ -961,6 +968,11 @@ describe "FormHelpers" do
|
|
961
968
|
assert_has_tag('form button', :type => 'submit', :content => "My button's content", :title => "My button") { actual_html }
|
962
969
|
end
|
963
970
|
|
971
|
+
should "pass options on submit button when submit_options are given" do
|
972
|
+
actual_html = button_to("Fancy button", '/users/1', :submit_options => { :class => :fancy })
|
973
|
+
assert_has_tag('form input', :type => 'submit', :value => 'Fancy button', :class => 'fancy') { actual_html }
|
974
|
+
end
|
975
|
+
|
964
976
|
should 'display correct button_to in erb' do
|
965
977
|
visit '/erb/button_to'
|
966
978
|
assert_have_selector('form', :action => '/foo')
|