Chris@1517: # Redmine - project management software Chris@1517: # Copyright (C) 2006-2014 Jean-Philippe Lang Chris@1517: # Chris@1517: # This program is free software; you can redistribute it and/or Chris@1517: # modify it under the terms of the GNU General Public License Chris@1517: # as published by the Free Software Foundation; either version 2 Chris@1517: # of the License, or (at your option) any later version. Chris@1517: # Chris@1517: # This program is distributed in the hope that it will be useful, Chris@1517: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1517: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1517: # GNU General Public License for more details. Chris@1517: # Chris@1517: # You should have received a copy of the GNU General Public License Chris@1517: # along with this program; if not, write to the Free Software Chris@1517: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@1517: Chris@1517: require File.expand_path('../../test_helper', __FILE__) Chris@1517: Chris@1517: class CalendarsControllerTest < ActionController::TestCase Chris@1517: fixtures :projects, Chris@1517: :trackers, Chris@1517: :projects_trackers, Chris@1517: :roles, Chris@1517: :member_roles, Chris@1517: :members, Chris@1517: :enabled_modules Chris@1517: Chris@1517: def test_show Chris@1517: get :show, :project_id => 1 Chris@1517: assert_response :success Chris@1517: assert_template :partial => '_calendar' Chris@1517: assert_not_nil assigns(:calendar) Chris@1517: end Chris@1517: Chris@1517: def test_show_should_run_custom_queries Chris@1517: @query = IssueQuery.create!(:name => 'Calendar', :visibility => IssueQuery::VISIBILITY_PUBLIC) Chris@1517: Chris@1517: get :show, :query_id => @query.id Chris@1517: assert_response :success Chris@1517: end Chris@1517: Chris@1517: def test_cross_project_calendar Chris@1517: get :show Chris@1517: assert_response :success Chris@1517: assert_template :partial => '_calendar' Chris@1517: assert_not_nil assigns(:calendar) Chris@1517: end Chris@1517: Chris@1517: def test_week_number_calculation Chris@1517: Setting.start_of_week = 7 Chris@1517: Chris@1517: get :show, :month => '1', :year => '2010' Chris@1517: assert_response :success Chris@1517: Chris@1517: assert_select 'tr' do Chris@1517: assert_select 'td.week-number', :text => '53' Chris@1517: assert_select 'td.odd', :text => '27' Chris@1517: assert_select 'td.even', :text => '2' Chris@1517: end Chris@1517: Chris@1517: assert_select 'tr' do Chris@1517: assert_select 'td.week-number', :text => '1' Chris@1517: assert_select 'td.odd', :text => '3' Chris@1517: assert_select 'td.even', :text => '9' Chris@1517: end Chris@1517: Chris@1517: Setting.start_of_week = 1 Chris@1517: get :show, :month => '1', :year => '2010' Chris@1517: assert_response :success Chris@1517: Chris@1517: assert_select 'tr' do Chris@1517: assert_select 'td.week-number', :text => '53' Chris@1517: assert_select 'td.even', :text => '28' Chris@1517: assert_select 'td.even', :text => '3' Chris@1517: end Chris@1517: Chris@1517: assert_select 'tr' do Chris@1517: assert_select 'td.week-number', :text => '1' Chris@1517: assert_select 'td.even', :text => '4' Chris@1517: assert_select 'td.even', :text => '10' Chris@1517: end Chris@1517: end Chris@1517: end