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.

activities_controller_test.rb 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2014 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 ActivitiesControllerTest < ActionController::TestCase
  19. fixtures :projects, :trackers, :issue_statuses, :issues,
  20. :enumerations, :users, :issue_categories,
  21. :projects_trackers,
  22. :roles,
  23. :member_roles,
  24. :members,
  25. :groups_users,
  26. :enabled_modules,
  27. :journals, :journal_details
  28. def test_project_index
  29. get :index, :id => 1, :with_subprojects => 0
  30. assert_response :success
  31. assert_template 'index'
  32. assert_not_nil assigns(:events_by_day)
  33. assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
  34. assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
  35. end
  36. def test_project_index_with_invalid_project_id_should_respond_404
  37. get :index, :id => 299
  38. assert_response 404
  39. end
  40. def test_previous_project_index
  41. get :index, :id => 1, :from => 2.days.ago.to_date
  42. assert_response :success
  43. assert_template 'index'
  44. assert_not_nil assigns(:events_by_day)
  45. assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
  46. assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
  47. end
  48. def test_global_index
  49. @request.session[:user_id] = 1
  50. get :index
  51. assert_response :success
  52. assert_template 'index'
  53. assert_not_nil assigns(:events_by_day)
  54. i5 = Issue.find(5)
  55. d5 = User.find(1).time_to_date(i5.created_on)
  56. assert_select 'h3', :text => /#{d5.day}/
  57. assert_select 'dl dt.issue a', :text => /Subproject issue/
  58. end
  59. def test_user_index
  60. @request.session[:user_id] = 1
  61. get :index, :user_id => 2
  62. assert_response :success
  63. assert_template 'index'
  64. assert_not_nil assigns(:events_by_day)
  65. assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
  66. i1 = Issue.find(1)
  67. d1 = User.find(1).time_to_date(i1.created_on)
  68. assert_select 'h3', :text => /#{d1.day}/
  69. assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
  70. end
  71. def test_user_index_with_invalid_user_id_should_respond_404
  72. get :index, :user_id => 299
  73. assert_response 404
  74. end
  75. def test_index_atom_feed
  76. get :index, :format => 'atom', :with_subprojects => 0
  77. assert_response :success
  78. assert_template 'common/feed'
  79. assert_select 'feed' do
  80. assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
  81. assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
  82. assert_select 'entry' do
  83. assert_select 'link[href=?]', 'http://test.host/issues/11'
  84. end
  85. end
  86. end
  87. def test_index_atom_feed_with_explicit_selection
  88. get :index, :format => 'atom', :with_subprojects => 0,
  89. :show_changesets => 1,
  90. :show_documents => 1,
  91. :show_files => 1,
  92. :show_issues => 1,
  93. :show_messages => 1,
  94. :show_news => 1,
  95. :show_time_entries => 1,
  96. :show_wiki_edits => 1
  97. assert_response :success
  98. assert_template 'common/feed'
  99. assert_select 'feed' do
  100. assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
  101. assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
  102. assert_select 'entry' do
  103. assert_select 'link[href=?]', 'http://test.host/issues/11'
  104. end
  105. end
  106. end
  107. def test_index_atom_feed_with_one_item_type
  108. get :index, :format => 'atom', :show_issues => '1'
  109. assert_response :success
  110. assert_template 'common/feed'
  111. assert_select 'title', :text => /Issues/
  112. end
  113. def test_index_should_show_private_notes_with_permission_only
  114. journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
  115. @request.session[:user_id] = 2
  116. get :index
  117. assert_response :success
  118. assert_include journal, assigns(:events_by_day).values.flatten
  119. Role.find(1).remove_permission! :view_private_notes
  120. get :index
  121. assert_response :success
  122. assert_not_include journal, assigns(:events_by_day).values.flatten
  123. end
  124. end