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