annotate .svn/pristine/7b/7b4a7980eacdd8ddbb5cfd044c9fa70a1519695c.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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