aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorLiborio Cannici <lic@crd.dk>2011-09-15 00:35:53 +0200
committerJeremy Kemper <jeremy@bitsweat.net>2011-10-08 18:02:15 -0700
commit114218e4da9a2adf7b6ef4a27d2fa47e15881cf1 (patch)
treee6040f8874b89e2eee894f1cb96bcb611ff633d4 /actionpack/test/template
parentf655895e87c8e013caac649986510eff4d3b03d9 (diff)
downloadrails-114218e4da9a2adf7b6ef4a27d2fa47e15881cf1.tar.gz
rails-114218e4da9a2adf7b6ef4a27d2fa47e15881cf1.tar.bz2
rails-114218e4da9a2adf7b6ef4a27d2fa47e15881cf1.zip
Fixes an issue when creating a date select with too many options.
Inspired by dlt https://github.com/dlt/rails/commit/9e615634745dc81598e7b880d52411338d3a7a93 Closes #239. Conflicts: actionpack/CHANGELOG
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/date_helper_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 09c53a36f0..af30ec9892 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -664,6 +664,15 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]")
end
+ def test_select_date_with_too_big_range_between_start_year_and_end_year
+ assert_raise(ArgumentError) { select_date(Time.mktime(2003, 8, 16), :start_year => 2000, :end_year => 20000, :prefix => "date[first]", :order => [:month, :day, :year]) }
+ assert_raise(ArgumentError) { select_date(Time.mktime(2003, 8, 16), :start_year => Date.today.year - 100.years, :end_year => 2000, :prefix => "date[first]", :order => [:month, :day, :year]) }
+ end
+
+ def test_select_date_can_have_more_then_1000_years_interval_if_forced_via_parameter
+ assert_nothing_raised { select_date(Time.mktime(2003, 8, 16), :start_year => 2000, :end_year => 3100, :max_years_allowed => 2000) }
+ end
+
def test_select_date_with_order
expected = %(<select id="date_first_month" name="date[first][month]">\n)
expected << %(<option value="1">January</option>\n<option value="2">February</option>\n<option value="3">March</option>\n<option value="4">April</option>\n<option value="5">May</option>\n<option value="6">June</option>\n<option value="7">July</option>\n<option value="8" selected="selected">August</option>\n<option value="9">September</option>\n<option value="10">October</option>\n<option value="11">November</option>\n<option value="12">December</option>\n)