Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #25 from wwidea/master

double digit months formatted wrong in default table_id
  • Loading branch information...
commit 763a497dbd8833b98d92815667b367ade938c00c 2 parents eca0c9b + 6028954
@topfunky authored
Showing with 7 additions and 2 deletions.
  1. +1 −1  lib/calendar_helper.rb
  2. +6 −1 test/test_calendar_helper.rb
View
2  lib/calendar_helper.rb
@@ -82,7 +82,7 @@ def calendar(options = {}, &block)
month_names = (!defined?(I18n) || I18n.t("date.month_names").include?("missing")) ? Date::MONTHNAMES.dup : I18n.t("date.month_names")
defaults = {
- :table_id => "calendar-#{options[:year]}-#{"0%d" % options[:month]}",
+ :table_id => "calendar-#{options[:year]}-#{"%02d" % options[:month]}",
:table_class => 'calendar',
:month_name_class => 'monthName',
:other_month_class => 'otherMonth',
View
7 test/test_calendar_helper.rb
@@ -109,11 +109,16 @@ def test_custom_summary_attribute
assert_match %r{<table [^>]*summary="TEST SUMMARY">}, html
end
- def test_table_id_defaults_calendar_year_month
+ def test_table_id_defaults_calendar_year_single_digit_month
html = calendar_with_defaults(:year => 1967, :month => 4)
assert_match %r{<table [^>]*id="calendar-1967-04"}, html
end
+ def test_table_id_defaults_calendar_year_double_digit_month
+ html = calendar_with_defaults(:year => 1967, :month => 12)
+ assert_match %r{<table [^>]*id="calendar-1967-12"}, html
+ end
+
def test_custom_table_id
html = calendar_with_defaults(:year => 1967, :month => 4, :table_id => 'test-the-id')
assert_match %r{<table [^>]*id="test-the-id"}, html
Please sign in to comment.
Something went wrong with that request. Please try again.