mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed that much of DateHelper wouldn't return html_safe? strings [DHH]
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*Edge*
|
||||
|
||||
* Fixed that much of DateHelper wouldn't return html_safe? strings [DHH]
|
||||
|
||||
* Fixed that fragment caching should return a cache hit as html_safe (or it would all just get escaped) [DHH]
|
||||
|
||||
* Added :alert, :notice, and :flash as options to ActionController::Base#redirect_to that'll automatically set the proper flash before the redirection [DHH]. Examples:
|
||||
|
||||
@@ -616,7 +616,7 @@ module ActionView
|
||||
|
||||
build_selects_from_types(order)
|
||||
else
|
||||
"#{select_date}#{@options[:datetime_separator]}#{select_time}"
|
||||
"#{select_date}#{@options[:datetime_separator]}#{select_time}".html_safe!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -835,7 +835,7 @@ module ActionView
|
||||
select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
|
||||
select_html << select_options_as_html.to_s
|
||||
|
||||
content_tag(:select, select_html, select_options) + "\n"
|
||||
(content_tag(:select, select_html, select_options) + "\n").html_safe!
|
||||
end
|
||||
|
||||
# Builds a prompt option tag with supplied options or from default options
|
||||
@@ -860,12 +860,12 @@ module ActionView
|
||||
# build_hidden(:year, 2008)
|
||||
# => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
|
||||
def build_hidden(type, value)
|
||||
tag(:input, {
|
||||
(tag(:input, {
|
||||
:type => "hidden",
|
||||
:id => input_id_from_type(type),
|
||||
:name => input_name_from_type(type),
|
||||
:value => value
|
||||
}) + "\n"
|
||||
}) + "\n").html_safe!
|
||||
end
|
||||
|
||||
# Returns the name attribute for the input tag
|
||||
@@ -896,7 +896,7 @@ module ActionView
|
||||
separator = separator(type) unless type == order.first # don't add on last field
|
||||
select.insert(0, separator.to_s + send("select_#{type}").to_s)
|
||||
end
|
||||
select
|
||||
select.html_safe!
|
||||
end
|
||||
|
||||
# Returns the separator for a given datetime component
|
||||
|
||||
@@ -2475,6 +2475,28 @@ class DateHelperTest < ActionView::TestCase
|
||||
}, options)
|
||||
end
|
||||
|
||||
def test_select_html_safety
|
||||
assert select_day(16).html_safe?
|
||||
assert select_month(8).html_safe?
|
||||
assert select_year(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
||||
assert select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
||||
assert select_second(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe?
|
||||
|
||||
assert select_minute(8, :use_hidden => true).html_safe?
|
||||
assert select_month(8, :prompt => 'Choose month').html_safe?
|
||||
|
||||
assert select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector').html_safe?
|
||||
assert select_date(Time.mktime(2003, 8, 16), :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]").html_safe?
|
||||
end
|
||||
|
||||
def test_object_select_html_safety
|
||||
@post = Post.new
|
||||
@post.written_on = Date.new(2004, 6, 15)
|
||||
|
||||
assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe?
|
||||
assert time_select("post", "written_on", :ignore_date => true).html_safe?
|
||||
end
|
||||
|
||||
protected
|
||||
def with_env_tz(new_tz = 'US/Eastern')
|
||||
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
|
||||
|
||||
Reference in New Issue
Block a user