You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calendars_controller_test.rb 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2016 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. require File.expand_path('../../test_helper', __FILE__)
  18. class CalendarsControllerTest < Redmine::ControllerTest
  19. fixtures :projects,
  20. :trackers,
  21. :projects_trackers,
  22. :roles,
  23. :member_roles,
  24. :members,
  25. :enabled_modules,
  26. :issues,
  27. :issue_statuses,
  28. :issue_relations,
  29. :issue_categories,
  30. :enumerations
  31. def test_show
  32. get :show, :project_id => 1
  33. assert_response :success
  34. end
  35. def test_show_should_run_custom_queries
  36. @query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
  37. get :show, :query_id => @query.id
  38. assert_response :success
  39. assert_select 'h2', :text => 'Calendar Query'
  40. end
  41. def test_cross_project_calendar
  42. get :show
  43. assert_response :success
  44. end
  45. def test_week_number_calculation
  46. with_settings :start_of_week => 7 do
  47. get :show, :month => '1', :year => '2010'
  48. assert_response :success
  49. end
  50. assert_select 'tr' do
  51. assert_select 'td.week-number', :text => '53'
  52. assert_select 'td.odd', :text => '27'
  53. assert_select 'td.even', :text => '2'
  54. end
  55. assert_select 'tr' do
  56. assert_select 'td.week-number', :text => '1'
  57. assert_select 'td.odd', :text => '3'
  58. assert_select 'td.even', :text => '9'
  59. end
  60. with_settings :start_of_week => 1 do
  61. get :show, :month => '1', :year => '2010'
  62. assert_response :success
  63. end
  64. assert_select 'tr' do
  65. assert_select 'td.week-number', :text => '53'
  66. assert_select 'td.even', :text => '28'
  67. assert_select 'td.even', :text => '3'
  68. end
  69. assert_select 'tr' do
  70. assert_select 'td.week-number', :text => '1'
  71. assert_select 'td.even', :text => '4'
  72. assert_select 'td.even', :text => '10'
  73. end
  74. end
  75. end