comparison test/functional/activities_controller_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 3e4c3460b6ca
children e248c7af89ec
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 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
1 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
2 19
3 class ActivitiesControllerTest < ActionController::TestCase 20 class ActivitiesControllerTest < ActionController::TestCase
4 fixtures :projects, :trackers, :issue_statuses, :issues, 21 fixtures :projects, :trackers, :issue_statuses, :issues,
5 :enumerations, :users, :issue_categories, 22 :enumerations, :users, :issue_categories,
7 :roles, 24 :roles,
8 :member_roles, 25 :member_roles,
9 :members, 26 :members,
10 :groups_users, 27 :groups_users,
11 :enabled_modules, 28 :enabled_modules,
12 :workflows,
13 :journals, :journal_details 29 :journals, :journal_details
14 30
15 31
16 def test_project_index 32 def test_project_index
17 get :index, :id => 1, :with_subprojects => 0 33 get :index, :id => 1, :with_subprojects => 0
18 assert_response :success 34 assert_response :success
19 assert_template 'index' 35 assert_template 'index'
20 assert_not_nil assigns(:events_by_day) 36 assert_not_nil assigns(:events_by_day)
21 37
22 assert_tag :tag => "h3", 38 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
23 :content => /#{2.days.ago.to_date.day}/, 39 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
24 :sibling => { :tag => "dl",
25 :child => { :tag => "dt",
26 :attributes => { :class => /issue-edit/ },
27 :child => { :tag => "a",
28 :content => /(#{IssueStatus.find(2).name})/,
29 }
30 }
31 }
32 end 40 end
33 41
34 def test_project_index_with_invalid_project_id_should_respond_404 42 def test_project_index_with_invalid_project_id_should_respond_404
35 get :index, :id => 299 43 get :index, :id => 299
36 assert_response 404 44 assert_response 404
40 get :index, :id => 1, :from => 2.days.ago.to_date 48 get :index, :id => 1, :from => 2.days.ago.to_date
41 assert_response :success 49 assert_response :success
42 assert_template 'index' 50 assert_template 'index'
43 assert_not_nil assigns(:events_by_day) 51 assert_not_nil assigns(:events_by_day)
44 52
45 assert_tag :tag => "h3", 53 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
46 :content => /#{3.day.ago.to_date.day}/, 54 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
47 :sibling => { :tag => "dl",
48 :child => { :tag => "dt",
49 :attributes => { :class => /issue/ },
50 :child => { :tag => "a",
51 :content => /Can&#x27;t print recipes/,
52 }
53 }
54 }
55 end 55 end
56 56
57 def test_global_index 57 def test_global_index
58 @request.session[:user_id] = 1 58 @request.session[:user_id] = 1
59 get :index 59 get :index
61 assert_template 'index' 61 assert_template 'index'
62 assert_not_nil assigns(:events_by_day) 62 assert_not_nil assigns(:events_by_day)
63 63
64 i5 = Issue.find(5) 64 i5 = Issue.find(5)
65 d5 = User.find(1).time_to_date(i5.created_on) 65 d5 = User.find(1).time_to_date(i5.created_on)
66 assert_tag :tag => "h3", 66
67 :content => /#{d5.day}/, 67 assert_select 'h3', :text => /#{d5.day}/
68 :sibling => { :tag => "dl", 68 assert_select 'dl dt.issue a', :text => /Subproject issue/
69 :child => { :tag => "dt",
70 :attributes => { :class => /issue/ },
71 :child => { :tag => "a",
72 :content => /Subproject issue/,
73 }
74 }
75 }
76 end 69 end
77 70
78 def test_user_index 71 def test_user_index
79 @request.session[:user_id] = 1 72 @request.session[:user_id] = 1
80 get :index, :user_id => 2 73 get :index, :user_id => 2
85 assert_select 'h2 a[href=/users/2]', :text => 'John Smith' 78 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
86 79
87 i1 = Issue.find(1) 80 i1 = Issue.find(1)
88 d1 = User.find(1).time_to_date(i1.created_on) 81 d1 = User.find(1).time_to_date(i1.created_on)
89 82
90 assert_tag :tag => "h3", 83 assert_select 'h3', :text => /#{d1.day}/
91 :content => /#{d1.day}/, 84 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
92 :sibling => { :tag => "dl",
93 :child => { :tag => "dt",
94 :attributes => { :class => /issue/ },
95 :child => { :tag => "a",
96 :content => /Can&#x27;t print recipes/,
97 }
98 }
99 }
100 end 85 end
101 86
102 def test_user_index_with_invalid_user_id_should_respond_404 87 def test_user_index_with_invalid_user_id_should_respond_404
103 get :index, :user_id => 299 88 get :index, :user_id => 299
104 assert_response 404 89 assert_response 404
107 def test_index_atom_feed 92 def test_index_atom_feed
108 get :index, :format => 'atom', :with_subprojects => 0 93 get :index, :format => 'atom', :with_subprojects => 0
109 assert_response :success 94 assert_response :success
110 assert_template 'common/feed' 95 assert_template 'common/feed'
111 96
112 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, 97 assert_select 'feed' do
113 :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} 98 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
114 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, 99 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
115 :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} 100 assert_select 'entry' do
116 101 assert_select 'link[href=?]', 'http://test.host/issues/11'
117 assert_tag :tag => 'entry', :child => { 102 end
118 :tag => 'link', 103 end
119 :attributes => {:href => 'http://test.host/issues/11'}}
120 end 104 end
121 105
122 def test_index_atom_feed_with_explicit_selection 106 def test_index_atom_feed_with_explicit_selection
123 get :index, :format => 'atom', :with_subprojects => 0, 107 get :index, :format => 'atom', :with_subprojects => 0,
124 :show_changesets => 1, 108 :show_changesets => 1,
131 :show_wiki_edits => 1 115 :show_wiki_edits => 1
132 116
133 assert_response :success 117 assert_response :success
134 assert_template 'common/feed' 118 assert_template 'common/feed'
135 119
136 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, 120 assert_select 'feed' do
137 :attributes => {: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'} 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'
138 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, 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'
139 :attributes => {: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'} 123 assert_select 'entry' do
140 124 assert_select 'link[href=?]', 'http://test.host/issues/11'
141 assert_tag :tag => 'entry', :child => { 125 end
142 :tag => 'link', 126 end
143 :attributes => {:href => 'http://test.host/issues/11'}}
144 end 127 end
145 128
146 def test_index_atom_feed_with_one_item_type 129 def test_index_atom_feed_with_one_item_type
147 get :index, :format => 'atom', :show_issues => '1' 130 get :index, :format => 'atom', :show_issues => '1'
148 assert_response :success 131 assert_response :success
149 assert_template 'common/feed' 132 assert_template 'common/feed'
150 assert_tag :tag => 'title', :content => /Issues/ 133
134 assert_select 'title', :text => /Issues/
151 end 135 end
152 136
153 def test_index_should_show_private_notes_with_permission_only 137 def test_index_should_show_private_notes_with_permission_only
154 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true) 138 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
155 @request.session[:user_id] = 2 139 @request.session[:user_id] = 2