Initial import

This commit is contained in:
2008-03-02 16:04:34 -03:00
commit 5e4951fa47
798 changed files with 59730 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<html>
<head>
<title>Stylesheet Tester</title>
<link href="../generators/calendar_styles/templates/grey/style.css" media="screen" rel="Stylesheet" type="text/css" />
<style>
body, tr, td {
font-family: Verdana;
}
</style>
</head>
<body style="background-color: #eeeeee">
<table class="calendar" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr class="monthName">
<th colspan="7">April</th>
</tr>
<tr class="dayName">
<th>Mon</th> <th>Tue</th> <th>Wed</th> <th>Thu</th> <th>Fri</th> <th>Sat</th> <th>Sun</th> </tr>
</thead>
<tbody>
<tr> <td class="otherMonth">27</td> <td class="otherMonth">28</td> <td class="otherMonth">29</td> <td class="otherMonth">30</td> <td class="otherMonth">31</td> <td class="day weekendDay">1</td> <td class="day weekendDay">2</td> </tr>
<tr> <td class="day">3</td> <td class="day">4</td> <td class="day">5</td> <td class="day">6</td> <td class="day">7</td> <td class="day weekendDay">8</td> <td class="day weekendDay">9</td> </tr>
<tr> <td class="day">10</td> <td class="day">11</td> <td class="day">12</td> <td class="day">13</td> <td class="day">14</td> <td class="day weekendDay">15</td> <td class="day weekendDay">16</td> </tr>
<tr> <td class="day">17</td> <td class="day">18</td> <td class="day">19</td> <td class="day">20</td> <td class="day">21</td> <td class="day weekendDay">22</td> <td class="day weekendDay">23</td> </tr>
<tr> <td class="day">24</td> <td class="day">25</td> <td class="day">26</td> <td class="specialDay">27</td> <td class="day">28</td> <td class="day weekendDay">29</td> <td class="day weekendDay">30</td> </tr>
<tr> </tr>
</tbody>
</table>
</body>
</html>

View File

@@ -0,0 +1,85 @@
require 'test/unit'
require File.expand_path(File.dirname(__FILE__) + "/../lib/calendar_helper")
class CalendarHelperTest < Test::Unit::TestCase
include CalendarHelper
def test_simple
assert_match %r{August}, calendar_with_defaults
end
def test_required_fields
# Year and month are required
assert_raises(ArgumentError) {
calendar
}
assert_raises(ArgumentError) {
calendar :year => 1
}
assert_raises(ArgumentError) {
calendar :month => 1
}
end
def test_default_css_classes
# :other_month_class is not implemented yet
{ :table_class => "calendar",
:month_name_class => "monthName",
:day_name_class => "dayName",
:day_class => "day" }.each do |key, value|
assert_correct_css_class_for_default value
end
end
def test_custom_css_classes
# Uses the key name as the CSS class name
# :other_month_class is not implemented yet
[:table_class, :month_name_class, :day_name_class, :day_class].each do |key|
assert_correct_css_class_for_key key.to_s, key
end
end
def test_abbrev
assert_match %r{>Mon<}, calendar_with_defaults(:abbrev => (0..2))
assert_match %r{>M<}, calendar_with_defaults(:abbrev => (0..0))
assert_match %r{>Monday<}, calendar_with_defaults(:abbrev => (0..-1))
end
def test_block
# Even days are special
assert_match %r{class="special_day">2<}, calendar(:year => 2006, :month => 8) { |d|
if d.mday % 2 == 0
[d.mday, {:class => 'special_day'}]
end
}
end
def test_first_day_of_week
assert_match %r{<tr class="dayName">\s*<th>Sun}, calendar_with_defaults
assert_match %r{<tr class="dayName">\s*<th>Mon}, calendar_with_defaults(:first_day_of_week => 1)
end
private
def assert_correct_css_class_for_key(css_class, key)
assert_match %r{class="#{css_class}"}, calendar_with_defaults(key => css_class)
end
def assert_correct_css_class_for_default(css_class)
assert_match %r{class="#{css_class}"}, calendar_with_defaults
end
def calendar_with_defaults(options={})
options = { :year => 2006, :month => 8 }.merge options
calendar options
end
end