Mercurial > hg > soundsoftware-site
comparison .svn/pristine/be/be60b294fa53596894bfd4efd7ed28e8a1bbb00b.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 |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
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 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class ContextMenusControllerTest < ActionController::TestCase | |
21 fixtures :projects, | |
22 :trackers, | |
23 :projects_trackers, | |
24 :roles, | |
25 :member_roles, | |
26 :members, | |
27 :enabled_modules, | |
28 :workflows, | |
29 :journals, :journal_details, | |
30 :versions, | |
31 :issues, :issue_statuses, :issue_categories, | |
32 :users, | |
33 :enumerations, | |
34 :time_entries | |
35 | |
36 def test_context_menu_one_issue | |
37 @request.session[:user_id] = 2 | |
38 get :issues, :ids => [1] | |
39 assert_response :success | |
40 assert_template 'context_menu' | |
41 | |
42 assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit' | |
43 assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy' | |
44 assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete' | |
45 | |
46 # Statuses | |
47 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed' | |
48 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate' | |
49 # No inactive priorities | |
50 assert_select 'a', :text => /Inactive Priority/, :count => 0 | |
51 # Versions | |
52 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0' | |
53 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' | |
54 # Assignees | |
55 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' | |
56 end | |
57 | |
58 def test_context_menu_one_issue_by_anonymous | |
59 get :issues, :ids => [1] | |
60 assert_response :success | |
61 assert_template 'context_menu' | |
62 assert_tag :tag => 'a', :content => 'Delete', | |
63 :attributes => { :href => '#', | |
64 :class => 'icon-del disabled' } | |
65 end | |
66 | |
67 def test_context_menu_multiple_issues_of_same_project | |
68 @request.session[:user_id] = 2 | |
69 get :issues, :ids => [1, 2] | |
70 assert_response :success | |
71 assert_template 'context_menu' | |
72 assert_not_nil assigns(:issues) | |
73 assert_equal [1, 2], assigns(:issues).map(&:id).sort | |
74 | |
75 ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') | |
76 | |
77 assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' | |
78 assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy' | |
79 assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' | |
80 | |
81 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' | |
82 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' | |
83 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3", :text => 'Dave Lopper' | |
84 end | |
85 | |
86 def test_context_menu_multiple_issues_of_different_projects | |
87 @request.session[:user_id] = 2 | |
88 get :issues, :ids => [1, 2, 6] | |
89 assert_response :success | |
90 assert_template 'context_menu' | |
91 assert_not_nil assigns(:issues) | |
92 assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort | |
93 | |
94 ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') | |
95 | |
96 assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' | |
97 assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' | |
98 | |
99 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' | |
100 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' | |
101 assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2", :text => 'John Smith' | |
102 end | |
103 | |
104 def test_context_menu_should_include_list_custom_fields | |
105 field = IssueCustomField.create!(:name => 'List', :field_format => 'list', | |
106 :possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
107 @request.session[:user_id] = 2 | |
108 get :issues, :ids => [1] | |
109 | |
110 assert_select "li.cf_#{field.id}" do | |
111 assert_select 'a[href=#]', :text => 'List' | |
112 assert_select 'ul' do | |
113 assert_select 'a', 3 | |
114 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' | |
115 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' | |
116 end | |
117 end | |
118 end | |
119 | |
120 def test_context_menu_should_not_include_null_value_for_required_custom_fields | |
121 field = IssueCustomField.create!(:name => 'List', :is_required => true, :field_format => 'list', | |
122 :possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
123 @request.session[:user_id] = 2 | |
124 get :issues, :ids => [1, 2] | |
125 | |
126 assert_select "li.cf_#{field.id}" do | |
127 assert_select 'a[href=#]', :text => 'List' | |
128 assert_select 'ul' do | |
129 assert_select 'a', 2 | |
130 assert_select 'a', :text => 'none', :count => 0 | |
131 end | |
132 end | |
133 end | |
134 | |
135 def test_context_menu_on_single_issue_should_select_current_custom_field_value | |
136 field = IssueCustomField.create!(:name => 'List', :field_format => 'list', | |
137 :possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
138 issue = Issue.find(1) | |
139 issue.custom_field_values = {field.id => 'Bar'} | |
140 issue.save! | |
141 @request.session[:user_id] = 2 | |
142 get :issues, :ids => [1] | |
143 | |
144 assert_select "li.cf_#{field.id}" do | |
145 assert_select 'a[href=#]', :text => 'List' | |
146 assert_select 'ul' do | |
147 assert_select 'a', 3 | |
148 assert_select 'a.icon-checked', :text => 'Bar' | |
149 end | |
150 end | |
151 end | |
152 | |
153 def test_context_menu_should_include_bool_custom_fields | |
154 field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool', | |
155 :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
156 @request.session[:user_id] = 2 | |
157 get :issues, :ids => [1] | |
158 | |
159 assert_select "li.cf_#{field.id}" do | |
160 assert_select 'a[href=#]', :text => 'Bool' | |
161 assert_select 'ul' do | |
162 assert_select 'a', 3 | |
163 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No' | |
164 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes' | |
165 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' | |
166 end | |
167 end | |
168 end | |
169 | |
170 def test_context_menu_should_include_user_custom_fields | |
171 field = IssueCustomField.create!(:name => 'User', :field_format => 'user', | |
172 :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
173 @request.session[:user_id] = 2 | |
174 get :issues, :ids => [1] | |
175 | |
176 assert_select "li.cf_#{field.id}" do | |
177 assert_select 'a[href=#]', :text => 'User' | |
178 assert_select 'ul' do | |
179 assert_select 'a', Project.find(1).members.count + 1 | |
180 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' | |
181 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' | |
182 end | |
183 end | |
184 end | |
185 | |
186 def test_context_menu_should_include_version_custom_fields | |
187 field = IssueCustomField.create!(:name => 'Version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1, 2, 3]) | |
188 @request.session[:user_id] = 2 | |
189 get :issues, :ids => [1] | |
190 | |
191 assert_select "li.cf_#{field.id}" do | |
192 assert_select 'a[href=#]', :text => 'Version' | |
193 assert_select 'ul' do | |
194 assert_select 'a', Project.find(1).shared_versions.count + 1 | |
195 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0' | |
196 assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' | |
197 end | |
198 end | |
199 end | |
200 | |
201 def test_context_menu_by_assignable_user_should_include_assigned_to_me_link | |
202 @request.session[:user_id] = 2 | |
203 get :issues, :ids => [1] | |
204 assert_response :success | |
205 assert_template 'context_menu' | |
206 | |
207 assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / | |
208 end | |
209 | |
210 def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects | |
211 @request.session[:user_id] = 2 | |
212 version = Version.create!(:name => 'Shared', :sharing => 'system', :project_id => 1) | |
213 | |
214 get :issues, :ids => [1, 4] | |
215 assert_response :success | |
216 assert_template 'context_menu' | |
217 | |
218 assert_include version, assigns(:versions) | |
219 assert_select 'a', :text => 'eCookbook - Shared' | |
220 end | |
221 | |
222 def test_context_menu_issue_visibility | |
223 get :issues, :ids => [1, 4] | |
224 assert_response :success | |
225 assert_template 'context_menu' | |
226 assert_equal [1], assigns(:issues).collect(&:id) | |
227 end | |
228 | |
229 def test_should_respond_with_404_without_ids | |
230 get :issues | |
231 assert_response 404 | |
232 end | |
233 | |
234 def test_time_entries_context_menu | |
235 @request.session[:user_id] = 2 | |
236 get :time_entries, :ids => [1, 2] | |
237 assert_response :success | |
238 assert_template 'time_entries' | |
239 | |
240 assert_select 'a:not(.disabled)', :text => 'Edit' | |
241 end | |
242 | |
243 def test_time_entries_context_menu_without_edit_permission | |
244 @request.session[:user_id] = 2 | |
245 Role.find_by_name('Manager').remove_permission! :edit_time_entries | |
246 | |
247 get :time_entries, :ids => [1, 2] | |
248 assert_response :success | |
249 assert_template 'time_entries' | |
250 assert_select 'a.disabled', :text => 'Edit' | |
251 end | |
252 end |