To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / functional / .svn / text-base / calendars_controller_test.rb.svn-base @ 442:753f1380d6bc

History | View | Annotate | Download (2.33 KB)

1
require File.expand_path('../../test_helper', __FILE__)
2

    
3
class CalendarsControllerTest < ActionController::TestCase
4
  fixtures :all
5

    
6
  def test_calendar
7
    get :show, :project_id => 1
8
    assert_response :success
9
    assert_template 'calendar'
10
    assert_not_nil assigns(:calendar)
11
  end
12
  
13
  def test_cross_project_calendar
14
    get :show
15
    assert_response :success
16
    assert_template 'calendar'
17
    assert_not_nil assigns(:calendar)
18
  end
19

    
20
  context "GET :show" do
21
    should "run custom queries" do
22
      @query = Query.generate_default!
23
      
24
      get :show, :query_id => @query.id
25
      assert_response :success
26
    end
27
    
28
  end
29
  
30
  def test_week_number_calculation
31
    Setting.start_of_week = 7
32
    
33
    get :show, :month => '1', :year => '2010'
34
    assert_response :success
35
    
36
    assert_tag :tag => 'tr',
37
      :descendant => {:tag => 'td',
38
                      :attributes => {:class => 'week-number'}, :content => '53'},
39
      :descendant => {:tag => 'td',
40
                      :attributes => {:class => 'odd'}, :content => '27'},
41
      :descendant => {:tag => 'td',
42
                      :attributes => {:class => 'even'}, :content => '2'}
43

    
44
    assert_tag :tag => 'tr',
45
      :descendant => {:tag => 'td',
46
                      :attributes => {:class => 'week-number'}, :content => '1'},
47
      :descendant => {:tag => 'td',
48
                      :attributes => {:class => 'odd'}, :content => '3'},
49
      :descendant => {:tag => 'td',
50
                      :attributes => {:class => 'even'}, :content => '9'}
51

    
52

    
53
    Setting.start_of_week = 1
54
    get :show, :month => '1', :year => '2010'
55
    assert_response :success
56

    
57
    assert_tag :tag => 'tr',
58
      :descendant => {:tag => 'td',
59
                      :attributes => {:class => 'week-number'}, :content => '53'},
60
      :descendant => {:tag => 'td',
61
                      :attributes => {:class => 'even'}, :content => '28'},
62
      :descendant => {:tag => 'td',
63
                      :attributes => {:class => 'even'}, :content => '3'}
64

    
65
    assert_tag :tag => 'tr',
66
      :descendant => {:tag => 'td',
67
                      :attributes => {:class => 'week-number'}, :content => '1'},
68
      :descendant => {:tag => 'td',
69
                      :attributes => {:class => 'even'}, :content => '4'},
70
      :descendant => {:tag => 'td',
71
                      :attributes => {:class => 'even'}, :content => '10'}
72

    
73
  end
74
end