##// END OF EJS Templates
Display the correct ISO week number on the project calendar....
Eric Davis -
r3676:41ff1b9cb264
parent child
Show More
@@ -1,32 +1,32
1 <table class="cal">
1 <table class="cal">
2 <thead>
2 <thead>
3 <tr><th scope="col" title="<%= l(:label_week) %>" class="week-number"></th><% 7.times do |i| %><th scope="col"><%= day_name( (calendar.first_wday+i)%7 ) %></th><% end %></tr>
3 <tr><th scope="col" title="<%= l(:label_week) %>" class="week-number"></th><% 7.times do |i| %><th scope="col"><%= day_name( (calendar.first_wday+i)%7 ) %></th><% end %></tr>
4 </thead>
4 </thead>
5 <tbody>
5 <tbody>
6 <tr>
6 <tr>
7 <% day = calendar.startdt
7 <% day = calendar.startdt
8 while day <= calendar.enddt %>
8 while day <= calendar.enddt %>
9 <%= "<td class='week-number' title='#{ l(:label_week) }'>#{day.cweek}</td>" if day.cwday == calendar.first_wday %>
9 <%= "<td class='week-number' title='#{ l(:label_week) }'>#{(day+(11-day.cwday)%7).cweek}</td>" if day.cwday == calendar.first_wday %>
10 <td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
10 <td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>">
11 <p class="day-num"><%= day.day %></p>
11 <p class="day-num"><%= day.day %></p>
12 <% calendar.events_on(day).each do |i| %>
12 <% calendar.events_on(day).each do |i| %>
13 <% if i.is_a? Issue %>
13 <% if i.is_a? Issue %>
14 <div class="<%= i.css_classes %> <%= 'starting' if day == i.start_date %> <%= 'ending' if day == i.due_date %> tooltip">
14 <div class="<%= i.css_classes %> <%= 'starting' if day == i.start_date %> <%= 'ending' if day == i.due_date %> tooltip">
15 <%= h("#{i.project} -") unless @project && @project == i.project %>
15 <%= h("#{i.project} -") unless @project && @project == i.project %>
16 <%= link_to_issue i, :truncate => 30 %>
16 <%= link_to_issue i, :truncate => 30 %>
17 <span class="tip"><%= render_issue_tooltip i %></span>
17 <span class="tip"><%= render_issue_tooltip i %></span>
18 </div>
18 </div>
19 <% else %>
19 <% else %>
20 <span class="icon icon-package">
20 <span class="icon icon-package">
21 <%= h("#{i.project} -") unless @project && @project == i.project %>
21 <%= h("#{i.project} -") unless @project && @project == i.project %>
22 <%= link_to_version i%>
22 <%= link_to_version i%>
23 </span>
23 </span>
24 <% end %>
24 <% end %>
25 <% end %>
25 <% end %>
26 </td>
26 </td>
27 <%= '</tr><tr>' if day.cwday==calendar.last_wday and day!=calendar.enddt %>
27 <%= '</tr><tr>' if day.cwday==calendar.last_wday and day!=calendar.enddt %>
28 <% day = day + 1
28 <% day = day + 1
29 end %>
29 end %>
30 </tr>
30 </tr>
31 </tbody>
31 </tbody>
32 </table>
32 </table>
@@ -1,20 +1,64
1 require 'test_helper'
1 require 'test_helper'
2
2
3 class CalendarsControllerTest < ActionController::TestCase
3 class CalendarsControllerTest < ActionController::TestCase
4 fixtures :all
4 fixtures :all
5
5
6 def test_calendar
6 def test_calendar
7 get :show, :project_id => 1
7 get :show, :project_id => 1
8 assert_response :success
8 assert_response :success
9 assert_template 'calendar'
9 assert_template 'calendar'
10 assert_not_nil assigns(:calendar)
10 assert_not_nil assigns(:calendar)
11 end
11 end
12
12
13 def test_cross_project_calendar
13 def test_cross_project_calendar
14 get :show
14 get :show
15 assert_response :success
15 assert_response :success
16 assert_template 'calendar'
16 assert_template 'calendar'
17 assert_not_nil assigns(:calendar)
17 assert_not_nil assigns(:calendar)
18 end
18 end
19
19
20 def test_week_number_calculation
21 Setting.start_of_week = 7
22
23 get :show, :month => '1', :year => '2010'
24 assert_response :success
25
26 assert_tag :tag => 'tr',
27 :descendant => {:tag => 'td',
28 :attributes => {:class => 'week-number'}, :content => '53'},
29 :descendant => {:tag => 'td',
30 :attributes => {:class => 'odd'}, :content => '27'},
31 :descendant => {:tag => 'td',
32 :attributes => {:class => 'even'}, :content => '2'}
33
34 assert_tag :tag => 'tr',
35 :descendant => {:tag => 'td',
36 :attributes => {:class => 'week-number'}, :content => '1'},
37 :descendant => {:tag => 'td',
38 :attributes => {:class => 'odd'}, :content => '3'},
39 :descendant => {:tag => 'td',
40 :attributes => {:class => 'even'}, :content => '9'}
41
42
43 Setting.start_of_week = 1
44 get :show, :month => '1', :year => '2010'
45 assert_response :success
46
47 assert_tag :tag => 'tr',
48 :descendant => {:tag => 'td',
49 :attributes => {:class => 'week-number'}, :content => '53'},
50 :descendant => {:tag => 'td',
51 :attributes => {:class => 'even'}, :content => '28'},
52 :descendant => {:tag => 'td',
53 :attributes => {:class => 'even'}, :content => '3'}
54
55 assert_tag :tag => 'tr',
56 :descendant => {:tag => 'td',
57 :attributes => {:class => 'week-number'}, :content => '1'},
58 :descendant => {:tag => 'td',
59 :attributes => {:class => 'even'}, :content => '4'},
60 :descendant => {:tag => 'td',
61 :attributes => {:class => 'even'}, :content => '10'}
62
63 end
20 end
64 end
General Comments 0
You need to be logged in to leave comments. Login now