annotate .svn/pristine/b5/b5912509c719c19cefc865fb8a655b03174ed731.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

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