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 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 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. :queries
  32. def test_show
  33. with_settings :gravatar_enabled => '1' do
  34. get :show, :params => {
  35. :project_id => 1
  36. }
  37. end
  38. assert_response :success
  39. # query form
  40. assert_select 'form#query_form' do
  41. assert_select 'div#query_form_with_buttons.hide-when-print' do
  42. assert_select 'div#query_form_content' do
  43. assert_select 'fieldset#filters.collapsible'
  44. end
  45. assert_select 'p.contextual'
  46. assert_select 'p.buttons'
  47. end
  48. end
  49. # Assert context menu on issues
  50. assert_select 'form[data-cm-url=?]', '/issues/context_menu'
  51. assert_select 'div.issue.hascontextmenu.tooltip' do
  52. assert_select 'input[name=?][type=?]', 'ids[]', 'checkbox'
  53. assert_select 'img[class="gravatar"]'
  54. end
  55. end
  56. def test_show_should_run_custom_queries
  57. @query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC)
  58. get :show, :params => {
  59. :query_id => @query.id
  60. }
  61. assert_response :success
  62. assert_select 'h2', :text => 'Calendar Query'
  63. end
  64. def test_cross_project_calendar
  65. get :show
  66. assert_response :success
  67. end
  68. def test_week_number_calculation
  69. with_settings :start_of_week => 7 do
  70. get :show, :params => {
  71. :month => '1',
  72. :year => '2010'
  73. }
  74. assert_response :success
  75. end
  76. assert_select 'tr' do
  77. assert_select 'td.week-number', :text => '53'
  78. assert_select 'td.odd', :text => '27'
  79. assert_select 'td.even', :text => '2'
  80. end
  81. assert_select 'tr' do
  82. assert_select 'td.week-number', :text => '1'
  83. assert_select 'td.odd', :text => '3'
  84. assert_select 'td.even', :text => '9'
  85. end
  86. with_settings :start_of_week => 1 do
  87. get :show, :params => {
  88. :month => '1',
  89. :year => '2010'
  90. }
  91. assert_response :success
  92. end
  93. assert_select 'tr' do
  94. assert_select 'td.week-number', :text => '53'
  95. assert_select 'td.even', :text => '28'
  96. assert_select 'td.even', :text => '3'
  97. end
  98. assert_select 'tr' do
  99. assert_select 'td.week-number', :text => '1'
  100. assert_select 'td.even', :text => '4'
  101. assert_select 'td.even', :text => '10'
  102. end
  103. end
  104. def test_show_custom_query_with_multiple_sort_criteria
  105. get :show, :params => {
  106. :query_id => 5
  107. }
  108. assert_response :success
  109. assert_select 'h2', :text => 'Open issues by priority and tracker'
  110. end
  111. def test_show_custom_query_with_group_by_option
  112. get :show, :params => {
  113. :query_id => 6
  114. }
  115. assert_response :success
  116. assert_select 'h2', :text => 'Open issues grouped by tracker'
  117. end
  118. end