annotate test/functional/activities_controller_test.rb @ 1628:9c5f8e24dadc live tip

Quieten this cron script
author Chris Cannam
date Tue, 25 Aug 2020 11:38:49 +0100
parents dffacf8a6908
children
rev   line source
Chris@1464 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1464 3 #
Chris@1464 4 # This program is free software; you can redistribute it and/or
Chris@1464 5 # modify it under the terms of the GNU General Public License
Chris@1464 6 # as published by the Free Software Foundation; either version 2
Chris@1464 7 # of the License, or (at your option) any later version.
Chris@1464 8 #
Chris@1464 9 # This program is distributed in the hope that it will be useful,
Chris@1464 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1464 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1464 12 # GNU General Public License for more details.
Chris@1464 13 #
Chris@1464 14 # You should have received a copy of the GNU General Public License
Chris@1464 15 # along with this program; if not, write to the Free Software
Chris@1464 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1464 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
chris@22 19
chris@22 20 class ActivitiesControllerTest < ActionController::TestCase
Chris@909 21 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@909 22 :enumerations, :users, :issue_categories,
Chris@909 23 :projects_trackers,
Chris@909 24 :roles,
Chris@909 25 :member_roles,
Chris@909 26 :members,
Chris@909 27 :groups_users,
Chris@909 28 :enabled_modules,
Chris@909 29 :journals, :journal_details
Chris@909 30
chris@22 31
chris@22 32 def test_project_index
chris@22 33 get :index, :id => 1, :with_subprojects => 0
chris@22 34 assert_response :success
chris@22 35 assert_template 'index'
chris@22 36 assert_not_nil assigns(:events_by_day)
Chris@441 37
Chris@1464 38 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
Chris@1464 39 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
chris@22 40 end
Chris@441 41
Chris@909 42 def test_project_index_with_invalid_project_id_should_respond_404
Chris@909 43 get :index, :id => 299
Chris@909 44 assert_response 404
Chris@909 45 end
Chris@909 46
chris@22 47 def test_previous_project_index
Chris@1294 48 get :index, :id => 1, :from => 2.days.ago.to_date
chris@22 49 assert_response :success
chris@22 50 assert_template 'index'
chris@22 51 assert_not_nil assigns(:events_by_day)
Chris@441 52
Chris@1464 53 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
Chris@1517 54 assert_select 'dl dt.issue a', :text => /#{ESCAPED_UCANT} print recipes/
chris@22 55 end
Chris@441 56
chris@22 57 def test_global_index
Chris@1115 58 @request.session[:user_id] = 1
chris@22 59 get :index
chris@22 60 assert_response :success
chris@22 61 assert_template 'index'
chris@22 62 assert_not_nil assigns(:events_by_day)
Chris@441 63
Chris@1115 64 i5 = Issue.find(5)
Chris@1115 65 d5 = User.find(1).time_to_date(i5.created_on)
Chris@1464 66
Chris@1464 67 assert_select 'h3', :text => /#{d5.day}/
Chris@1464 68 assert_select 'dl dt.issue a', :text => /Subproject issue/
chris@22 69 end
Chris@441 70
chris@22 71 def test_user_index
Chris@1115 72 @request.session[:user_id] = 1
chris@22 73 get :index, :user_id => 2
chris@22 74 assert_response :success
chris@22 75 assert_template 'index'
chris@22 76 assert_not_nil assigns(:events_by_day)
Chris@441 77
Chris@1115 78 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
Chris@1115 79
Chris@1115 80 i1 = Issue.find(1)
Chris@1115 81 d1 = User.find(1).time_to_date(i1.created_on)
Chris@1115 82
Chris@1464 83 assert_select 'h3', :text => /#{d1.day}/
Chris@1517 84 assert_select 'dl dt.issue a', :text => /#{ESCAPED_UCANT} print recipes/
chris@22 85 end
Chris@441 86
Chris@909 87 def test_user_index_with_invalid_user_id_should_respond_404
Chris@909 88 get :index, :user_id => 299
Chris@909 89 assert_response 404
Chris@909 90 end
Chris@909 91
chris@22 92 def test_index_atom_feed
Chris@1115 93 get :index, :format => 'atom', :with_subprojects => 0
chris@22 94 assert_response :success
Chris@1115 95 assert_template 'common/feed'
Chris@1115 96
Chris@1464 97 assert_select 'feed' do
Chris@1464 98 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
Chris@1464 99 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
Chris@1464 100 assert_select 'entry' do
Chris@1464 101 assert_select 'link[href=?]', 'http://test.host/issues/11'
Chris@1464 102 end
Chris@1464 103 end
Chris@1115 104 end
Chris@1115 105
Chris@1115 106 def test_index_atom_feed_with_explicit_selection
Chris@1115 107 get :index, :format => 'atom', :with_subprojects => 0,
Chris@1115 108 :show_changesets => 1,
Chris@1115 109 :show_documents => 1,
Chris@1115 110 :show_files => 1,
Chris@1115 111 :show_issues => 1,
Chris@1115 112 :show_messages => 1,
Chris@1115 113 :show_news => 1,
Chris@1115 114 :show_time_entries => 1,
Chris@1115 115 :show_wiki_edits => 1
Chris@1115 116
Chris@1115 117 assert_response :success
Chris@1115 118 assert_template 'common/feed'
Chris@1115 119
Chris@1464 120 assert_select 'feed' do
Chris@1464 121 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'
Chris@1464 122 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'
Chris@1464 123 assert_select 'entry' do
Chris@1464 124 assert_select 'link[href=?]', 'http://test.host/issues/11'
Chris@1464 125 end
Chris@1464 126 end
chris@22 127 end
Chris@909 128
Chris@909 129 def test_index_atom_feed_with_one_item_type
Chris@909 130 get :index, :format => 'atom', :show_issues => '1'
Chris@909 131 assert_response :success
Chris@1115 132 assert_template 'common/feed'
Chris@1464 133
Chris@1464 134 assert_select 'title', :text => /Issues/
Chris@909 135 end
Chris@1115 136
Chris@1115 137 def test_index_should_show_private_notes_with_permission_only
Chris@1115 138 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
Chris@1115 139 @request.session[:user_id] = 2
Chris@1115 140
Chris@1115 141 get :index
Chris@1115 142 assert_response :success
Chris@1115 143 assert_include journal, assigns(:events_by_day).values.flatten
Chris@1115 144
Chris@1115 145 Role.find(1).remove_permission! :view_private_notes
Chris@1115 146 get :index
Chris@1115 147 assert_response :success
Chris@1115 148 assert_not_include journal, assigns(:events_by_day).values.flatten
Chris@1115 149 end
chris@22 150 end