Skip to content

Commit

Permalink
Address a year boundary condition in the mini-calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed Sep 5, 2009
1 parent 1818d39 commit ae3573d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions features/mini_calendar.feature
Expand Up @@ -23,3 +23,14 @@ Feature: Mini-calendar
And there should be 1 links to meals
And there should be a link to the next month
And there should not be a link to the previous month

Scenario: Navigating boundary conditions

Given a "Test" meal enjoyed on 2008-01-23
And a "Test" meal enjoyed on 2007-12-15
When I visit the mini-calendar
Then I should see the calendar for January 2008
And there should be 1 links to meals
When I click on the link to the previous month
Then I should see the calendar for December 2007
And there should be 1 links to meals
11 changes: 11 additions & 0 deletions spec/views/mini_calendar.haml_spec.rb
Expand Up @@ -96,4 +96,15 @@
:content => ">")
end
end

context "January" do
before(:each) do
assigns[:month] = "2008-01"
end

it "should have weeks (probing boundary condition)" do
render("views/mini_calendar.haml")
response.should have_selector("td")
end
end
end
2 changes: 1 addition & 1 deletion views/mini_calendar.haml
Expand Up @@ -20,7 +20,7 @@
%th F
%th Sa
- week = 0
- while ((sunday0 + week*7).mon <= day1.mon)
- while ((sunday0 + week*7).strftime("%Y-%m") <= day1.strftime("%Y-%m"))
%tr{:class => "week#{week+1}"}
- (0..6).map{|d| sunday0 + d + week*7}.each do |date|
%td{:id => date.to_s}
Expand Down

0 comments on commit ae3573d

Please sign in to comment.