comparison test/functional/calendars_controller_test.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
2 19
3 class CalendarsControllerTest < ActionController::TestCase 20 class CalendarsControllerTest < ActionController::TestCase
4 fixtures :projects, 21 fixtures :projects,
5 :trackers, 22 :trackers,
7 :roles, 24 :roles,
8 :member_roles, 25 :member_roles,
9 :members, 26 :members,
10 :enabled_modules 27 :enabled_modules
11 28
12 def test_calendar 29 def test_show
13 get :show, :project_id => 1 30 get :show, :project_id => 1
14 assert_response :success 31 assert_response :success
15 assert_template 'calendar' 32 assert_template 'calendar'
16 assert_not_nil assigns(:calendar) 33 assert_not_nil assigns(:calendar)
34 end
35
36 def test_show_should_run_custom_queries
37 @query = IssueQuery.create!(:name => 'Calendar', :is_public => true)
38
39 get :show, :query_id => @query.id
40 assert_response :success
17 end 41 end
18 42
19 def test_cross_project_calendar 43 def test_cross_project_calendar
20 get :show 44 get :show
21 assert_response :success 45 assert_response :success
22 assert_template 'calendar' 46 assert_template 'calendar'
23 assert_not_nil assigns(:calendar) 47 assert_not_nil assigns(:calendar)
24 end 48 end
25 49
26 context "GET :show" do
27 should "run custom queries" do
28 @query = Query.create!(:name => 'Calendar', :is_public => true)
29
30 get :show, :query_id => @query.id
31 assert_response :success
32 end
33
34 end
35
36 def test_week_number_calculation 50 def test_week_number_calculation
37 Setting.start_of_week = 7 51 Setting.start_of_week = 7
38 52
39 get :show, :month => '1', :year => '2010' 53 get :show, :month => '1', :year => '2010'
40 assert_response :success 54 assert_response :success
41 55
42 assert_tag :tag => 'tr', 56 assert_select 'tr' do
43 :descendant => {:tag => 'td', 57 assert_select 'td.week-number', :text => '53'
44 :attributes => {:class => 'week-number'}, :content => '53'}, 58 assert_select 'td.odd', :text => '27'
45 :descendant => {:tag => 'td', 59 assert_select 'td.even', :text => '2'
46 :attributes => {:class => 'odd'}, :content => '27'}, 60 end
47 :descendant => {:tag => 'td',
48 :attributes => {:class => 'even'}, :content => '2'}
49 61
50 assert_tag :tag => 'tr', 62 assert_select 'tr' do
51 :descendant => {:tag => 'td', 63 assert_select 'td.week-number', :text => '1'
52 :attributes => {:class => 'week-number'}, :content => '1'}, 64 assert_select 'td.odd', :text => '3'
53 :descendant => {:tag => 'td', 65 assert_select 'td.even', :text => '9'
54 :attributes => {:class => 'odd'}, :content => '3'}, 66 end
55 :descendant => {:tag => 'td',
56 :attributes => {:class => 'even'}, :content => '9'}
57
58 67
59 Setting.start_of_week = 1 68 Setting.start_of_week = 1
60 get :show, :month => '1', :year => '2010' 69 get :show, :month => '1', :year => '2010'
61 assert_response :success 70 assert_response :success
62 71
63 assert_tag :tag => 'tr', 72 assert_select 'tr' do
64 :descendant => {:tag => 'td', 73 assert_select 'td.week-number', :text => '53'
65 :attributes => {:class => 'week-number'}, :content => '53'}, 74 assert_select 'td.even', :text => '28'
66 :descendant => {:tag => 'td', 75 assert_select 'td.even', :text => '3'
67 :attributes => {:class => 'even'}, :content => '28'}, 76 end
68 :descendant => {:tag => 'td',
69 :attributes => {:class => 'even'}, :content => '3'}
70 77
71 assert_tag :tag => 'tr', 78 assert_select 'tr' do
72 :descendant => {:tag => 'td', 79 assert_select 'td.week-number', :text => '1'
73 :attributes => {:class => 'week-number'}, :content => '1'}, 80 assert_select 'td.even', :text => '4'
74 :descendant => {:tag => 'td', 81 assert_select 'td.even', :text => '10'
75 :attributes => {:class => 'even'}, :content => '4'}, 82 end
76 :descendant => {:tag => 'td',
77 :attributes => {:class => 'even'}, :content => '10'}
78
79 end 83 end
80 end 84 end