##// END OF EJS Templates
Render issue attributes using divs instead of a table for responsiveness (#19097)....
Jean-Philippe Lang -
r14466:cb0866f31307
parent child
Show More
@@ -1,516 +1,516
1 1 # encoding: utf-8
2 2 #
3 3 # Redmine - project management software
4 4 # Copyright (C) 2006-2015 Jean-Philippe Lang
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; either version 2
9 9 # of the License, or (at your option) any later version.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 19
20 20 module IssuesHelper
21 21 include ApplicationHelper
22 22 include Redmine::Export::PDF::IssuesPdfHelper
23 23
24 24 def issue_list(issues, &block)
25 25 ancestors = []
26 26 issues.each do |issue|
27 27 while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
28 28 ancestors.pop
29 29 end
30 30 yield issue, ancestors.size
31 31 ancestors << issue unless issue.leaf?
32 32 end
33 33 end
34 34
35 35 def grouped_issue_list(issues, query, issue_count_by_group, &block)
36 36 previous_group, first = false, true
37 37 totals_by_group = query.totalable_columns.inject({}) do |h, column|
38 38 h[column] = query.total_by_group_for(column)
39 39 h
40 40 end
41 41 issue_list(issues) do |issue, level|
42 42 group_name = group_count = nil
43 43 if query.grouped?
44 44 group = query.group_by_column.value(issue)
45 45 if first || group != previous_group
46 46 if group.blank? && group != false
47 47 group_name = "(#{l(:label_blank_value)})"
48 48 else
49 49 group_name = format_object(group)
50 50 end
51 51 group_name ||= ""
52 52 group_count = issue_count_by_group[group]
53 53 group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
54 54 end
55 55 end
56 56 yield issue, level, group_name, group_count, group_totals
57 57 previous_group, first = group, false
58 58 end
59 59 end
60 60
61 61 # Renders a HTML/CSS tooltip
62 62 #
63 63 # To use, a trigger div is needed. This is a div with the class of "tooltip"
64 64 # that contains this method wrapped in a span with the class of "tip"
65 65 #
66 66 # <div class="tooltip"><%= link_to_issue(issue) %>
67 67 # <span class="tip"><%= render_issue_tooltip(issue) %></span>
68 68 # </div>
69 69 #
70 70 def render_issue_tooltip(issue)
71 71 @cached_label_status ||= l(:field_status)
72 72 @cached_label_start_date ||= l(:field_start_date)
73 73 @cached_label_due_date ||= l(:field_due_date)
74 74 @cached_label_assigned_to ||= l(:field_assigned_to)
75 75 @cached_label_priority ||= l(:field_priority)
76 76 @cached_label_project ||= l(:field_project)
77 77
78 78 link_to_issue(issue) + "<br /><br />".html_safe +
79 79 "<strong>#{@cached_label_project}</strong>: #{link_to_project(issue.project)}<br />".html_safe +
80 80 "<strong>#{@cached_label_status}</strong>: #{h(issue.status.name)}<br />".html_safe +
81 81 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />".html_safe +
82 82 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />".html_safe +
83 83 "<strong>#{@cached_label_assigned_to}</strong>: #{h(issue.assigned_to)}<br />".html_safe +
84 84 "<strong>#{@cached_label_priority}</strong>: #{h(issue.priority.name)}".html_safe
85 85 end
86 86
87 87 def issue_heading(issue)
88 88 h("#{issue.tracker} ##{issue.id}")
89 89 end
90 90
91 91 def render_issue_subject_with_tree(issue)
92 92 s = ''
93 93 ancestors = issue.root? ? [] : issue.ancestors.visible.to_a
94 94 ancestors.each do |ancestor|
95 95 s << '<div>' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id)))
96 96 end
97 97 s << '<div>'
98 98 subject = h(issue.subject)
99 99 if issue.is_private?
100 100 subject = content_tag('span', l(:field_is_private), :class => 'private') + ' ' + subject
101 101 end
102 102 s << content_tag('h3', subject)
103 103 s << '</div>' * (ancestors.size + 1)
104 104 s.html_safe
105 105 end
106 106
107 107 def render_descendants_tree(issue)
108 108 s = '<form><table class="list issues">'
109 109 issue_list(issue.descendants.visible.preload(:status, :priority, :tracker).sort_by(&:lft)) do |child, level|
110 110 css = "issue issue-#{child.id} hascontextmenu"
111 111 css << " idnt idnt-#{level}" if level > 0
112 112 s << content_tag('tr',
113 113 content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil), :class => 'checkbox') +
114 114 content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
115 115 content_tag('td', h(child.status)) +
116 116 content_tag('td', link_to_user(child.assigned_to)) +
117 117 content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
118 118 :class => css)
119 119 end
120 120 s << '</table></form>'
121 121 s.html_safe
122 122 end
123 123
124 124 def issue_estimated_hours_details(issue)
125 125 if issue.total_estimated_hours.present?
126 126 if issue.total_estimated_hours == issue.estimated_hours
127 127 l_hours_short(issue.estimated_hours)
128 128 else
129 129 s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : ""
130 130 s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})"
131 131 s.html_safe
132 132 end
133 133 end
134 134 end
135 135
136 136 def issue_spent_hours_details(issue)
137 137 if issue.total_spent_hours > 0
138 138 if issue.total_spent_hours == issue.spent_hours
139 139 link_to(l_hours_short(issue.spent_hours), issue_time_entries_path(issue))
140 140 else
141 141 s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : ""
142 142 s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), issue_time_entries_path(issue)})"
143 143 s.html_safe
144 144 end
145 145 end
146 146 end
147 147
148 148 # Returns an array of error messages for bulk edited issues
149 149 def bulk_edit_error_messages(issues)
150 150 messages = {}
151 151 issues.each do |issue|
152 152 issue.errors.full_messages.each do |message|
153 153 messages[message] ||= []
154 154 messages[message] << issue
155 155 end
156 156 end
157 157 messages.map { |message, issues|
158 158 "#{message}: " + issues.map {|i| "##{i.id}"}.join(', ')
159 159 }
160 160 end
161 161
162 162 # Returns a link for adding a new subtask to the given issue
163 163 def link_to_new_subtask(issue)
164 164 attrs = {
165 165 :tracker_id => issue.tracker,
166 166 :parent_issue_id => issue
167 167 }
168 168 link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
169 169 end
170 170
171 171 class IssueFieldsRows
172 172 include ActionView::Helpers::TagHelper
173 173
174 174 def initialize
175 175 @left = []
176 176 @right = []
177 177 end
178 178
179 179 def left(*args)
180 180 args.any? ? @left << cells(*args) : @left
181 181 end
182 182
183 183 def right(*args)
184 184 args.any? ? @right << cells(*args) : @right
185 185 end
186 186
187 187 def size
188 188 @left.size > @right.size ? @left.size : @right.size
189 189 end
190 190
191 191 def to_html
192 html = ''.html_safe
193 blank = content_tag('th', '') + content_tag('td', '')
194 size.times do |i|
195 left = @left[i] || blank
196 right = @right[i] || blank
197 html << content_tag('tr', left + right)
198 end
199 html
192 content =
193 content_tag('div', @left.reduce(&:+), :class => 'splitcontentleft') +
194 content_tag('div', @right.reduce(&:+), :class => 'splitcontentleft')
195
196 content_tag('div', content, :class => 'splitcontent')
200 197 end
201 198
202 199 def cells(label, text, options={})
203 content_tag('th', label + ":", options) + content_tag('td', text, options)
200 options[:class] = [options[:class] || "", 'attribute'].join(' ')
201 content_tag 'div',
202 content_tag('div', label + ":", :class => 'label') + content_tag('div', text, :class => 'value'),
203 options
204 204 end
205 205 end
206 206
207 207 def issue_fields_rows
208 208 r = IssueFieldsRows.new
209 209 yield r
210 210 r.to_html
211 211 end
212 212
213 213 def render_custom_fields_rows(issue)
214 214 values = issue.visible_custom_field_values
215 215 return if values.empty?
216 216 half = (values.size / 2.0).ceil
217 217 issue_fields_rows do |rows|
218 218 values.each_with_index do |value, i|
219 219 css = "cf_#{value.custom_field.id}"
220 220 m = (i < half ? :left : :right)
221 221 rows.send m, custom_field_name_tag(value.custom_field), show_value(value), :class => css
222 222 end
223 223 end
224 224 end
225 225
226 226 # Returns the path for updating the issue form
227 227 # with project as the current project
228 228 def update_issue_form_path(project, issue)
229 229 options = {:format => 'js'}
230 230 if issue.new_record?
231 231 if project
232 232 new_project_issue_path(project, options)
233 233 else
234 234 new_issue_path(options)
235 235 end
236 236 else
237 237 edit_issue_path(issue, options)
238 238 end
239 239 end
240 240
241 241 # Returns the number of descendants for an array of issues
242 242 def issues_descendant_count(issues)
243 243 ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
244 244 ids -= issues.map(&:id)
245 245 ids.size
246 246 end
247 247
248 248 def issues_destroy_confirmation_message(issues)
249 249 issues = [issues] unless issues.is_a?(Array)
250 250 message = l(:text_issues_destroy_confirmation)
251 251
252 252 descendant_count = issues_descendant_count(issues)
253 253 if descendant_count > 0
254 254 message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
255 255 end
256 256 message
257 257 end
258 258
259 259 # Returns an array of users that are proposed as watchers
260 260 # on the new issue form
261 261 def users_for_new_issue_watchers(issue)
262 262 users = issue.watcher_users
263 263 if issue.project.users.count <= 20
264 264 users = (users + issue.project.users.sort).uniq
265 265 end
266 266 users
267 267 end
268 268
269 269 def sidebar_queries
270 270 unless @sidebar_queries
271 271 @sidebar_queries = IssueQuery.visible.
272 272 order("#{Query.table_name}.name ASC").
273 273 # Project specific queries and global queries
274 274 where(@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id]).
275 275 to_a
276 276 end
277 277 @sidebar_queries
278 278 end
279 279
280 280 def query_links(title, queries)
281 281 return '' if queries.empty?
282 282 # links to #index on issues/show
283 283 url_params = controller_name == 'issues' ? {:controller => 'issues', :action => 'index', :project_id => @project} : params
284 284
285 285 content_tag('h3', title) + "\n" +
286 286 content_tag('ul',
287 287 queries.collect {|query|
288 288 css = 'query'
289 289 css << ' selected' if query == @query
290 290 content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css))
291 291 }.join("\n").html_safe,
292 292 :class => 'queries'
293 293 ) + "\n"
294 294 end
295 295
296 296 def render_sidebar_queries
297 297 out = ''.html_safe
298 298 out << query_links(l(:label_my_queries), sidebar_queries.select(&:is_private?))
299 299 out << query_links(l(:label_query_plural), sidebar_queries.reject(&:is_private?))
300 300 out
301 301 end
302 302
303 303 def email_issue_attributes(issue, user)
304 304 items = []
305 305 %w(author status priority assigned_to category fixed_version).each do |attribute|
306 306 unless issue.disabled_core_fields.include?(attribute+"_id")
307 307 items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
308 308 end
309 309 end
310 310 issue.visible_custom_field_values(user).each do |value|
311 311 items << "#{value.custom_field.name}: #{show_value(value, false)}"
312 312 end
313 313 items
314 314 end
315 315
316 316 def render_email_issue_attributes(issue, user, html=false)
317 317 items = email_issue_attributes(issue, user)
318 318 if html
319 319 content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
320 320 else
321 321 items.map{|s| "* #{s}"}.join("\n")
322 322 end
323 323 end
324 324
325 325 # Returns the textual representation of a journal details
326 326 # as an array of strings
327 327 def details_to_strings(details, no_html=false, options={})
328 328 options[:only_path] = (options[:only_path] == false ? false : true)
329 329 strings = []
330 330 values_by_field = {}
331 331 details.each do |detail|
332 332 if detail.property == 'cf'
333 333 field = detail.custom_field
334 334 if field && field.multiple?
335 335 values_by_field[field] ||= {:added => [], :deleted => []}
336 336 if detail.old_value
337 337 values_by_field[field][:deleted] << detail.old_value
338 338 end
339 339 if detail.value
340 340 values_by_field[field][:added] << detail.value
341 341 end
342 342 next
343 343 end
344 344 end
345 345 strings << show_detail(detail, no_html, options)
346 346 end
347 347 if values_by_field.present?
348 348 multiple_values_detail = Struct.new(:property, :prop_key, :custom_field, :old_value, :value)
349 349 values_by_field.each do |field, changes|
350 350 if changes[:added].any?
351 351 detail = multiple_values_detail.new('cf', field.id.to_s, field)
352 352 detail.value = changes[:added]
353 353 strings << show_detail(detail, no_html, options)
354 354 end
355 355 if changes[:deleted].any?
356 356 detail = multiple_values_detail.new('cf', field.id.to_s, field)
357 357 detail.old_value = changes[:deleted]
358 358 strings << show_detail(detail, no_html, options)
359 359 end
360 360 end
361 361 end
362 362 strings
363 363 end
364 364
365 365 # Returns the textual representation of a single journal detail
366 366 def show_detail(detail, no_html=false, options={})
367 367 multiple = false
368 368 show_diff = false
369 369
370 370 case detail.property
371 371 when 'attr'
372 372 field = detail.prop_key.to_s.gsub(/\_id$/, "")
373 373 label = l(("field_" + field).to_sym)
374 374 case detail.prop_key
375 375 when 'due_date', 'start_date'
376 376 value = format_date(detail.value.to_date) if detail.value
377 377 old_value = format_date(detail.old_value.to_date) if detail.old_value
378 378
379 379 when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id',
380 380 'priority_id', 'category_id', 'fixed_version_id'
381 381 value = find_name_by_reflection(field, detail.value)
382 382 old_value = find_name_by_reflection(field, detail.old_value)
383 383
384 384 when 'estimated_hours'
385 385 value = "%0.02f" % detail.value.to_f unless detail.value.blank?
386 386 old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank?
387 387
388 388 when 'parent_id'
389 389 label = l(:field_parent_issue)
390 390 value = "##{detail.value}" unless detail.value.blank?
391 391 old_value = "##{detail.old_value}" unless detail.old_value.blank?
392 392
393 393 when 'is_private'
394 394 value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank?
395 395 old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank?
396 396
397 397 when 'description'
398 398 show_diff = true
399 399 end
400 400 when 'cf'
401 401 custom_field = detail.custom_field
402 402 if custom_field
403 403 label = custom_field.name
404 404 if custom_field.format.class.change_as_diff
405 405 show_diff = true
406 406 else
407 407 multiple = custom_field.multiple?
408 408 value = format_value(detail.value, custom_field) if detail.value
409 409 old_value = format_value(detail.old_value, custom_field) if detail.old_value
410 410 end
411 411 end
412 412 when 'attachment'
413 413 label = l(:label_attachment)
414 414 when 'relation'
415 415 if detail.value && !detail.old_value
416 416 rel_issue = Issue.visible.find_by_id(detail.value)
417 417 value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.value}" :
418 418 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
419 419 elsif detail.old_value && !detail.value
420 420 rel_issue = Issue.visible.find_by_id(detail.old_value)
421 421 old_value = rel_issue.nil? ? "#{l(:label_issue)} ##{detail.old_value}" :
422 422 (no_html ? rel_issue : link_to_issue(rel_issue, :only_path => options[:only_path]))
423 423 end
424 424 relation_type = IssueRelation::TYPES[detail.prop_key]
425 425 label = l(relation_type[:name]) if relation_type
426 426 end
427 427 call_hook(:helper_issues_show_detail_after_setting,
428 428 {:detail => detail, :label => label, :value => value, :old_value => old_value })
429 429
430 430 label ||= detail.prop_key
431 431 value ||= detail.value
432 432 old_value ||= detail.old_value
433 433
434 434 unless no_html
435 435 label = content_tag('strong', label)
436 436 old_value = content_tag("i", h(old_value)) if detail.old_value
437 437 if detail.old_value && detail.value.blank? && detail.property != 'relation'
438 438 old_value = content_tag("del", old_value)
439 439 end
440 440 if detail.property == 'attachment' && value.present? &&
441 441 atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
442 442 # Link to the attachment if it has not been removed
443 443 value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
444 444 if options[:only_path] != false && atta.is_text?
445 445 value += link_to(
446 446 image_tag('magnifier.png'),
447 447 :controller => 'attachments', :action => 'show',
448 448 :id => atta, :filename => atta.filename
449 449 )
450 450 end
451 451 else
452 452 value = content_tag("i", h(value)) if value
453 453 end
454 454 end
455 455
456 456 if show_diff
457 457 s = l(:text_journal_changed_no_detail, :label => label)
458 458 unless no_html
459 459 diff_link = link_to 'diff',
460 460 {:controller => 'journals', :action => 'diff', :id => detail.journal_id,
461 461 :detail_id => detail.id, :only_path => options[:only_path]},
462 462 :title => l(:label_view_diff)
463 463 s << " (#{ diff_link })"
464 464 end
465 465 s.html_safe
466 466 elsif detail.value.present?
467 467 case detail.property
468 468 when 'attr', 'cf'
469 469 if detail.old_value.present?
470 470 l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe
471 471 elsif multiple
472 472 l(:text_journal_added, :label => label, :value => value).html_safe
473 473 else
474 474 l(:text_journal_set_to, :label => label, :value => value).html_safe
475 475 end
476 476 when 'attachment', 'relation'
477 477 l(:text_journal_added, :label => label, :value => value).html_safe
478 478 end
479 479 else
480 480 l(:text_journal_deleted, :label => label, :old => old_value).html_safe
481 481 end
482 482 end
483 483
484 484 # Find the name of an associated record stored in the field attribute
485 485 def find_name_by_reflection(field, id)
486 486 unless id.present?
487 487 return nil
488 488 end
489 489 @detail_value_name_by_reflection ||= Hash.new do |hash, key|
490 490 association = Issue.reflect_on_association(key.first.to_sym)
491 491 name = nil
492 492 if association
493 493 record = association.klass.find_by_id(key.last)
494 494 if record
495 495 name = record.name.force_encoding('UTF-8')
496 496 end
497 497 end
498 498 hash[key] = name
499 499 end
500 500 @detail_value_name_by_reflection[[field, id]]
501 501 end
502 502
503 503 # Renders issue children recursively
504 504 def render_api_issue_children(issue, api)
505 505 return if issue.leaf?
506 506 api.array :children do
507 507 issue.children.each do |child|
508 508 api.issue(:id => child.id) do
509 509 api.tracker(:id => child.tracker_id, :name => child.tracker.name) unless child.tracker.nil?
510 510 api.subject child.subject
511 511 render_api_issue_children(child, api)
512 512 end
513 513 end
514 514 end
515 515 end
516 516 end
@@ -1,162 +1,162
1 1 <%= render :partial => 'action_menu' %>
2 2
3 3 <h2><%= issue_heading(@issue) %></h2>
4 4
5 5 <div class="<%= @issue.css_classes %> details">
6 6 <% if @prev_issue_id || @next_issue_id %>
7 7 <div class="next-prev-links contextual">
8 8 <%= link_to_if @prev_issue_id,
9 9 "\xc2\xab #{l(:label_previous)}",
10 10 (@prev_issue_id ? issue_path(@prev_issue_id) : nil),
11 11 :title => "##{@prev_issue_id}",
12 12 :accesskey => accesskey(:previous) %> |
13 13 <% if @issue_position && @issue_count %>
14 14 <span class="position"><%= l(:label_item_position, :position => @issue_position, :count => @issue_count) %></span> |
15 15 <% end %>
16 16 <%= link_to_if @next_issue_id,
17 17 "#{l(:label_next)} \xc2\xbb",
18 18 (@next_issue_id ? issue_path(@next_issue_id) : nil),
19 19 :title => "##{@next_issue_id}",
20 20 :accesskey => accesskey(:next) %>
21 21 </div>
22 22 <% end %>
23 23
24 24 <%= avatar(@issue.author, :size => "50") %>
25 25
26 26 <div class="subject">
27 27 <%= render_issue_subject_with_tree(@issue) %>
28 28 </div>
29 29 <p class="author">
30 30 <%= authoring @issue.created_on, @issue.author %>.
31 31 <% if @issue.created_on != @issue.updated_on %>
32 32 <%= l(:label_updated_time, time_tag(@issue.updated_on)).html_safe %>.
33 33 <% end %>
34 34 </p>
35 35
36 <table class="attributes">
36 <div class="attributes">
37 37 <%= issue_fields_rows do |rows|
38 38 rows.left l(:field_status), @issue.status.name, :class => 'status'
39 39 rows.left l(:field_priority), @issue.priority.name, :class => 'priority'
40 40
41 41 unless @issue.disabled_core_fields.include?('assigned_to_id')
42 42 rows.left l(:field_assigned_to), avatar(@issue.assigned_to, :size => "14").to_s.html_safe + (@issue.assigned_to ? link_to_user(@issue.assigned_to) : "-"), :class => 'assigned-to'
43 43 end
44 44 unless @issue.disabled_core_fields.include?('category_id') || (@issue.category.nil? && @issue.project.issue_categories.none?)
45 45 rows.left l(:field_category), (@issue.category ? @issue.category.name : "-"), :class => 'category'
46 46 end
47 47 unless @issue.disabled_core_fields.include?('fixed_version_id') || (@issue.fixed_version.nil? && @issue.assignable_versions.none?)
48 48 rows.left l(:field_fixed_version), (@issue.fixed_version ? link_to_version(@issue.fixed_version) : "-"), :class => 'fixed-version'
49 49 end
50 50
51 51 unless @issue.disabled_core_fields.include?('start_date')
52 52 rows.right l(:field_start_date), format_date(@issue.start_date), :class => 'start-date'
53 53 end
54 54 unless @issue.disabled_core_fields.include?('due_date')
55 55 rows.right l(:field_due_date), format_date(@issue.due_date), :class => 'due-date'
56 56 end
57 57 unless @issue.disabled_core_fields.include?('done_ratio')
58 58 rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%"), :class => 'progress'
59 59 end
60 60 unless @issue.disabled_core_fields.include?('estimated_hours')
61 61 if @issue.estimated_hours.present? || @issue.total_estimated_hours.to_f > 0
62 62 rows.right l(:field_estimated_hours), issue_estimated_hours_details(@issue), :class => 'estimated-hours'
63 63 end
64 64 end
65 65 if User.current.allowed_to_view_all_time_entries?(@project)
66 66 if @issue.total_spent_hours > 0
67 67 rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
68 68 end
69 69 end
70 70 end %>
71 71 <%= render_custom_fields_rows(@issue) %>
72 72 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
73 </table>
73 </div>
74 74
75 75 <% if @issue.description? || @issue.attachments.any? -%>
76 76 <hr />
77 77 <% if @issue.description? %>
78 78 <div class="description">
79 79 <div class="contextual">
80 80 <%= link_to l(:button_quote), quoted_issue_path(@issue), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %>
81 81 </div>
82 82
83 83 <p><strong><%=l(:field_description)%></strong></p>
84 84 <div class="wiki">
85 85 <%= textilizable @issue, :description, :attachments => @issue.attachments %>
86 86 </div>
87 87 </div>
88 88 <% end %>
89 89 <%= link_to_attachments @issue, :thumbnails => true %>
90 90 <% end -%>
91 91
92 92 <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
93 93
94 94 <% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
95 95 <hr />
96 96 <div id="issue_tree">
97 97 <div class="contextual">
98 98 <%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
99 99 </div>
100 100 <p><strong><%=l(:label_subtask_plural)%></strong></p>
101 101 <%= render_descendants_tree(@issue) unless @issue.leaf? %>
102 102 </div>
103 103 <% end %>
104 104
105 105 <% if @relations.present? || User.current.allowed_to?(:manage_issue_relations, @project) %>
106 106 <hr />
107 107 <div id="relations">
108 108 <%= render :partial => 'relations' %>
109 109 </div>
110 110 <% end %>
111 111
112 112 </div>
113 113
114 114 <% if @changesets.present? %>
115 115 <div id="issue-changesets">
116 116 <h3><%=l(:label_associated_revisions)%></h3>
117 117 <%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
118 118 </div>
119 119 <% end %>
120 120
121 121 <% if @journals.present? %>
122 122 <div id="history">
123 123 <h3><%=l(:label_history)%></h3>
124 124 <%= render :partial => 'history', :locals => { :issue => @issue, :journals => @journals } %>
125 125 </div>
126 126 <% end %>
127 127
128 128
129 129 <div style="clear: both;"></div>
130 130 <%= render :partial => 'action_menu' %>
131 131
132 132 <div style="clear: both;"></div>
133 133 <% if @issue.editable? %>
134 134 <div id="update" style="display:none;">
135 135 <h3><%= l(:button_edit) %></h3>
136 136 <%= render :partial => 'edit' %>
137 137 </div>
138 138 <% end %>
139 139
140 140 <% other_formats_links do |f| %>
141 141 <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
142 142 <%= f.link_to 'PDF' %>
143 143 <% end %>
144 144
145 145 <% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
146 146
147 147 <% content_for :sidebar do %>
148 148 <%= render :partial => 'issues/sidebar' %>
149 149
150 150 <% if User.current.allowed_to?(:add_issue_watchers, @project) ||
151 151 (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
152 152 <div id="watchers">
153 153 <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %>
154 154 </div>
155 155 <% end %>
156 156 <% end %>
157 157
158 158 <% content_for :header_tags do %>
159 159 <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
160 160 <% end %>
161 161
162 162 <%= context_menu issues_context_menu_path %>
@@ -1,1265 +1,1262
1 1 html {overflow-y:scroll;}
2 2 body { font-family: Verdana, sans-serif; font-size: 12px; color:#333; margin: 0; padding: 0; min-width: 900px; }
3 3
4 4 h1, h2, h3, h4 {font-family: "Trebuchet MS", Verdana, sans-serif;padding: 2px 10px 1px 0px;margin: 0 0 10px 0;}
5 5 #content h1, h2, h3, h4 {color: #555;}
6 6 h2, .wiki h1 {font-size: 20px;}
7 7 h3, .wiki h2 {font-size: 16px;}
8 8 h4, .wiki h3 {font-size: 13px;}
9 9 h4 {border-bottom: 1px dotted #bbb;}
10 10 pre, code {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;}
11 11
12 12 /***** Layout *****/
13 13 #wrapper {background: white;}
14 14
15 15 #top-menu {background: #3E5B76; color: #fff; height:1.8em; font-size: 0.8em; padding: 2px 2px 0px 6px;}
16 16 #top-menu ul {margin: 0; padding: 0;}
17 17 #top-menu li {
18 18 float:left;
19 19 list-style-type:none;
20 20 margin: 0px 0px 0px 0px;
21 21 padding: 0px 0px 0px 0px;
22 22 white-space:nowrap;
23 23 }
24 24 #top-menu a {color: #fff; margin-right: 8px; font-weight: bold;}
25 25 #top-menu #loggedas { float: right; margin-right: 0.5em; color: #fff; }
26 26
27 27 #account {float:right;}
28 28
29 29 #header {min-height:5.3em;margin:0;background-color:#628DB6;color:#f8f8f8; padding: 4px 8px 20px 6px; position:relative;}
30 30 #header a {color:#f8f8f8;}
31 31 #header h1 a.ancestor { font-size: 80%; }
32 32 #quick-search {float:right;}
33 33
34 34 #main-menu {position: absolute; bottom: 0px; left:6px; margin-right: -500px;}
35 35 #main-menu ul {margin: 0; padding: 0;}
36 36 #main-menu li {
37 37 float:left;
38 38 list-style-type:none;
39 39 margin: 0px 2px 0px 0px;
40 40 padding: 0px 0px 0px 0px;
41 41 white-space:nowrap;
42 42 }
43 43 #main-menu li a {
44 44 display: block;
45 45 color: #fff;
46 46 text-decoration: none;
47 47 font-weight: bold;
48 48 margin: 0;
49 49 padding: 4px 10px 4px 10px;
50 50 }
51 51 #main-menu li a:hover {background:#759FCF; color:#fff;}
52 52 #main-menu li a.selected, #main-menu li a.selected:hover {background:#fff; color:#555;}
53 53
54 54 #admin-menu ul {margin: 0; padding: 0;}
55 55 #admin-menu li {margin: 0; padding: 0 0 6px 0; list-style-type:none;}
56 56
57 57 #admin-menu a { background-position: 0% 40%; background-repeat: no-repeat; padding-left: 20px; padding-top: 2px; padding-bottom: 3px;}
58 58 #admin-menu a.projects { background-image: url(../images/projects.png); }
59 59 #admin-menu a.users { background-image: url(../images/user.png); }
60 60 #admin-menu a.groups { background-image: url(../images/group.png); }
61 61 #admin-menu a.roles { background-image: url(../images/database_key.png); }
62 62 #admin-menu a.trackers { background-image: url(../images/ticket.png); }
63 63 #admin-menu a.issue_statuses { background-image: url(../images/ticket_edit.png); }
64 64 #admin-menu a.workflows { background-image: url(../images/ticket_go.png); }
65 65 #admin-menu a.custom_fields { background-image: url(../images/textfield.png); }
66 66 #admin-menu a.enumerations { background-image: url(../images/text_list_bullets.png); }
67 67 #admin-menu a.settings { background-image: url(../images/changeset.png); }
68 68 #admin-menu a.plugins { background-image: url(../images/plugin.png); }
69 69 #admin-menu a.info { background-image: url(../images/help.png); }
70 70 #admin-menu a.server_authentication { background-image: url(../images/server_key.png); }
71 71
72 72 #main {background-color:#EEEEEE;}
73 73
74 74 #sidebar{ float: right; width: 22%; position: relative; z-index: 9; padding: 0; margin: 0;}
75 75 * html #sidebar{ width: 22%; }
76 76 #sidebar h3{ font-size: 14px; margin-top:14px; color: #666; }
77 77 #sidebar hr{ width: 100%; margin: 0 auto; height: 1px; background: #ccc; border: 0; }
78 78 * html #sidebar hr{ width: 95%; position: relative; left: -6px; color: #ccc; }
79 79 #sidebar .contextual { margin-right: 1em; }
80 80 #sidebar ul, ul.flat {margin: 0; padding: 0;}
81 81 #sidebar ul li, ul.flat li {list-style-type:none;margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;}
82 82
83 83 #content { width: 75%; background-color: #fff; margin: 0px; border-right: 1px solid #ddd; padding: 6px 10px 10px 10px; z-index: 10; }
84 84 * html #content{ width: 75%; padding-left: 0; margin-top: 0px; padding: 6px 10px 10px 10px;}
85 85 html>body #content { min-height: 600px; }
86 86 * html body #content { height: 600px; } /* IE */
87 87
88 88 #main.nosidebar #sidebar{ display: none; }
89 89 #main.nosidebar #content{ width: auto; border-right: 0; }
90 90
91 91 #footer {clear: both; border-top: 1px solid #bbb; font-size: 0.9em; color: #aaa; padding: 5px; text-align:center; background:#fff;}
92 92
93 93 #login-form table {margin-top:5em; padding:1em; margin-left: auto; margin-right: auto; border: 2px solid #FDBF3B; background-color:#FFEBC1; }
94 94 #login-form table td {padding: 6px;}
95 95 #login-form label {font-weight: bold;}
96 96 #login-form input#username, #login-form input#password { width: 300px; }
97 97
98 98 div.modal { border-radius:5px; background:#fff; z-index:50; padding:4px;}
99 99 div.modal h3.title {display:none;}
100 100 div.modal p.buttons {text-align:right; margin-bottom:0;}
101 101 div.modal .box p {margin: 0.3em 0;}
102 102
103 103 input#openid_url { background: url(../images/openid-bg.gif) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; }
104 104
105 105 .clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }
106 106
107 107 /***** Links *****/
108 108 a, a:link, a:visited{ color: #169; text-decoration: none; }
109 109 a:hover, a:active{ color: #c61a1a; text-decoration: underline;}
110 110 a img{ border: 0; }
111 111
112 112 a.issue.closed, a.issue.closed:link, a.issue.closed:visited { color: #999; text-decoration: line-through; }
113 113 a.project.closed, a.project.closed:link, a.project.closed:visited { color: #999; }
114 114 a.user.locked, a.user.locked:link, a.user.locked:visited {color: #999;}
115 115
116 116 #sidebar a.selected {line-height:1.7em; padding:1px 3px 2px 2px; margin-left:-2px; background-color:#9DB9D5; color:#fff; border-radius:2px;}
117 117 #sidebar a.selected:hover {text-decoration:none;}
118 118 #admin-menu a {line-height:1.7em;}
119 119 #admin-menu a.selected {padding-left: 20px !important; background-position: 2px 40%;}
120 120
121 121 a.collapsible {padding-left: 12px; background: url(../images/arrow_expanded.png) no-repeat -3px 40%;}
122 122 a.collapsible.collapsed {background: url(../images/arrow_collapsed.png) no-repeat -5px 40%;}
123 123
124 124 a#toggle-completed-versions {color:#999;}
125 125 /***** Tables *****/
126 126 table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; }
127 127 table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; }
128 128 table.list td {text-align:center; vertical-align:top; padding-right:10px;}
129 129 table.list td.id { width: 2%; text-align: center;}
130 130 table.list td.name, table.list td.description, table.list td.subject, table.list td.comments, table.list td.roles {text-align: left;}
131 131 table.list td.tick {width:15%}
132 132 table.list td.checkbox { width: 15px; padding: 2px 0 0 0; }
133 133 table.list td.checkbox input {padding:0px;}
134 134 table.list td.buttons { width: 15%; white-space:nowrap; text-align: right; }
135 135 table.list td.buttons a { padding-right: 0.6em; }
136 136 table.list td.buttons img {vertical-align:middle;}
137 137 table.list td.reorder {width:15%; white-space:nowrap; text-align:center; }
138 138 table.list caption { text-align: left; padding: 0.5em 0.5em 0.5em 0; }
139 139
140 140 tr.project td.name a { white-space:nowrap; }
141 141 tr.project.closed, tr.project.archived { color: #aaa; }
142 142 tr.project.closed a, tr.project.archived a { color: #aaa; }
143 143
144 144 tr.project.idnt td.name span {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%; padding-left: 16px;}
145 145 tr.project.idnt-1 td.name {padding-left: 0.5em;}
146 146 tr.project.idnt-2 td.name {padding-left: 2em;}
147 147 tr.project.idnt-3 td.name {padding-left: 3.5em;}
148 148 tr.project.idnt-4 td.name {padding-left: 5em;}
149 149 tr.project.idnt-5 td.name {padding-left: 6.5em;}
150 150 tr.project.idnt-6 td.name {padding-left: 8em;}
151 151 tr.project.idnt-7 td.name {padding-left: 9.5em;}
152 152 tr.project.idnt-8 td.name {padding-left: 11em;}
153 153 tr.project.idnt-9 td.name {padding-left: 12.5em;}
154 154
155 155 tr.issue { text-align: center; white-space: nowrap; }
156 156 tr.issue td.subject, tr.issue td.category, td.assigned_to, tr.issue td.string, tr.issue td.text, tr.issue td.relations, tr.issue td.parent { white-space: normal; }
157 157 tr.issue td.relations { text-align: left; }
158 158 tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
159 159 tr.issue td.relations span {white-space: nowrap;}
160 160 table.issues td.description {color:#777; font-size:90%; padding:4px 4px 4px 24px; text-align:left; white-space:normal;}
161 161 table.issues td.description pre {white-space:normal;}
162 162
163 163 tr.issue.idnt td.subject a {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%; padding-left: 16px;}
164 164 tr.issue.idnt-1 td.subject {padding-left: 0.5em;}
165 165 tr.issue.idnt-2 td.subject {padding-left: 2em;}
166 166 tr.issue.idnt-3 td.subject {padding-left: 3.5em;}
167 167 tr.issue.idnt-4 td.subject {padding-left: 5em;}
168 168 tr.issue.idnt-5 td.subject {padding-left: 6.5em;}
169 169 tr.issue.idnt-6 td.subject {padding-left: 8em;}
170 170 tr.issue.idnt-7 td.subject {padding-left: 9.5em;}
171 171 tr.issue.idnt-8 td.subject {padding-left: 11em;}
172 172 tr.issue.idnt-9 td.subject {padding-left: 12.5em;}
173 173
174 174 table.issue-report {table-layout:fixed;}
175 175
176 176 tr.entry { border: 1px solid #f8f8f8; }
177 177 tr.entry td { white-space: nowrap; }
178 178 tr.entry td.filename {width:30%; text-align:left;}
179 179 tr.entry td.filename_no_report {width:70%; text-align:left;}
180 180 tr.entry td.size { text-align: right; font-size: 90%; }
181 181 tr.entry td.revision, tr.entry td.author { text-align: center; }
182 182 tr.entry td.age { text-align: right; }
183 183 tr.entry.file td.filename a { margin-left: 16px; }
184 184 tr.entry.file td.filename_no_report a { margin-left: 16px; }
185 185
186 186 tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;}
187 187 tr.open span.expander {background-image: url(../images/bullet_toggle_minus.png);}
188 188
189 189 tr.changeset { height: 20px }
190 190 tr.changeset ul, ol { margin-top: 0px; margin-bottom: 0px; }
191 191 tr.changeset td.revision_graph { width: 15%; background-color: #fffffb; }
192 192 tr.changeset td.author { text-align: center; width: 15%; white-space:nowrap;}
193 193 tr.changeset td.committed_on { text-align: center; width: 15%; white-space:nowrap;}
194 194
195 195 table.files tbody th {text-align:left;}
196 196 table.files tr.file td.filename { text-align: left; padding-left: 24px; }
197 197 table.files tr.file td.digest { font-size: 80%; }
198 198
199 199 table.members td.roles, table.memberships td.roles { width: 45%; }
200 200
201 201 tr.message { height: 2.6em; }
202 202 tr.message td.subject { padding-left: 20px; }
203 203 tr.message td.created_on { white-space: nowrap; }
204 204 tr.message td.last_message { font-size: 80%; white-space: nowrap; }
205 205 tr.message.locked td.subject { background: url(../images/locked.png) no-repeat 0 1px; }
206 206 tr.message.sticky td.subject { background: url(../images/bullet_go.png) no-repeat 0 1px; font-weight: bold; }
207 207
208 208 tr.version.closed, tr.version.closed a { color: #999; }
209 209 tr.version td.name { padding-left: 20px; }
210 210 tr.version.shared td.name { background: url(../images/link.png) no-repeat 0% 70%; }
211 211 tr.version td.date, tr.version td.status, tr.version td.sharing { text-align: center; white-space:nowrap; }
212 212
213 213 tr.user td {width:13%;white-space: nowrap;}
214 214 td.username, td.firstname, td.lastname, td.email {text-align:left !important;}
215 215 tr.user td.email { width:18%; }
216 216 tr.user.locked, tr.user.registered { color: #aaa; }
217 217 tr.user.locked a, tr.user.registered a { color: #aaa; }
218 218
219 219 table.permissions td.role {color:#999;font-size:90%;font-weight:normal !important;text-align:center;vertical-align:bottom;}
220 220
221 221 tr.wiki-page-version td.updated_on, tr.wiki-page-version td.author {text-align:center;}
222 222
223 223 tr.time-entry { text-align: center; white-space: nowrap; }
224 224 tr.time-entry td.issue, tr.time-entry td.comments, tr.time-entry td.subject, tr.time-entry td.activity { text-align: left; white-space: normal; }
225 225 td.hours { text-align: right; font-weight: bold; padding-right: 0.5em; }
226 226 td.hours .hours-dec { font-size: 0.9em; }
227 227
228 228 table.plugins td { vertical-align: middle; }
229 229 table.plugins td.configure { text-align: right; padding-right: 1em; }
230 230 table.plugins span.name { font-weight: bold; display: block; margin-bottom: 6px; }
231 231 table.plugins span.description { display: block; font-size: 0.9em; }
232 232 table.plugins span.url { display: block; font-size: 0.9em; }
233 233
234 234 tr.group td { padding: 0.8em 0 0.5em 0.3em; border-bottom: 1px solid #ccc; text-align:left; }
235 235 tr.group span.name {font-weight:bold;}
236 236 tr.group span.count {font-weight:bold; position:relative; top:-1px; color:#fff; font-size:10px; background:#9DB9D5; padding:0px 6px 1px 6px; border-radius:3px; margin-left:4px;}
237 237 tr.group span.totals {color: #aaa; font-size: 80%;}
238 238 tr.group span.totals .value {font-weight:bold; color:#777;}
239 239 tr.group a.toggle-all { color: #aaa; font-size: 80%; display:none; float:right; margin-right:4px;}
240 240 tr.group:hover a.toggle-all { display:inline;}
241 241 a.toggle-all:hover {text-decoration:none;}
242 242
243 243 table.list tbody tr:hover { background-color:#ffffdd; }
244 244 table.list tbody tr.group:hover { background-color:inherit; }
245 245 table td {padding:2px;}
246 246 table p {margin:0;}
247 247 .odd {background-color:#f6f7f8;}
248 248 .even {background-color: #fff;}
249 249
250 250 tr.builtin td.name {font-style:italic;}
251 251
252 252 a.sort { padding-right: 16px; background-position: 100% 50%; background-repeat: no-repeat; }
253 253 a.sort.asc { background-image: url(../images/sort_asc.png); }
254 254 a.sort.desc { background-image: url(../images/sort_desc.png); }
255 255
256 table.attributes { width: 100% }
257 table.attributes th { vertical-align: top; text-align: left; }
258 table.attributes td { vertical-align: top; }
259
260 256 table.boards a.board, h3.comments { background: url(../images/comment.png) no-repeat 0% 50%; padding-left: 20px; }
261 257 table.boards td.last-message {text-align:left;font-size:80%;}
262 258
263 259 table.messages td.last_message {text-align:left;}
264 260
265 261 #query_form_content {font-size:90%;}
266 262
267 263 .query_sort_criteria_count {
268 264 display: inline-block;
269 265 min-width: 1em;
270 266 }
271 267
272 268 table.query-columns {
273 269 border-collapse: collapse;
274 270 border: 0;
275 271 }
276 272
277 273 table.query-columns td.buttons {
278 274 vertical-align: middle;
279 275 text-align: center;
280 276 }
281 277 table.query-columns td.buttons input[type=button] {width:35px;}
282 278 .query-totals {text-align:right; margin-top:-2.3em;}
283 279 .query-totals>span {margin-left:0.6em;}
284 280 .query-totals .value {font-weight:bold;}
285 281
286 282 td.center {text-align:center;}
287 283
288 284 h3.version { background: url(../images/package.png) no-repeat 0% 50%; padding-left: 20px; }
289 285
290 286 div.issues h3 { background: url(../images/ticket.png) no-repeat 0% 50%; padding-left: 20px; }
291 287 div.members h3 { background: url(../images/group.png) no-repeat 0% 50%; padding-left: 20px; }
292 288 div.news h3 { background: url(../images/news.png) no-repeat 0% 50%; padding-left: 20px; }
293 289 div.projects h3 { background: url(../images/projects.png) no-repeat 0% 50%; padding-left: 20px; }
294 290
295 291 #watchers select {width: 95%; display: block;}
296 292 #watchers a.delete {opacity: 0.4; vertical-align: middle;}
297 293 #watchers a.delete:hover {opacity: 1;}
298 294 #watchers img.gravatar {margin: 0 4px 2px 0;}
299 295
300 296 span#watchers_inputs {overflow:auto; display:block;}
301 297 span.search_for_watchers {display:block;}
302 298 span.search_for_watchers, span.add_attachment {font-size:80%; line-height:2.5em;}
303 299 span.search_for_watchers a, span.add_attachment a {padding-left:16px; background: url(../images/bullet_add.png) no-repeat 0 50%; }
304 300
305 301
306 302 .highlight { background-color: #FCFD8D;}
307 303 .highlight.token-1 { background-color: #faa;}
308 304 .highlight.token-2 { background-color: #afa;}
309 305 .highlight.token-3 { background-color: #aaf;}
310 306
311 307 .box{
312 308 padding:6px;
313 309 margin-bottom: 10px;
314 310 background-color:#f6f6f6;
315 311 color:#505050;
316 312 line-height:1.5em;
317 313 border: 1px solid #e4e4e4;
318 314 word-wrap: break-word;
319 315 border-radius: 3px;
320 316 }
321 317
322 318 div.square {
323 319 border: 1px solid #999;
324 320 float: left;
325 321 margin: .3em .4em 0 .4em;
326 322 overflow: hidden;
327 323 width: .6em; height: .6em;
328 324 }
329 325 .contextual {float:right; white-space: nowrap; line-height:1.4em;margin-top:5px; padding-left: 10px; font-size:0.9em;}
330 326 .contextual input, .contextual select {font-size:0.9em;}
331 327 .message .contextual { margin-top: 0; }
332 328
333 329 .splitcontent {overflow:auto;}
334 330 .splitcontentleft{float:left; width:49%;}
335 331 .splitcontentright{float:right; width:49%;}
336 332 form {display: inline;}
337 333 input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;}
338 334 fieldset {border: 1px solid #e4e4e4; margin:0;}
339 335 legend {color: #333;}
340 336 hr { width: 100%; height: 1px; background: #ccc; border: 0;}
341 337 blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0.6em; margin-left: 2.4em;}
342 338 blockquote blockquote { margin-left: 0;}
343 339 abbr, span.field-description[title] { border-bottom: 1px dotted #aaa; cursor: help; }
344 340 textarea.wiki-edit {width:99%; resize:vertical;}
345 341 li p {margin-top: 0;}
346 342 div.issue {background:#ffffdd; padding:6px; margin-bottom:6px; border: 1px solid #d7d7d7; border-radius:3px;}
347 343 p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;}
348 344 p.subtitle { font-size: 0.9em; margin: -6px 0 12px 0; font-style: italic; }
349 345 p.footnote { font-size: 0.9em; margin-top: 0px; margin-bottom: 0px; }
350 346 .ltr {direction:ltr !important; unicode-bidi:bidi-override;}
351 347 .rtl {direction:rtl !important; unicode-bidi:bidi-override;}
352 348
353 349 div.issue div.subject div div { padding-left: 16px; }
354 350 div.issue div.subject p {margin: 0; margin-bottom: 0.1em; font-size: 90%; color: #999;}
355 351 div.issue div.subject>div>p { margin-top: 0.5em; }
356 352 div.issue div.subject h3 {margin: 0; margin-bottom: 0.1em;}
357 353 div.issue span.private, div.journal span.private { position:relative; bottom: 2px; text-transform: uppercase; background: #d22; color: #fff; font-weight:bold; padding: 0px 2px 0px 2px; font-size: 60%; margin-right: 2px; border-radius: 2px;}
358 354 div.issue .next-prev-links {color:#999;}
359 div.issue table.attributes th {width:22%;}
360 div.issue table.attributes td {width:28%;}
361 div.issue.issue.overdue td.due-date { color: #c22; }
355 div.issue .attributes {margin-top: 2em;}
356 div.issue .attribute {padding-left:180px; clear:left; min-height: 1.8em;}
357 div.issue .attribute .label {width: 170px; margin-left:-180px; font-weight:bold; float:left;}
358 div.issue.overdue .due-date .value { color: #c22; }
362 359
363 360 #issue_tree table.issues, #relations table.issues { border: 0; }
364 361 #issue_tree td.checkbox, #relations td.checkbox {display:none;}
365 362 #relations td.buttons {padding:0;}
366 363
367 364 fieldset.collapsible {border-width: 1px 0 0 0;}
368 365 fieldset.collapsible>legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; }
369 366 fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_collapsed.png); }
370 367
371 368 fieldset#date-range p { margin: 2px 0 2px 0; }
372 369 fieldset#filters table { border-collapse: collapse; }
373 370 fieldset#filters table td { padding: 0; vertical-align: middle; }
374 371 fieldset#filters tr.filter { height: 2.1em; }
375 372 fieldset#filters td.field { width:230px; }
376 373 fieldset#filters td.operator { width:180px; }
377 374 fieldset#filters td.operator select {max-width:170px;}
378 375 fieldset#filters td.values { white-space:nowrap; }
379 376 fieldset#filters td.values select {min-width:130px;}
380 377 fieldset#filters td.values input {height:1em;}
381 378
382 379 #filters-table {width:60%; float:left;}
383 380 .add-filter {width:35%; float:right; text-align: right; vertical-align: top;}
384 381
385 382 #issue_is_private_wrap {float:right; margin-right:1em;}
386 383 .toggle-multiselect {background: url(../images/bullet_toggle_plus.png) no-repeat 0% 40%; padding-left:8px; margin-left:0; cursor:pointer;}
387 384 .buttons { font-size: 0.9em; margin-bottom: 1.4em; margin-top: 1em; }
388 385
389 386 div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 1em; background: #fff; padding-left: 1em; font-size: 90%;}
390 387 div#issue-changesets div.changeset { padding: 4px;}
391 388 div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; }
392 389 div#issue-changesets p { margin-top: 0; margin-bottom: 1em;}
393 390
394 391 .journal ul.details img {margin:0 0 -3px 4px;}
395 392 div.journal {overflow:auto;}
396 393 div.journal.private-notes {border-left:2px solid #d22; padding-left:4px; margin-left:-6px;}
397 394 div.journal ul.details {color:#959595; margin-bottom: 1.5em;}
398 395 div.journal ul.details a {color:#70A7CD;}
399 396 div.journal ul.details a:hover {color:#D14848;}
400 397
401 398 div#activity dl, #search-results { margin-left: 2em; }
402 399 div#activity dd, #search-results dd { margin-bottom: 1em; padding-left: 18px; font-size: 0.9em; }
403 400 div#activity dt, #search-results dt { margin-bottom: 0px; padding-left: 20px; line-height: 18px; background-position: 0 50%; background-repeat: no-repeat; }
404 401 div#activity dt.me .time { border-bottom: 1px solid #999; }
405 402 div#activity dt .time { color: #777; font-size: 80%; }
406 403 div#activity dd .description, #search-results dd .description { font-style: italic; }
407 404 div#activity span.project:after, #search-results span.project:after { content: " -"; }
408 405 div#activity dd span.description, #search-results dd span.description { display:block; color: #808080; }
409 406 div#activity dt.grouped {margin-left:5em;}
410 407 div#activity dd.grouped {margin-left:9em;}
411 408
412 409 #search-results dd { margin-bottom: 1em; padding-left: 20px; margin-left:0px; }
413 410
414 411 div#search-results-counts {float:right;}
415 412 div#search-results-counts ul { margin-top: 0.5em; }
416 413 div#search-results-counts li { list-style-type:none; float: left; margin-left: 1em; }
417 414
418 415 dt.issue { background-image: url(../images/ticket.png); }
419 416 dt.issue-edit { background-image: url(../images/ticket_edit.png); }
420 417 dt.issue-closed { background-image: url(../images/ticket_checked.png); }
421 418 dt.issue-note { background-image: url(../images/ticket_note.png); }
422 419 dt.changeset { background-image: url(../images/changeset.png); }
423 420 dt.news { background-image: url(../images/news.png); }
424 421 dt.message { background-image: url(../images/message.png); }
425 422 dt.reply { background-image: url(../images/comments.png); }
426 423 dt.wiki-page { background-image: url(../images/wiki_edit.png); }
427 424 dt.attachment { background-image: url(../images/attachment.png); }
428 425 dt.document { background-image: url(../images/document.png); }
429 426 dt.project { background-image: url(../images/projects.png); }
430 427 dt.time-entry { background-image: url(../images/time.png); }
431 428
432 429 #search-results dt.issue.closed { background-image: url(../images/ticket_checked.png); }
433 430
434 431 div#roadmap .related-issues { margin-bottom: 1em; }
435 432 div#roadmap .related-issues td.checkbox { display: none; }
436 433 div#roadmap .wiki h1:first-child { display: none; }
437 434 div#roadmap .wiki h1 { font-size: 120%; }
438 435 div#roadmap .wiki h2 { font-size: 110%; }
439 436 body.controller-versions.action-show div#roadmap .related-issues {width:70%;}
440 437
441 438 div#version-summary { float:right; width:28%; margin-left: 16px; margin-bottom: 16px; background-color: #fff; }
442 439 div#version-summary fieldset { margin-bottom: 1em; }
443 440 div#version-summary fieldset.time-tracking table { width:100%; }
444 441 div#version-summary th, div#version-summary td.total-hours { text-align: right; }
445 442
446 443 table#time-report td.hours, table#time-report th.period, table#time-report th.total { text-align: right; padding-right: 0.5em; }
447 444 table#time-report tbody tr.subtotal { font-style: italic; color:#777;}
448 445 table#time-report tbody tr.subtotal td.hours { color:#b0b0b0; }
449 446 table#time-report tbody tr.total { font-weight: bold; background-color:#EEEEEE; border-top:1px solid #e4e4e4;}
450 447 table#time-report .hours-dec { font-size: 0.9em; }
451 448
452 449 div.wiki-page .contextual a {opacity: 0.4}
453 450 div.wiki-page .contextual a:hover {opacity: 1}
454 451
455 452 form .attributes select { width: 60%; }
456 453 input#issue_subject, input#document_title { width: 99%; }
457 454 select#issue_done_ratio { width: 95px; }
458 455
459 456 ul.projects {margin:0; padding-left:1em;}
460 457 ul.projects ul {padding-left:1.6em;}
461 458 ul.projects.root {margin:0; padding:0;}
462 459 ul.projects li {list-style-type:none;}
463 460
464 461 #projects-index ul.projects ul.projects { border-left: 3px solid #e0e0e0; padding-left:1em;}
465 462 #projects-index ul.projects li.root {margin-bottom: 1em;}
466 463 #projects-index ul.projects li.child {margin-top: 1em;}
467 464 #projects-index ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 16px; margin: 0 0 10px 0; }
468 465 .my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; }
469 466
470 467 #notified-projects>ul, #tracker_project_ids>ul, #custom_field_project_ids>ul {max-height:250px; overflow-y:auto;}
471 468
472 469 #related-issues li img {vertical-align:middle;}
473 470
474 471 ul.properties {padding:0; font-size: 0.9em; color: #777;}
475 472 ul.properties li {list-style-type:none;}
476 473 ul.properties li span {font-style:italic;}
477 474
478 475 .total-hours { font-size: 110%; font-weight: bold; }
479 476 .total-hours span.hours-int { font-size: 120%; }
480 477
481 478 .autoscroll {overflow-x: auto; padding:1px; margin-bottom: 1.2em;}
482 479 #user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 90%; }
483 480
484 481 #workflow_copy_form select { width: 200px; }
485 482 table.transitions td.enabled {background: #bfb;}
486 483 #workflow_form table select {font-size:90%; max-width:100px;}
487 484 table.fields_permissions td.readonly {background:#ddd;}
488 485 table.fields_permissions td.required {background:#d88;}
489 486
490 487 select.expandable {vertical-align:top;}
491 488
492 489 textarea#custom_field_possible_values {width: 95%; resize:vertical}
493 490 textarea#custom_field_default_value {width: 95%; resize:vertical}
494 491 .sort-handle {display:inline-block; vertical-align:middle;}
495 492
496 493 input#content_comments {width: 99%}
497 494
498 495 p.pagination {margin-top:8px; font-size: 90%}
499 496
500 497 #search-form fieldset p {margin:0.2em 0;}
501 498
502 499 /***** Tabular forms ******/
503 500 .tabular p{
504 501 margin: 0;
505 502 padding: 3px 0 3px 0;
506 503 padding-left: 180px; /* width of left column containing the label elements */
507 504 min-height: 1.8em;
508 505 clear:left;
509 506 }
510 507
511 508 html>body .tabular p {overflow:hidden;}
512 509
513 510 .tabular input, .tabular select {max-width:95%}
514 511 .tabular textarea {width:95%; resize:vertical;}
515 512
516 513 .tabular label{
517 514 font-weight: bold;
518 515 float: left;
519 516 text-align: right;
520 517 /* width of left column */
521 518 margin-left: -180px;
522 519 /* width of labels. Should be smaller than left column to create some right margin */
523 520 width: 175px;
524 521 }
525 522
526 523 .tabular label.floating{
527 524 font-weight: normal;
528 525 margin-left: 0px;
529 526 text-align: left;
530 527 width: 270px;
531 528 }
532 529
533 530 .tabular label.block{
534 531 font-weight: normal;
535 532 margin-left: 0px !important;
536 533 text-align: left;
537 534 float: none;
538 535 display: block;
539 536 width: auto !important;
540 537 }
541 538
542 539 .tabular label.inline{
543 540 font-weight: normal;
544 541 float:none;
545 542 margin-left: 5px !important;
546 543 width: auto;
547 544 }
548 545
549 546 label.no-css {
550 547 font-weight: inherit;
551 548 float:none;
552 549 text-align:left;
553 550 margin-left:0px;
554 551 width:auto;
555 552 }
556 553 input#time_entry_comments { width: 90%;}
557 554
558 555 #preview fieldset {margin-top: 1em; background: url(../images/draft.png)}
559 556
560 557 .tabular.settings p{ padding-left: 300px; }
561 558 .tabular.settings label{ margin-left: -300px; width: 295px; }
562 559 .tabular.settings textarea { width: 99%; }
563 560
564 561 .settings.enabled_scm table {width:100%}
565 562 .settings.enabled_scm td.scm_name{ font-weight: bold; }
566 563
567 564 fieldset.settings label { display: block; }
568 565 fieldset#notified_events .parent { padding-left: 20px; }
569 566
570 567 span.required {color: #bb0000;}
571 568 .summary {font-style: italic;}
572 569
573 570 .check_box_group {
574 571 display:block;
575 572 width:95%;
576 573 max-height:300px;
577 574 overflow-y:auto;
578 575 padding:2px 4px 4px 2px;
579 576 background:#fff;
580 577 border:1px solid #9EB1C2;
581 578 border-radius:2px
582 579 }
583 580 .check_box_group label {
584 581 font-weight: normal;
585 582 margin-left: 0px !important;
586 583 text-align: left;
587 584 float: none;
588 585 display: block;
589 586 width: auto;
590 587 }
591 588 .check_box_group.bool_cf {border:0; background:inherit;}
592 589 .check_box_group.bool_cf label {display: inline;}
593 590
594 591 #attachments_fields input.description {margin-left:4px; width:340px;}
595 592 #attachments_fields span {display:block; white-space:nowrap;}
596 593 #attachments_fields input.filename {border:0; height:1.8em; width:250px; color:#555; background-color:inherit; background:url(../images/attachment.png) no-repeat 1px 50%; padding-left:18px;}
597 594 #attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
598 595 #attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;}
599 596 #attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
600 597 a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;}
601 598 a.remove-upload:hover {text-decoration:none !important;}
602 599
603 600 div.fileover { background-color: lavender; }
604 601
605 602 div.attachments { margin-top: 12px; }
606 603 div.attachments p { margin:4px 0 2px 0; }
607 604 div.attachments img { vertical-align: middle; }
608 605 div.attachments span.author { font-size: 0.9em; color: #888; }
609 606
610 607 div.thumbnails {margin-top:0.6em;}
611 608 div.thumbnails div {background:#fff;border:2px solid #ddd;display:inline-block;margin-right:2px;}
612 609 div.thumbnails img {margin: 3px; vertical-align: middle;}
613 610 #history div.thumbnails {margin-left: 2em;}
614 611
615 612 p.other-formats { text-align: right; font-size:0.9em; color: #666; }
616 613 .other-formats span + span:before { content: "| "; }
617 614
618 615 a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; }
619 616
620 617 em.info {font-style:normal;font-size:90%;color:#888;display:block;}
621 618 em.info.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;}
622 619
623 620 textarea.text_cf {width:95%; resize:vertical;}
624 621 input.string_cf, input.link_cf {width:95%;}
625 622 select.bool_cf {width:auto !important;}
626 623
627 624 #tab-content-modules fieldset p {margin:3px 0 4px 0;}
628 625
629 626 #tab-content-users .splitcontentleft {width: 64%;}
630 627 #tab-content-users .splitcontentright {width: 34%;}
631 628 #tab-content-users fieldset {padding:1em; margin-bottom: 1em;}
632 629 #tab-content-users fieldset legend {font-weight: bold;}
633 630 #tab-content-users fieldset label {display: block;}
634 631 #tab-content-users #principals {max-height: 400px; overflow: auto;}
635 632
636 633 #users_for_watcher {height: 200px; overflow:auto;}
637 634 #users_for_watcher label {display: block;}
638 635
639 636 table.members td.name {padding-left: 20px;}
640 637 table.members td.group, table.members td.groupnonmember, table.members td.groupanonymous {background: url(../images/group.png) no-repeat 0% 1px;}
641 638
642 639 input#principal_search, input#user_search {width:90%}
643 640 .roles-selection label {display:inline-block; width:210px;}
644 641
645 642 input.autocomplete {
646 643 background: #fff url(../images/magnifier.png) no-repeat 2px 50%; padding-left:20px !important;
647 644 border:1px solid #9EB1C2; border-radius:2px; height:1.5em;
648 645 }
649 646 input.autocomplete.ajax-loading {
650 647 background-image: url(../images/loading.gif);
651 648 }
652 649
653 650 .role-visibility {padding-left:2em;}
654 651
655 652 .objects-selection {
656 653 height: 300px;
657 654 overflow: auto;
658 655 }
659 656
660 657 .objects-selection label {
661 658 display: block;
662 659 }
663 660
664 661 .objects-selection>div {
665 662 column-count: auto;
666 663 column-width: 200px;
667 664 -webkit-column-count: auto;
668 665 -webkit-column-width: 200px;
669 666 -webkit-column-gap : 0.5rem;
670 667 -webkit-column-rule: 1px solid #ccc;
671 668 -moz-column-count: auto;
672 669 -moz-column-width: 200px;
673 670 -moz-column-gap : 0.5rem;
674 671 -moz-column-rule: 1px solid #ccc;
675 672 }
676 673
677 674 /***** Flash & error messages ****/
678 675 #errorExplanation, div.flash, .nodata, .warning, .conflict {
679 676 padding: 4px 4px 4px 30px;
680 677 margin-bottom: 12px;
681 678 font-size: 1.1em;
682 679 border: 2px solid;
683 680 border-radius: 3px;
684 681 }
685 682
686 683 div.flash {margin-top: 8px;}
687 684
688 685 div.flash.error, #errorExplanation {
689 686 background: url(../images/exclamation.png) 8px 50% no-repeat;
690 687 background-color: #ffe3e3;
691 688 border-color: #dd0000;
692 689 color: #880000;
693 690 }
694 691
695 692 div.flash.notice {
696 693 background: url(../images/true.png) 8px 5px no-repeat;
697 694 background-color: #dfffdf;
698 695 border-color: #9fcf9f;
699 696 color: #005f00;
700 697 }
701 698
702 699 div.flash.warning, .conflict {
703 700 background: url(../images/warning.png) 8px 5px no-repeat;
704 701 background-color: #FFEBC1;
705 702 border-color: #FDBF3B;
706 703 color: #A6750C;
707 704 text-align: left;
708 705 }
709 706
710 707 .nodata, .warning {
711 708 text-align: center;
712 709 background-color: #FFEBC1;
713 710 border-color: #FDBF3B;
714 711 color: #A6750C;
715 712 }
716 713
717 714 #errorExplanation ul { font-size: 0.9em;}
718 715 #errorExplanation h2, #errorExplanation p { display: none; }
719 716
720 717 .conflict-details {font-size:80%;}
721 718
722 719 /***** Ajax indicator ******/
723 720 #ajax-indicator {
724 721 position: absolute; /* fixed not supported by IE */
725 722 background-color:#eee;
726 723 border: 1px solid #bbb;
727 724 top:35%;
728 725 left:40%;
729 726 width:20%;
730 727 font-weight:bold;
731 728 text-align:center;
732 729 padding:0.6em;
733 730 z-index:100;
734 731 opacity: 0.5;
735 732 }
736 733
737 734 html>body #ajax-indicator { position: fixed; }
738 735
739 736 #ajax-indicator span {
740 737 background-position: 0% 40%;
741 738 background-repeat: no-repeat;
742 739 background-image: url(../images/loading.gif);
743 740 padding-left: 26px;
744 741 vertical-align: bottom;
745 742 }
746 743
747 744 /***** Calendar *****/
748 745 table.cal {border-collapse: collapse; width: 100%; margin: 0px 0 6px 0;border: 1px solid #d7d7d7;}
749 746 table.cal thead th {width: 14%; background-color:#EEEEEE; padding: 4px; }
750 747 table.cal thead th.week-number {width: auto;}
751 748 table.cal tbody tr {height: 100px;}
752 749 table.cal td {border: 1px solid #d7d7d7; vertical-align: top; font-size: 0.9em;}
753 750 table.cal td.week-number { background-color:#EEEEEE; padding: 4px; border:none; font-size: 1em;}
754 751 table.cal td p.day-num {font-size: 1.1em; text-align:right;}
755 752 table.cal td.odd p.day-num {color: #bbb;}
756 753 table.cal td.today {background:#ffffdd;}
757 754 table.cal td.today p.day-num {font-weight: bold;}
758 755 table.cal .starting a, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;}
759 756 table.cal .ending a, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;}
760 757 table.cal .starting.ending a, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;}
761 758 p.cal.legend span {display:block;}
762 759
763 760 /***** Tooltips ******/
764 761 .tooltip{position:relative;z-index:24;}
765 762 .tooltip:hover{z-index:25;color:#000;}
766 763 .tooltip span.tip{display: none; text-align:left;}
767 764
768 765 div.tooltip:hover span.tip{
769 766 display:block;
770 767 position:absolute;
771 768 top:12px; left:24px; width:270px;
772 769 border:1px solid #555;
773 770 background-color:#fff;
774 771 padding: 4px;
775 772 font-size: 0.8em;
776 773 color:#505050;
777 774 }
778 775
779 776 img.ui-datepicker-trigger {
780 777 cursor: pointer;
781 778 vertical-align: middle;
782 779 margin-left: 4px;
783 780 }
784 781
785 782 /***** Progress bar *****/
786 783 table.progress {
787 784 border-collapse: collapse;
788 785 border-spacing: 0pt;
789 786 empty-cells: show;
790 787 text-align: center;
791 788 float:left;
792 789 margin: 1px 6px 1px 0px;
793 790 }
794 791
795 792 table.progress td { height: 1em; }
796 793 table.progress td.closed { background: #BAE0BA none repeat scroll 0%; }
797 794 table.progress td.done { background: #D3EDD3 none repeat scroll 0%; }
798 795 table.progress td.todo { background: #eee none repeat scroll 0%; }
799 p.percent {font-size: 80%;}
796 p.percent {font-size: 80%; margin:0;}
800 797 p.progress-info {clear: left; font-size: 80%; margin-top:-4px; color:#777;}
801 798
802 799 #roadmap table.progress td { height: 1.2em; }
803 800 /***** Tabs *****/
804 801 #content .tabs {height: 2.6em; margin-bottom:1.2em; position:relative; overflow:hidden;}
805 802 #content .tabs ul {margin:0; position:absolute; bottom:0; padding-left:0.5em; width: 2000px; border-bottom: 1px solid #bbbbbb;}
806 803 #content .tabs ul li {
807 804 float:left;
808 805 list-style-type:none;
809 806 white-space:nowrap;
810 807 margin-right:4px;
811 808 background:#fff;
812 809 position:relative;
813 810 margin-bottom:-1px;
814 811 }
815 812 #content .tabs ul li a{
816 813 display:block;
817 814 font-size: 0.9em;
818 815 text-decoration:none;
819 816 line-height:1.3em;
820 817 padding:4px 6px 4px 6px;
821 818 border: 1px solid #ccc;
822 819 border-bottom: 1px solid #bbbbbb;
823 820 background-color: #f6f6f6;
824 821 color:#999;
825 822 font-weight:bold;
826 823 border-top-left-radius:3px;
827 824 border-top-right-radius:3px;
828 825 }
829 826
830 827 #content .tabs ul li a:hover {
831 828 background-color: #ffffdd;
832 829 text-decoration:none;
833 830 }
834 831
835 832 #content .tabs ul li a.selected {
836 833 background-color: #fff;
837 834 border: 1px solid #bbbbbb;
838 835 border-bottom: 1px solid #fff;
839 836 color:#444;
840 837 }
841 838
842 839 #content .tabs ul li a.selected:hover {background-color: #fff;}
843 840
844 841 div.tabs-buttons { position:absolute; right: 0; width: 48px; height: 24px; background: white; bottom: 0; border-bottom: 1px solid #bbbbbb; }
845 842
846 843 button.tab-left, button.tab-right {
847 844 font-size: 0.9em;
848 845 cursor: pointer;
849 846 height:24px;
850 847 border: 1px solid #ccc;
851 848 border-bottom: 1px solid #bbbbbb;
852 849 position:absolute;
853 850 padding:4px;
854 851 width: 20px;
855 852 bottom: -1px;
856 853 }
857 854
858 855 button.tab-left {
859 856 right: 20px;
860 857 background: #eeeeee url(../images/bullet_arrow_left.png) no-repeat 50% 50%;
861 858 border-top-left-radius:3px;
862 859 }
863 860
864 861 button.tab-right {
865 862 right: 0;
866 863 background: #eeeeee url(../images/bullet_arrow_right.png) no-repeat 50% 50%;
867 864 border-top-right-radius:3px;
868 865 }
869 866
870 867 /***** Diff *****/
871 868 .diff_out { background: #fcc; }
872 869 .diff_out span { background: #faa; }
873 870 .diff_in { background: #cfc; }
874 871 .diff_in span { background: #afa; }
875 872
876 873 .text-diff {
877 874 padding: 1em;
878 875 background-color:#f6f6f6;
879 876 color:#505050;
880 877 border: 1px solid #e4e4e4;
881 878 }
882 879
883 880 /***** Wiki *****/
884 881 div.wiki table {
885 882 border-collapse: collapse;
886 883 margin-bottom: 1em;
887 884 }
888 885
889 886 div.wiki table, div.wiki td, div.wiki th {
890 887 border: 1px solid #bbb;
891 888 padding: 4px;
892 889 }
893 890
894 891 div.wiki .noborder, div.wiki .noborder td, div.wiki .noborder th {border:0;}
895 892
896 893 div.wiki .external {
897 894 background-position: 0% 60%;
898 895 background-repeat: no-repeat;
899 896 padding-left: 12px;
900 897 background-image: url(../images/external.png);
901 898 }
902 899
903 900 div.wiki a {word-wrap: break-word;}
904 901 div.wiki a.new {color: #b73535;}
905 902
906 903 div.wiki ul, div.wiki ol {margin-bottom:1em;}
907 904 div.wiki li>ul, div.wiki li>ol {margin-bottom: 0;}
908 905
909 906 div.wiki pre {
910 907 margin: 1em 1em 1em 1.6em;
911 908 padding: 8px;
912 909 background-color: #fafafa;
913 910 border: 1px solid #e2e2e2;
914 911 border-radius: 3px;
915 912 width:auto;
916 913 overflow-x: auto;
917 914 overflow-y: hidden;
918 915 }
919 916
920 917 div.wiki ul.toc {
921 918 background-color: #ffffdd;
922 919 border: 1px solid #e4e4e4;
923 920 padding: 4px;
924 921 line-height: 1.2em;
925 922 margin-bottom: 12px;
926 923 margin-right: 12px;
927 924 margin-left: 0;
928 925 display: table
929 926 }
930 927 * html div.wiki ul.toc { width: 50%; } /* IE6 doesn't autosize div */
931 928
932 929 div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; }
933 930 div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
934 931 div.wiki ul.toc ul { margin: 0; padding: 0; }
935 932 div.wiki ul.toc li {list-style-type:none; margin: 0; font-size:12px;}
936 933 div.wiki ul.toc li li {margin-left: 1.5em; font-size:10px;}
937 934 div.wiki ul.toc a {
938 935 font-size: 0.9em;
939 936 font-weight: normal;
940 937 text-decoration: none;
941 938 color: #606060;
942 939 }
943 940 div.wiki ul.toc a:hover { color: #c61a1a; text-decoration: underline;}
944 941
945 942 a.wiki-anchor { display: none; margin-left: 6px; text-decoration: none; }
946 943 a.wiki-anchor:hover { color: #aaa !important; text-decoration: none; }
947 944 h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display: inline; color: #ddd; }
948 945
949 946 div.wiki img {vertical-align:middle; max-width:100%;}
950 947
951 948 /***** My page layout *****/
952 949 .block-receiver {
953 950 border:1px dashed #c0c0c0;
954 951 margin-bottom: 20px;
955 952 padding: 15px 0 15px 0;
956 953 }
957 954
958 955 .mypage-box {
959 956 margin:0 0 20px 0;
960 957 color:#505050;
961 958 line-height:1.5em;
962 959 }
963 960
964 961 .handle {cursor: move;}
965 962
966 963 a.close-icon {
967 964 display:block;
968 965 margin-top:3px;
969 966 overflow:hidden;
970 967 width:12px;
971 968 height:12px;
972 969 background-repeat: no-repeat;
973 970 cursor:pointer;
974 971 background-image:url('../images/close.png');
975 972 }
976 973 a.close-icon:hover {background-image:url('../images/close_hl.png');}
977 974
978 975 /***** Gantt chart *****/
979 976 .gantt_hdr {
980 977 position:absolute;
981 978 top:0;
982 979 height:16px;
983 980 border-top: 1px solid #c0c0c0;
984 981 border-bottom: 1px solid #c0c0c0;
985 982 border-right: 1px solid #c0c0c0;
986 983 text-align: center;
987 984 overflow: hidden;
988 985 }
989 986
990 987 .gantt_hdr.nwday {background-color:#f1f1f1; color:#999;}
991 988
992 989 .gantt_subjects { font-size: 0.8em; }
993 990 .gantt_subjects div { line-height:16px;height:16px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis; }
994 991
995 992 .task {
996 993 position: absolute;
997 994 height:8px;
998 995 font-size:0.8em;
999 996 color:#888;
1000 997 padding:0;
1001 998 margin:0;
1002 999 line-height:16px;
1003 1000 white-space:nowrap;
1004 1001 }
1005 1002
1006 1003 .task.label {width:100%;}
1007 1004 .task.label.project, .task.label.version { font-weight: bold; }
1008 1005
1009 1006 .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
1010 1007 .task_done { background:#00c600 url(../images/task_done.png); border: 1px solid #00c600; }
1011 1008 .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
1012 1009
1013 1010 .task_todo.parent { background: #888; border: 1px solid #888; height: 3px;}
1014 1011 .task_late.parent, .task_done.parent { height: 3px;}
1015 1012 .task.parent.marker.starting { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-left: -4px; left: 0px; top: -1px;}
1016 1013 .task.parent.marker.ending { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-left: -4px; right: 0px; top: -1px;}
1017 1014
1018 1015 .version.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
1019 1016 .version.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
1020 1017 .version.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;}
1021 1018 .version.marker { background-image:url(../images/version_marker.png); background-repeat: no-repeat; border: 0; margin-left: -4px; margin-top: 1px; }
1022 1019
1023 1020 .project.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
1024 1021 .project.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
1025 1022 .project.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;}
1026 1023 .project.marker { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; margin-left: -4px; margin-top: 1px; }
1027 1024
1028 1025 .version-behind-schedule a, .issue-behind-schedule a {color: #f66914;}
1029 1026 .version-overdue a, .issue-overdue a, .project-overdue a {color: #f00;}
1030 1027
1031 1028 /***** Icons *****/
1032 1029 .icon {
1033 1030 background-position: 0% 50%;
1034 1031 background-repeat: no-repeat;
1035 1032 padding-left: 20px;
1036 1033 padding-top: 2px;
1037 1034 padding-bottom: 3px;
1038 1035 }
1039 1036
1040 1037 .icon-add { background-image: url(../images/add.png); }
1041 1038 .icon-edit { background-image: url(../images/edit.png); }
1042 1039 .icon-copy { background-image: url(../images/copy.png); }
1043 1040 .icon-duplicate { background-image: url(../images/duplicate.png); }
1044 1041 .icon-del { background-image: url(../images/delete.png); }
1045 1042 .icon-move { background-image: url(../images/move.png); }
1046 1043 .icon-save { background-image: url(../images/save.png); }
1047 1044 .icon-cancel { background-image: url(../images/cancel.png); }
1048 1045 .icon-multiple { background-image: url(../images/table_multiple.png); }
1049 1046 .icon-folder { background-image: url(../images/folder.png); }
1050 1047 .open .icon-folder { background-image: url(../images/folder_open.png); }
1051 1048 .icon-package { background-image: url(../images/package.png); }
1052 1049 .icon-user { background-image: url(../images/user.png); }
1053 1050 .icon-projects { background-image: url(../images/projects.png); }
1054 1051 .icon-help { background-image: url(../images/help.png); }
1055 1052 .icon-attachment { background-image: url(../images/attachment.png); }
1056 1053 .icon-history { background-image: url(../images/history.png); }
1057 1054 .icon-time { background-image: url(../images/time.png); }
1058 1055 .icon-time-add { background-image: url(../images/time_add.png); }
1059 1056 .icon-stats { background-image: url(../images/stats.png); }
1060 1057 .icon-warning { background-image: url(../images/warning.png); }
1061 1058 .icon-fav { background-image: url(../images/fav.png); }
1062 1059 .icon-fav-off { background-image: url(../images/fav_off.png); }
1063 1060 .icon-reload { background-image: url(../images/reload.png); }
1064 1061 .icon-lock { background-image: url(../images/locked.png); }
1065 1062 .icon-unlock { background-image: url(../images/unlock.png); }
1066 1063 .icon-checked { background-image: url(../images/true.png); }
1067 1064 .icon-details { background-image: url(../images/zoom_in.png); }
1068 1065 .icon-report { background-image: url(../images/report.png); }
1069 1066 .icon-comment { background-image: url(../images/comment.png); }
1070 1067 .icon-summary { background-image: url(../images/lightning.png); }
1071 1068 .icon-server-authentication { background-image: url(../images/server_key.png); }
1072 1069 .icon-issue { background-image: url(../images/ticket.png); }
1073 1070 .icon-zoom-in { background-image: url(../images/zoom_in.png); }
1074 1071 .icon-zoom-out { background-image: url(../images/zoom_out.png); }
1075 1072 .icon-passwd { background-image: url(../images/textfield_key.png); }
1076 1073 .icon-test { background-image: url(../images/bullet_go.png); }
1077 1074 .icon-email-add { background-image: url(../images/email_add.png); }
1078 1075
1079 1076 .icon-file { background-image: url(../images/files/default.png); }
1080 1077 .icon-file.text-plain { background-image: url(../images/files/text.png); }
1081 1078 .icon-file.text-x-c { background-image: url(../images/files/c.png); }
1082 1079 .icon-file.text-x-csharp { background-image: url(../images/files/csharp.png); }
1083 1080 .icon-file.text-x-java { background-image: url(../images/files/java.png); }
1084 1081 .icon-file.text-x-javascript { background-image: url(../images/files/js.png); }
1085 1082 .icon-file.text-x-php { background-image: url(../images/files/php.png); }
1086 1083 .icon-file.text-x-ruby { background-image: url(../images/files/ruby.png); }
1087 1084 .icon-file.text-xml { background-image: url(../images/files/xml.png); }
1088 1085 .icon-file.text-css { background-image: url(../images/files/css.png); }
1089 1086 .icon-file.text-html { background-image: url(../images/files/html.png); }
1090 1087 .icon-file.image-gif { background-image: url(../images/files/image.png); }
1091 1088 .icon-file.image-jpeg { background-image: url(../images/files/image.png); }
1092 1089 .icon-file.image-png { background-image: url(../images/files/image.png); }
1093 1090 .icon-file.image-tiff { background-image: url(../images/files/image.png); }
1094 1091 .icon-file.application-pdf { background-image: url(../images/files/pdf.png); }
1095 1092 .icon-file.application-zip { background-image: url(../images/files/zip.png); }
1096 1093 .icon-file.application-x-gzip { background-image: url(../images/files/zip.png); }
1097 1094
1098 1095 img.gravatar {
1099 1096 padding: 2px;
1100 1097 border: solid 1px #d5d5d5;
1101 1098 background: #fff;
1102 1099 vertical-align: middle;
1103 1100 }
1104 1101
1105 1102 div.issue img.gravatar {
1106 1103 float: left;
1107 1104 margin: 0 6px 0 0;
1108 1105 padding: 5px;
1109 1106 }
1110 1107
1111 1108 div.issue table img.gravatar {
1112 1109 height: 14px;
1113 1110 width: 14px;
1114 1111 padding: 2px;
1115 1112 float: left;
1116 1113 margin: 0 0.5em 0 0;
1117 1114 }
1118 1115
1119 1116 h2 img.gravatar {margin: -2px 4px -4px 0;}
1120 1117 h3 img.gravatar {margin: -4px 4px -4px 0;}
1121 1118 h4 img.gravatar {margin: -6px 4px -4px 0;}
1122 1119 td.username img.gravatar {margin: 0 0.5em 0 0; vertical-align: top;}
1123 1120 #activity dt img.gravatar {float: left; margin: 0 1em 1em 0;}
1124 1121 /* Used on 12px Gravatar img tags without the icon background */
1125 1122 .icon-gravatar {float: left; margin-right: 4px;}
1126 1123
1127 1124 #activity dt, .journal {clear: left;}
1128 1125
1129 1126 .journal-link {float: right;}
1130 1127
1131 1128 h2 img { vertical-align:middle; }
1132 1129
1133 1130 .hascontextmenu { cursor: context-menu; }
1134 1131
1135 1132 .sample-data {border:1px solid #ccc; border-collapse:collapse; background-color:#fff; margin:0.5em;}
1136 1133 .sample-data td {border:1px solid #ccc; padding: 2px 4px; font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;}
1137 1134 .sample-data tr:first-child td {font-weight:bold; text-align:center;}
1138 1135
1139 1136 .ui-progressbar {position: relative;}
1140 1137 #progress-label {
1141 1138 position: absolute; left: 50%; top: 4px;
1142 1139 font-weight: bold;
1143 1140 color: #555; text-shadow: 1px 1px 0 #fff;
1144 1141 }
1145 1142
1146 1143 /* Custom JQuery styles */
1147 1144 .ui-datepicker-title select {width:70px !important; margin-top:-2px !important; margin-right:4px !important;}
1148 1145
1149 1146
1150 1147 /************* CodeRay styles *************/
1151 1148 .syntaxhl div {display: inline;}
1152 1149 .syntaxhl .code pre { overflow: auto }
1153 1150
1154 1151 .syntaxhl .annotation { color:#007 }
1155 1152 .syntaxhl .attribute-name { color:#b48 }
1156 1153 .syntaxhl .attribute-value { color:#700 }
1157 1154 .syntaxhl .binary { color:#549 }
1158 1155 .syntaxhl .binary .char { color:#325 }
1159 1156 .syntaxhl .binary .delimiter { color:#325 }
1160 1157 .syntaxhl .char { color:#D20 }
1161 1158 .syntaxhl .char .content { color:#D20 }
1162 1159 .syntaxhl .char .delimiter { color:#710 }
1163 1160 .syntaxhl .class { color:#258; font-weight:bold }
1164 1161 .syntaxhl .class-variable { color:#369 }
1165 1162 .syntaxhl .color { color:#0A0 }
1166 1163 .syntaxhl .comment { color:#385 }
1167 1164 .syntaxhl .comment .char { color:#385 }
1168 1165 .syntaxhl .comment .delimiter { color:#385 }
1169 1166 .syntaxhl .constant { color:#258; font-weight:bold }
1170 1167 .syntaxhl .decorator { color:#B0B }
1171 1168 .syntaxhl .definition { color:#099; font-weight:bold }
1172 1169 .syntaxhl .delimiter { color:black }
1173 1170 .syntaxhl .directive { color:#088; font-weight:bold }
1174 1171 .syntaxhl .docstring { color:#D42; }
1175 1172 .syntaxhl .doctype { color:#34b }
1176 1173 .syntaxhl .done { text-decoration: line-through; color: gray }
1177 1174 .syntaxhl .entity { color:#800; font-weight:bold }
1178 1175 .syntaxhl .error { color:#F00; background-color:#FAA }
1179 1176 .syntaxhl .escape { color:#666 }
1180 1177 .syntaxhl .exception { color:#C00; font-weight:bold }
1181 1178 .syntaxhl .float { color:#06D }
1182 1179 .syntaxhl .function { color:#06B; font-weight:bold }
1183 1180 .syntaxhl .function .delimiter { color:#024; font-weight:bold }
1184 1181 .syntaxhl .global-variable { color:#d70 }
1185 1182 .syntaxhl .hex { color:#02b }
1186 1183 .syntaxhl .id { color:#33D; font-weight:bold }
1187 1184 .syntaxhl .include { color:#B44; font-weight:bold }
1188 1185 .syntaxhl .inline { background-color: hsla(0,0%,0%,0.07); color: black }
1189 1186 .syntaxhl .inline-delimiter { font-weight: bold; color: #666 }
1190 1187 .syntaxhl .instance-variable { color:#33B }
1191 1188 .syntaxhl .integer { color:#06D }
1192 1189 .syntaxhl .imaginary { color:#f00 }
1193 1190 .syntaxhl .important { color:#D00 }
1194 1191 .syntaxhl .key { color: #606 }
1195 1192 .syntaxhl .key .char { color: #60f }
1196 1193 .syntaxhl .key .delimiter { color: #404 }
1197 1194 .syntaxhl .keyword { color:#939; font-weight:bold }
1198 1195 .syntaxhl .label { color:#970; font-weight:bold }
1199 1196 .syntaxhl .local-variable { color:#950 }
1200 1197 .syntaxhl .map .content { color:#808 }
1201 1198 .syntaxhl .map .delimiter { color:#40A}
1202 1199 .syntaxhl .map { background-color:hsla(200,100%,50%,0.06); }
1203 1200 .syntaxhl .namespace { color:#707; font-weight:bold }
1204 1201 .syntaxhl .octal { color:#40E }
1205 1202 .syntaxhl .operator { }
1206 1203 .syntaxhl .predefined { color:#369; font-weight:bold }
1207 1204 .syntaxhl .predefined-constant { color:#069 }
1208 1205 .syntaxhl .predefined-type { color:#0a8; font-weight:bold }
1209 1206 .syntaxhl .preprocessor { color:#579 }
1210 1207 .syntaxhl .pseudo-class { color:#00C; font-weight:bold }
1211 1208 .syntaxhl .regexp { background-color:hsla(300,100%,50%,0.06); }
1212 1209 .syntaxhl .regexp .content { color:#808 }
1213 1210 .syntaxhl .regexp .delimiter { color:#404 }
1214 1211 .syntaxhl .regexp .modifier { color:#C2C }
1215 1212 .syntaxhl .reserved { color:#080; font-weight:bold }
1216 1213 .syntaxhl .shell { background-color:hsla(120,100%,50%,0.06); }
1217 1214 .syntaxhl .shell .content { color:#2B2 }
1218 1215 .syntaxhl .shell .delimiter { color:#161 }
1219 1216 .syntaxhl .string .char { color: #46a }
1220 1217 .syntaxhl .string .content { color: #46a }
1221 1218 .syntaxhl .string .delimiter { color: #46a }
1222 1219 .syntaxhl .string .modifier { color: #46a }
1223 1220 .syntaxhl .symbol { color:#d33 }
1224 1221 .syntaxhl .symbol .content { color:#d33 }
1225 1222 .syntaxhl .symbol .delimiter { color:#d33 }
1226 1223 .syntaxhl .tag { color:#070; font-weight:bold }
1227 1224 .syntaxhl .type { color:#339; font-weight:bold }
1228 1225 .syntaxhl .value { color: #088 }
1229 1226 .syntaxhl .variable { color:#037 }
1230 1227
1231 1228 .syntaxhl .insert { background: hsla(120,100%,50%,0.12) }
1232 1229 .syntaxhl .delete { background: hsla(0,100%,50%,0.12) }
1233 1230 .syntaxhl .change { color: #bbf; background: #007 }
1234 1231 .syntaxhl .head { color: #f8f; background: #505 }
1235 1232 .syntaxhl .head .filename { color: white; }
1236 1233
1237 1234 .syntaxhl .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; }
1238 1235 .syntaxhl .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }
1239 1236
1240 1237 .syntaxhl .insert .insert { color: #0c0; background:transparent; font-weight:bold }
1241 1238 .syntaxhl .delete .delete { color: #c00; background:transparent; font-weight:bold }
1242 1239 .syntaxhl .change .change { color: #88f }
1243 1240 .syntaxhl .head .head { color: #f4f }
1244 1241
1245 1242 /***** Media print specific styles *****/
1246 1243 @media print {
1247 1244 #top-menu, #header, #main-menu, #sidebar, #footer, .contextual, .other-formats { display:none; }
1248 1245 #main { background: #fff; }
1249 1246 #content { width: 99%; margin: 0; padding: 0; border: 0; background: #fff; overflow: visible !important;}
1250 1247 #wiki_add_attachment { display:none; }
1251 1248 .hide-when-print { display: none; }
1252 1249 .autoscroll {overflow-x: visible;}
1253 1250 table.list {margin-top:0.5em;}
1254 1251 table.list th, table.list td {border: 1px solid #aaa;}
1255 1252 }
1256 1253
1257 1254 /* Accessibility specific styles */
1258 1255 .hidden-for-sighted {
1259 1256 position:absolute;
1260 1257 left:-10000px;
1261 1258 top:auto;
1262 1259 width:1px;
1263 1260 height:1px;
1264 1261 overflow:hidden;
1265 1262 }
@@ -1,4466 +1,4466
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class IssuesControllerTest < ActionController::TestCase
21 21 fixtures :projects,
22 22 :users, :email_addresses,
23 23 :roles,
24 24 :members,
25 25 :member_roles,
26 26 :issues,
27 27 :issue_statuses,
28 28 :issue_relations,
29 29 :versions,
30 30 :trackers,
31 31 :projects_trackers,
32 32 :issue_categories,
33 33 :enabled_modules,
34 34 :enumerations,
35 35 :attachments,
36 36 :workflows,
37 37 :custom_fields,
38 38 :custom_values,
39 39 :custom_fields_projects,
40 40 :custom_fields_trackers,
41 41 :time_entries,
42 42 :journals,
43 43 :journal_details,
44 44 :queries,
45 45 :repositories,
46 46 :changesets
47 47
48 48 include Redmine::I18n
49 49
50 50 def setup
51 51 User.current = nil
52 52 end
53 53
54 54 def test_index
55 55 with_settings :default_language => "en" do
56 56 get :index
57 57 assert_response :success
58 58 assert_template 'index'
59 59 assert_not_nil assigns(:issues)
60 60 assert_nil assigns(:project)
61 61
62 62 # links to visible issues
63 63 assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
64 64 assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
65 65 # private projects hidden
66 66 assert_select 'a[href="/issues/6"]', 0
67 67 assert_select 'a[href="/issues/4"]', 0
68 68 # project column
69 69 assert_select 'th', :text => /Project/
70 70 end
71 71 end
72 72
73 73 def test_index_should_not_list_issues_when_module_disabled
74 74 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
75 75 get :index
76 76 assert_response :success
77 77 assert_template 'index'
78 78 assert_not_nil assigns(:issues)
79 79 assert_nil assigns(:project)
80 80
81 81 assert_select 'a[href="/issues/1"]', 0
82 82 assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
83 83 end
84 84
85 85 def test_index_should_list_visible_issues_only
86 86 get :index, :per_page => 100
87 87 assert_response :success
88 88 assert_not_nil assigns(:issues)
89 89 assert_nil assigns(:issues).detect {|issue| !issue.visible?}
90 90 end
91 91
92 92 def test_index_with_project
93 93 Setting.display_subprojects_issues = 0
94 94 get :index, :project_id => 1
95 95 assert_response :success
96 96 assert_template 'index'
97 97 assert_not_nil assigns(:issues)
98 98
99 99 assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
100 100 assert_select 'a[href="/issues/5"]', 0
101 101 end
102 102
103 103 def test_index_with_project_and_subprojects
104 104 Setting.display_subprojects_issues = 1
105 105 get :index, :project_id => 1
106 106 assert_response :success
107 107 assert_template 'index'
108 108 assert_not_nil assigns(:issues)
109 109
110 110 assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
111 111 assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
112 112 assert_select 'a[href="/issues/6"]', 0
113 113 end
114 114
115 115 def test_index_with_project_and_subprojects_should_show_private_subprojects_with_permission
116 116 @request.session[:user_id] = 2
117 117 Setting.display_subprojects_issues = 1
118 118 get :index, :project_id => 1
119 119 assert_response :success
120 120 assert_template 'index'
121 121 assert_not_nil assigns(:issues)
122 122
123 123 assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/
124 124 assert_select 'a[href="/issues/5"]', :text => /Subproject issue/
125 125 assert_select 'a[href="/issues/6"]', :text => /Issue of a private subproject/
126 126 end
127 127
128 128 def test_index_with_project_and_default_filter
129 129 get :index, :project_id => 1, :set_filter => 1
130 130 assert_response :success
131 131 assert_template 'index'
132 132 assert_not_nil assigns(:issues)
133 133
134 134 query = assigns(:query)
135 135 assert_not_nil query
136 136 # default filter
137 137 assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters)
138 138 end
139 139
140 140 def test_index_with_project_and_filter
141 141 get :index, :project_id => 1, :set_filter => 1,
142 142 :f => ['tracker_id'],
143 143 :op => {'tracker_id' => '='},
144 144 :v => {'tracker_id' => ['1']}
145 145 assert_response :success
146 146 assert_template 'index'
147 147 assert_not_nil assigns(:issues)
148 148
149 149 query = assigns(:query)
150 150 assert_not_nil query
151 151 assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters)
152 152 end
153 153
154 154 def test_index_with_short_filters
155 155 to_test = {
156 156 'status_id' => {
157 157 'o' => { :op => 'o', :values => [''] },
158 158 'c' => { :op => 'c', :values => [''] },
159 159 '7' => { :op => '=', :values => ['7'] },
160 160 '7|3|4' => { :op => '=', :values => ['7', '3', '4'] },
161 161 '=7' => { :op => '=', :values => ['7'] },
162 162 '!3' => { :op => '!', :values => ['3'] },
163 163 '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }},
164 164 'subject' => {
165 165 'This is a subject' => { :op => '=', :values => ['This is a subject'] },
166 166 'o' => { :op => '=', :values => ['o'] },
167 167 '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] },
168 168 '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }},
169 169 'tracker_id' => {
170 170 '3' => { :op => '=', :values => ['3'] },
171 171 '=3' => { :op => '=', :values => ['3'] }},
172 172 'start_date' => {
173 173 '2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
174 174 '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] },
175 175 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
176 176 '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] },
177 177 '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] },
178 178 '<t+2' => { :op => '<t+', :values => ['2'] },
179 179 '>t+2' => { :op => '>t+', :values => ['2'] },
180 180 't+2' => { :op => 't+', :values => ['2'] },
181 181 't' => { :op => 't', :values => [''] },
182 182 'w' => { :op => 'w', :values => [''] },
183 183 '>t-2' => { :op => '>t-', :values => ['2'] },
184 184 '<t-2' => { :op => '<t-', :values => ['2'] },
185 185 't-2' => { :op => 't-', :values => ['2'] }},
186 186 'created_on' => {
187 187 '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
188 188 '<t-2' => { :op => '<t-', :values => ['2'] },
189 189 '>t-2' => { :op => '>t-', :values => ['2'] },
190 190 't-2' => { :op => 't-', :values => ['2'] }},
191 191 'cf_1' => {
192 192 'c' => { :op => '=', :values => ['c'] },
193 193 '!c' => { :op => '!', :values => ['c'] },
194 194 '!*' => { :op => '!*', :values => [''] },
195 195 '*' => { :op => '*', :values => [''] }},
196 196 'estimated_hours' => {
197 197 '=13.4' => { :op => '=', :values => ['13.4'] },
198 198 '>=45' => { :op => '>=', :values => ['45'] },
199 199 '<=125' => { :op => '<=', :values => ['125'] },
200 200 '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] },
201 201 '!*' => { :op => '!*', :values => [''] },
202 202 '*' => { :op => '*', :values => [''] }}
203 203 }
204 204
205 205 default_filter = { 'status_id' => {:operator => 'o', :values => [''] }}
206 206
207 207 to_test.each do |field, expression_and_expected|
208 208 expression_and_expected.each do |filter_expression, expected|
209 209
210 210 get :index, :set_filter => 1, field => filter_expression
211 211
212 212 assert_response :success
213 213 assert_template 'index'
214 214 assert_not_nil assigns(:issues)
215 215
216 216 query = assigns(:query)
217 217 assert_not_nil query
218 218 assert query.has_filter?(field)
219 219 assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters)
220 220 end
221 221 end
222 222 end
223 223
224 224 def test_index_with_project_and_empty_filters
225 225 get :index, :project_id => 1, :set_filter => 1, :fields => ['']
226 226 assert_response :success
227 227 assert_template 'index'
228 228 assert_not_nil assigns(:issues)
229 229
230 230 query = assigns(:query)
231 231 assert_not_nil query
232 232 # no filter
233 233 assert_equal({}, query.filters)
234 234 end
235 235
236 236 def test_index_with_project_custom_field_filter
237 237 field = ProjectCustomField.create!(:name => 'Client', :is_filter => true, :field_format => 'string')
238 238 CustomValue.create!(:custom_field => field, :customized => Project.find(3), :value => 'Foo')
239 239 CustomValue.create!(:custom_field => field, :customized => Project.find(5), :value => 'Foo')
240 240 filter_name = "project.cf_#{field.id}"
241 241 @request.session[:user_id] = 1
242 242
243 243 get :index, :set_filter => 1,
244 244 :f => [filter_name],
245 245 :op => {filter_name => '='},
246 246 :v => {filter_name => ['Foo']}
247 247 assert_response :success
248 248 assert_template 'index'
249 249 assert_equal [3, 5], assigns(:issues).map(&:project_id).uniq.sort
250 250 end
251 251
252 252 def test_index_with_query
253 253 get :index, :project_id => 1, :query_id => 5
254 254 assert_response :success
255 255 assert_template 'index'
256 256 assert_not_nil assigns(:issues)
257 257 assert_nil assigns(:issue_count_by_group)
258 258 end
259 259
260 260 def test_index_with_query_grouped_by_tracker
261 261 get :index, :project_id => 1, :query_id => 6
262 262 assert_response :success
263 263 assert_template 'index'
264 264 assert_not_nil assigns(:issues)
265 265 assert_not_nil assigns(:issue_count_by_group)
266 266 end
267 267
268 268 def test_index_with_query_grouped_and_sorted_by_category
269 269 get :index, :project_id => 1, :set_filter => 1, :group_by => "category", :sort => "category"
270 270 assert_response :success
271 271 assert_template 'index'
272 272 assert_not_nil assigns(:issues)
273 273 assert_not_nil assigns(:issue_count_by_group)
274 274 end
275 275
276 276 def test_index_with_query_grouped_by_list_custom_field
277 277 get :index, :project_id => 1, :query_id => 9
278 278 assert_response :success
279 279 assert_template 'index'
280 280 assert_not_nil assigns(:issues)
281 281 assert_not_nil assigns(:issue_count_by_group)
282 282 end
283 283
284 284 def test_index_with_query_grouped_by_user_custom_field
285 285 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
286 286 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
287 287 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
288 288 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
289 289 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
290 290
291 291 get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
292 292 assert_response :success
293 293
294 294 assert_select 'tr.group', 3
295 295 assert_select 'tr.group' do
296 296 assert_select 'a', :text => 'John Smith'
297 297 assert_select 'span.count', :text => '1'
298 298 end
299 299 assert_select 'tr.group' do
300 300 assert_select 'a', :text => 'Dave Lopper'
301 301 assert_select 'span.count', :text => '2'
302 302 end
303 303 end
304 304
305 305 def test_index_grouped_by_boolean_custom_field_should_distinguish_blank_and_false_values
306 306 cf = IssueCustomField.create!(:name => 'Bool', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'bool')
307 307 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '1')
308 308 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '0')
309 309 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '')
310 310
311 311 with_settings :default_language => 'en' do
312 312 get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}"
313 313 assert_response :success
314 314 end
315 315
316 316 assert_select 'tr.group', 3
317 317 assert_select 'tr.group', :text => /Yes/
318 318 assert_select 'tr.group', :text => /No/
319 319 assert_select 'tr.group', :text => /blank/
320 320 end
321 321
322 322 def test_index_grouped_by_boolean_custom_field_with_false_group_in_first_position_should_show_the_group
323 323 cf = IssueCustomField.create!(:name => 'Bool', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'bool', :is_filter => true)
324 324 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '0')
325 325 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '0')
326 326
327 327 with_settings :default_language => 'en' do
328 328 get :index, :project_id => 1, :set_filter => 1, "cf_#{cf.id}" => "*", :group_by => "cf_#{cf.id}"
329 329 assert_response :success
330 330 assert_equal [1, 2], assigns(:issues).map(&:id).sort
331 331 end
332 332
333 333 assert_select 'tr.group', 1
334 334 assert_select 'tr.group', :text => /No/
335 335 end
336 336
337 337 def test_index_with_query_grouped_by_tracker_in_normal_order
338 338 3.times {|i| Issue.generate!(:tracker_id => (i + 1))}
339 339
340 340 get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc'
341 341 assert_response :success
342 342
343 343 trackers = assigns(:issues).map(&:tracker).uniq
344 344 assert_equal [1, 2, 3], trackers.map(&:id)
345 345 end
346 346
347 347 def test_index_with_query_grouped_by_tracker_in_reverse_order
348 348 3.times {|i| Issue.generate!(:tracker_id => (i + 1))}
349 349
350 350 get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc,tracker:desc'
351 351 assert_response :success
352 352
353 353 trackers = assigns(:issues).map(&:tracker).uniq
354 354 assert_equal [3, 2, 1], trackers.map(&:id)
355 355 end
356 356
357 357 def test_index_with_query_id_and_project_id_should_set_session_query
358 358 get :index, :project_id => 1, :query_id => 4
359 359 assert_response :success
360 360 assert_kind_of Hash, session[:query]
361 361 assert_equal 4, session[:query][:id]
362 362 assert_equal 1, session[:query][:project_id]
363 363 end
364 364
365 365 def test_index_with_invalid_query_id_should_respond_404
366 366 get :index, :project_id => 1, :query_id => 999
367 367 assert_response 404
368 368 end
369 369
370 370 def test_index_with_cross_project_query_in_session_should_show_project_issues
371 371 q = IssueQuery.create!(:name => "test", :user_id => 2, :visibility => IssueQuery::VISIBILITY_PRIVATE, :project => nil)
372 372 @request.session[:query] = {:id => q.id, :project_id => 1}
373 373
374 374 with_settings :display_subprojects_issues => '0' do
375 375 get :index, :project_id => 1
376 376 end
377 377 assert_response :success
378 378 assert_not_nil assigns(:query)
379 379 assert_equal q.id, assigns(:query).id
380 380 assert_equal 1, assigns(:query).project_id
381 381 assert_equal [1], assigns(:issues).map(&:project_id).uniq
382 382 end
383 383
384 384 def test_private_query_should_not_be_available_to_other_users
385 385 q = IssueQuery.create!(:name => "private", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PRIVATE, :project => nil)
386 386 @request.session[:user_id] = 3
387 387
388 388 get :index, :query_id => q.id
389 389 assert_response 403
390 390 end
391 391
392 392 def test_private_query_should_be_available_to_its_user
393 393 q = IssueQuery.create!(:name => "private", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PRIVATE, :project => nil)
394 394 @request.session[:user_id] = 2
395 395
396 396 get :index, :query_id => q.id
397 397 assert_response :success
398 398 end
399 399
400 400 def test_public_query_should_be_available_to_other_users
401 401 q = IssueQuery.create!(:name => "public", :user => User.find(2), :visibility => IssueQuery::VISIBILITY_PUBLIC, :project => nil)
402 402 @request.session[:user_id] = 3
403 403
404 404 get :index, :query_id => q.id
405 405 assert_response :success
406 406 end
407 407
408 408 def test_index_should_omit_page_param_in_export_links
409 409 get :index, :page => 2
410 410 assert_response :success
411 411 assert_select 'a.atom[href="/issues.atom"]'
412 412 assert_select 'a.csv[href="/issues.csv"]'
413 413 assert_select 'a.pdf[href="/issues.pdf"]'
414 414 assert_select 'form#csv-export-form[action="/issues.csv"]'
415 415 end
416 416
417 417 def test_index_should_not_warn_when_not_exceeding_export_limit
418 418 with_settings :issues_export_limit => 200 do
419 419 get :index
420 420 assert_select '#csv-export-options p.icon-warning', 0
421 421 end
422 422 end
423 423
424 424 def test_index_should_warn_when_exceeding_export_limit
425 425 with_settings :issues_export_limit => 2 do
426 426 get :index
427 427 assert_select '#csv-export-options p.icon-warning', :text => %r{limit: 2}
428 428 end
429 429 end
430 430
431 431 def test_index_csv
432 432 get :index, :format => 'csv'
433 433 assert_response :success
434 434 assert_not_nil assigns(:issues)
435 435 assert_equal 'text/csv; header=present', @response.content_type
436 436 assert @response.body.starts_with?("#,")
437 437 lines = @response.body.chomp.split("\n")
438 438 assert_equal assigns(:query).columns.size, lines[0].split(',').size
439 439 end
440 440
441 441 def test_index_csv_with_project
442 442 get :index, :project_id => 1, :format => 'csv'
443 443 assert_response :success
444 444 assert_not_nil assigns(:issues)
445 445 assert_equal 'text/csv; header=present', @response.content_type
446 446 end
447 447
448 448 def test_index_csv_with_description
449 449 Issue.generate!(:description => 'test_index_csv_with_description')
450 450
451 451 with_settings :default_language => 'en' do
452 452 get :index, :format => 'csv', :csv => {:description => '1'}
453 453 assert_response :success
454 454 assert_not_nil assigns(:issues)
455 455 end
456 456
457 457 assert_equal 'text/csv; header=present', response.content_type
458 458 headers = response.body.chomp.split("\n").first.split(',')
459 459 assert_include 'Description', headers
460 460 assert_include 'test_index_csv_with_description', response.body
461 461 end
462 462
463 463 def test_index_csv_with_spent_time_column
464 464 issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2)
465 465 TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today)
466 466
467 467 get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours)
468 468 assert_response :success
469 469 assert_equal 'text/csv; header=present', @response.content_type
470 470 lines = @response.body.chomp.split("\n")
471 471 assert_include "#{issue.id},#{issue.subject},7.33", lines
472 472 end
473 473
474 474 def test_index_csv_with_all_columns
475 475 get :index, :format => 'csv', :csv => {:columns => 'all'}
476 476 assert_response :success
477 477 assert_not_nil assigns(:issues)
478 478 assert_equal 'text/csv; header=present', @response.content_type
479 479 assert_match /\A#,/, response.body
480 480 lines = response.body.chomp.split("\n")
481 481 assert_equal assigns(:query).available_inline_columns.size, lines[0].split(',').size
482 482 end
483 483
484 484 def test_index_csv_with_multi_column_field
485 485 CustomField.find(1).update_attribute :multiple, true
486 486 issue = Issue.find(1)
487 487 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
488 488 issue.save!
489 489
490 490 get :index, :format => 'csv', :csv => {:columns => 'all'}
491 491 assert_response :success
492 492 lines = @response.body.chomp.split("\n")
493 493 assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
494 494 end
495 495
496 496 def test_index_csv_should_format_float_custom_fields_with_csv_decimal_separator
497 497 field = IssueCustomField.create!(:name => 'Float', :is_for_all => true, :tracker_ids => [1], :field_format => 'float')
498 498 issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {field.id => '185.6'})
499 499
500 500 with_settings :default_language => 'fr' do
501 501 get :index, :format => 'csv', :csv => {:columns => 'all'}
502 502 assert_response :success
503 503 issue_line = response.body.chomp.split("\n").map {|line| line.split(';')}.detect {|line| line[0]==issue.id.to_s}
504 504 assert_include '185,60', issue_line
505 505 end
506 506
507 507 with_settings :default_language => 'en' do
508 508 get :index, :format => 'csv', :csv => {:columns => 'all'}
509 509 assert_response :success
510 510 issue_line = response.body.chomp.split("\n").map {|line| line.split(',')}.detect {|line| line[0]==issue.id.to_s}
511 511 assert_include '185.60', issue_line
512 512 end
513 513 end
514 514
515 515 def test_index_csv_should_fill_parent_column_with_parent_id
516 516 Issue.delete_all
517 517 parent = Issue.generate!
518 518 child = Issue.generate!(:parent_issue_id => parent.id)
519 519
520 520 with_settings :default_language => 'en' do
521 521 get :index, :format => 'csv', :c => %w(parent)
522 522 end
523 523 lines = response.body.split("\n")
524 524 assert_include "#{child.id},#{parent.id}", lines
525 525 end
526 526
527 527 def test_index_csv_big_5
528 528 with_settings :default_language => "zh-TW" do
529 529 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
530 530 str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
531 531 issue = Issue.generate!(:subject => str_utf8)
532 532
533 533 get :index, :project_id => 1,
534 534 :f => ['subject'],
535 535 :op => '=', :values => [str_utf8],
536 536 :format => 'csv'
537 537 assert_equal 'text/csv; header=present', @response.content_type
538 538 lines = @response.body.chomp.split("\n")
539 539 header = lines[0]
540 540 status = "\xaa\xac\xbaA".force_encoding('Big5')
541 541 assert header.include?(status)
542 542 issue_line = lines.find {|l| l =~ /^#{issue.id},/}
543 543 assert issue_line.include?(str_big5)
544 544 end
545 545 end
546 546
547 547 def test_index_csv_cannot_convert_should_be_replaced_big_5
548 548 with_settings :default_language => "zh-TW" do
549 549 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
550 550 issue = Issue.generate!(:subject => str_utf8)
551 551
552 552 get :index, :project_id => 1,
553 553 :f => ['subject'],
554 554 :op => '=', :values => [str_utf8],
555 555 :c => ['status', 'subject'],
556 556 :format => 'csv',
557 557 :set_filter => 1
558 558 assert_equal 'text/csv; header=present', @response.content_type
559 559 lines = @response.body.chomp.split("\n")
560 560 header = lines[0]
561 561 issue_line = lines.find {|l| l =~ /^#{issue.id},/}
562 562 s1 = "\xaa\xac\xbaA".force_encoding('Big5') # status
563 563 assert header.include?(s1)
564 564 s2 = issue_line.split(",")[2]
565 565 s3 = "\xa5H?".force_encoding('Big5') # subject
566 566 assert_equal s3, s2
567 567 end
568 568 end
569 569
570 570 def test_index_csv_tw
571 571 with_settings :default_language => "zh-TW" do
572 572 str1 = "test_index_csv_tw"
573 573 issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
574 574
575 575 get :index, :project_id => 1,
576 576 :f => ['subject'],
577 577 :op => '=', :values => [str1],
578 578 :c => ['estimated_hours', 'subject'],
579 579 :format => 'csv',
580 580 :set_filter => 1
581 581 assert_equal 'text/csv; header=present', @response.content_type
582 582 lines = @response.body.chomp.split("\n")
583 583 assert_include "#{issue.id},1234.50,#{str1}", lines
584 584 end
585 585 end
586 586
587 587 def test_index_csv_fr
588 588 with_settings :default_language => "fr" do
589 589 str1 = "test_index_csv_fr"
590 590 issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
591 591
592 592 get :index, :project_id => 1,
593 593 :f => ['subject'],
594 594 :op => '=', :values => [str1],
595 595 :c => ['estimated_hours', 'subject'],
596 596 :format => 'csv',
597 597 :set_filter => 1
598 598 assert_equal 'text/csv; header=present', @response.content_type
599 599 lines = @response.body.chomp.split("\n")
600 600 assert_include "#{issue.id};1234,50;#{str1}", lines
601 601 end
602 602 end
603 603
604 604 def test_index_pdf
605 605 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
606 606 with_settings :default_language => lang do
607 607
608 608 get :index
609 609 assert_response :success
610 610 assert_template 'index'
611 611
612 612 get :index, :format => 'pdf'
613 613 assert_response :success
614 614 assert_not_nil assigns(:issues)
615 615 assert_equal 'application/pdf', @response.content_type
616 616
617 617 get :index, :project_id => 1, :format => 'pdf'
618 618 assert_response :success
619 619 assert_not_nil assigns(:issues)
620 620 assert_equal 'application/pdf', @response.content_type
621 621
622 622 get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
623 623 assert_response :success
624 624 assert_not_nil assigns(:issues)
625 625 assert_equal 'application/pdf', @response.content_type
626 626 end
627 627 end
628 628 end
629 629
630 630 def test_index_pdf_with_query_grouped_by_list_custom_field
631 631 get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
632 632 assert_response :success
633 633 assert_not_nil assigns(:issues)
634 634 assert_not_nil assigns(:issue_count_by_group)
635 635 assert_equal 'application/pdf', @response.content_type
636 636 end
637 637
638 638 def test_index_atom
639 639 get :index, :project_id => 'ecookbook', :format => 'atom'
640 640 assert_response :success
641 641 assert_template 'common/feed'
642 642 assert_equal 'application/atom+xml', response.content_type
643 643
644 644 assert_select 'feed' do
645 645 assert_select 'link[rel=self][href=?]', 'http://test.host/projects/ecookbook/issues.atom'
646 646 assert_select 'link[rel=alternate][href=?]', 'http://test.host/projects/ecookbook/issues'
647 647 assert_select 'entry link[href=?]', 'http://test.host/issues/1'
648 648 end
649 649 end
650 650
651 651 def test_index_sort
652 652 get :index, :sort => 'tracker,id:desc'
653 653 assert_response :success
654 654
655 655 sort_params = @request.session['issues_index_sort']
656 656 assert sort_params.is_a?(String)
657 657 assert_equal 'tracker,id:desc', sort_params
658 658
659 659 issues = assigns(:issues)
660 660 assert_not_nil issues
661 661 assert !issues.empty?
662 662 assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
663 663 assert_select 'table.issues.sort-by-tracker.sort-asc'
664 664 end
665 665
666 666 def test_index_sort_by_field_not_included_in_columns
667 667 Setting.issue_list_default_columns = %w(subject author)
668 668 get :index, :sort => 'tracker'
669 669 end
670 670
671 671 def test_index_sort_by_assigned_to
672 672 get :index, :sort => 'assigned_to'
673 673 assert_response :success
674 674 assignees = assigns(:issues).collect(&:assigned_to).compact
675 675 assert_equal assignees.sort, assignees
676 676 assert_select 'table.issues.sort-by-assigned-to.sort-asc'
677 677 end
678 678
679 679 def test_index_sort_by_assigned_to_desc
680 680 get :index, :sort => 'assigned_to:desc'
681 681 assert_response :success
682 682 assignees = assigns(:issues).collect(&:assigned_to).compact
683 683 assert_equal assignees.sort.reverse, assignees
684 684 assert_select 'table.issues.sort-by-assigned-to.sort-desc'
685 685 end
686 686
687 687 def test_index_group_by_assigned_to
688 688 get :index, :group_by => 'assigned_to', :sort => 'priority'
689 689 assert_response :success
690 690 end
691 691
692 692 def test_index_sort_by_author
693 693 get :index, :sort => 'author'
694 694 assert_response :success
695 695 authors = assigns(:issues).collect(&:author)
696 696 assert_equal authors.sort, authors
697 697 end
698 698
699 699 def test_index_sort_by_author_desc
700 700 get :index, :sort => 'author:desc'
701 701 assert_response :success
702 702 authors = assigns(:issues).collect(&:author)
703 703 assert_equal authors.sort.reverse, authors
704 704 end
705 705
706 706 def test_index_group_by_author
707 707 get :index, :group_by => 'author', :sort => 'priority'
708 708 assert_response :success
709 709 end
710 710
711 711 def test_index_sort_by_spent_hours
712 712 get :index, :sort => 'spent_hours:desc'
713 713 assert_response :success
714 714 hours = assigns(:issues).collect(&:spent_hours)
715 715 assert_equal hours.sort.reverse, hours
716 716 end
717 717
718 718 def test_index_sort_by_total_spent_hours
719 719 get :index, :sort => 'total_spent_hours:desc'
720 720 assert_response :success
721 721 hours = assigns(:issues).collect(&:total_spent_hours)
722 722 assert_equal hours.sort.reverse, hours
723 723 end
724 724
725 725 def test_index_sort_by_total_estimated_hours
726 726 get :index, :sort => 'total_estimated_hours:desc'
727 727 assert_response :success
728 728 hours = assigns(:issues).collect(&:total_estimated_hours)
729 729 assert_equal hours.sort.reverse, hours
730 730 end
731 731
732 732 def test_index_sort_by_user_custom_field
733 733 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
734 734 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
735 735 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
736 736 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
737 737 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
738 738
739 739 get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id"
740 740 assert_response :success
741 741
742 742 assert_equal [2, 3, 1], assigns(:issues).select {|issue| issue.custom_field_value(cf).present?}.map(&:id)
743 743 end
744 744
745 745 def test_index_with_columns
746 746 columns = ['tracker', 'subject', 'assigned_to']
747 747 get :index, :set_filter => 1, :c => columns
748 748 assert_response :success
749 749
750 750 # query should use specified columns
751 751 query = assigns(:query)
752 752 assert_kind_of IssueQuery, query
753 753 assert_equal columns, query.column_names.map(&:to_s)
754 754
755 755 # columns should be stored in session
756 756 assert_kind_of Hash, session[:query]
757 757 assert_kind_of Array, session[:query][:column_names]
758 758 assert_equal columns, session[:query][:column_names].map(&:to_s)
759 759
760 760 # ensure only these columns are kept in the selected columns list
761 761 assert_select 'select#selected_columns option' do
762 762 assert_select 'option', 3
763 763 assert_select 'option[value=tracker]'
764 764 assert_select 'option[value=project]', 0
765 765 end
766 766 end
767 767
768 768 def test_index_without_project_should_implicitly_add_project_column_to_default_columns
769 769 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
770 770 get :index, :set_filter => 1
771 771
772 772 # query should use specified columns
773 773 query = assigns(:query)
774 774 assert_kind_of IssueQuery, query
775 775 assert_equal [:id, :project, :tracker, :subject, :assigned_to], query.columns.map(&:name)
776 776 end
777 777
778 778 def test_index_without_project_and_explicit_default_columns_should_not_add_project_column
779 779 Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to']
780 780 columns = ['id', 'tracker', 'subject', 'assigned_to']
781 781 get :index, :set_filter => 1, :c => columns
782 782
783 783 # query should use specified columns
784 784 query = assigns(:query)
785 785 assert_kind_of IssueQuery, query
786 786 assert_equal columns.map(&:to_sym), query.columns.map(&:name)
787 787 end
788 788
789 789 def test_index_with_default_columns_should_respect_default_columns_order
790 790 columns = ['assigned_to', 'subject', 'status', 'tracker']
791 791 with_settings :issue_list_default_columns => columns do
792 792 get :index, :project_id => 1, :set_filter => 1
793 793
794 794 query = assigns(:query)
795 795 assert_equal (['id'] + columns).map(&:to_sym), query.columns.map(&:name)
796 796 end
797 797 end
798 798
799 799 def test_index_with_custom_field_column
800 800 columns = %w(tracker subject cf_2)
801 801 get :index, :set_filter => 1, :c => columns
802 802 assert_response :success
803 803
804 804 # query should use specified columns
805 805 query = assigns(:query)
806 806 assert_kind_of IssueQuery, query
807 807 assert_equal columns, query.column_names.map(&:to_s)
808 808
809 809 assert_select 'table.issues td.cf_2.string'
810 810 end
811 811
812 812 def test_index_with_multi_custom_field_column
813 813 field = CustomField.find(1)
814 814 field.update_attribute :multiple, true
815 815 issue = Issue.find(1)
816 816 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
817 817 issue.save!
818 818
819 819 get :index, :set_filter => 1, :c => %w(tracker subject cf_1)
820 820 assert_response :success
821 821
822 822 assert_select 'table.issues td.cf_1', :text => 'MySQL, Oracle'
823 823 end
824 824
825 825 def test_index_with_multi_user_custom_field_column
826 826 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
827 827 :tracker_ids => [1], :is_for_all => true)
828 828 issue = Issue.find(1)
829 829 issue.custom_field_values = {field.id => ['2', '3']}
830 830 issue.save!
831 831
832 832 get :index, :set_filter => 1, :c => ['tracker', 'subject', "cf_#{field.id}"]
833 833 assert_response :success
834 834
835 835 assert_select "table.issues td.cf_#{field.id}" do
836 836 assert_select 'a', 2
837 837 assert_select 'a[href=?]', '/users/2', :text => 'John Smith'
838 838 assert_select 'a[href=?]', '/users/3', :text => 'Dave Lopper'
839 839 end
840 840 end
841 841
842 842 def test_index_with_date_column
843 843 with_settings :date_format => '%d/%m/%Y' do
844 844 Issue.find(1).update_attribute :start_date, '1987-08-24'
845 845 get :index, :set_filter => 1, :c => %w(start_date)
846 846 assert_select "table.issues td.start_date", :text => '24/08/1987'
847 847 end
848 848 end
849 849
850 850 def test_index_with_done_ratio_column
851 851 Issue.find(1).update_attribute :done_ratio, 40
852 852 get :index, :set_filter => 1, :c => %w(done_ratio)
853 853 assert_select 'table.issues td.done_ratio' do
854 854 assert_select 'table.progress' do
855 855 assert_select 'td.closed[style=?]', 'width: 40%;'
856 856 end
857 857 end
858 858 end
859 859
860 860 def test_index_with_spent_hours_column
861 861 Issue.expects(:load_visible_spent_hours).once
862 862 get :index, :set_filter => 1, :c => %w(subject spent_hours)
863 863 assert_select 'table.issues tr#issue-3 td.spent_hours', :text => '1.00'
864 864 end
865 865
866 866 def test_index_with_total_spent_hours_column
867 867 Issue.expects(:load_visible_total_spent_hours).once
868 868 get :index, :set_filter => 1, :c => %w(subject total_spent_hours)
869 869 assert_select 'table.issues tr#issue-3 td.total_spent_hours', :text => '1.00'
870 870 end
871 871
872 872 def test_index_with_total_estimated_hours_column
873 873 get :index, :set_filter => 1, :c => %w(subject total_estimated_hours)
874 874 assert_select 'table.issues td.total_estimated_hours'
875 875 end
876 876
877 877 def test_index_should_not_show_spent_hours_column_without_permission
878 878 Role.anonymous.remove_permission! :view_time_entries
879 879 get :index, :set_filter => 1, :c => %w(subject spent_hours)
880 880 assert_select 'td.spent_hours', 0
881 881 end
882 882
883 883 def test_index_with_fixed_version_column
884 884 get :index, :set_filter => 1, :c => %w(fixed_version)
885 885 assert_select 'table.issues td.fixed_version' do
886 886 assert_select 'a[href=?]', '/versions/2', :text => 'eCookbook - 1.0'
887 887 end
888 888 end
889 889
890 890 def test_index_with_relations_column
891 891 IssueRelation.delete_all
892 892 IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(1), :issue_to => Issue.find(7))
893 893 IssueRelation.create!(:relation_type => "relates", :issue_from => Issue.find(8), :issue_to => Issue.find(1))
894 894 IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(1), :issue_to => Issue.find(11))
895 895 IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(12), :issue_to => Issue.find(2))
896 896
897 897 get :index, :set_filter => 1, :c => %w(subject relations)
898 898 assert_response :success
899 899 assert_select "tr#issue-1 td.relations" do
900 900 assert_select "span", 3
901 901 assert_select "span", :text => "Related to #7"
902 902 assert_select "span", :text => "Related to #8"
903 903 assert_select "span", :text => "Blocks #11"
904 904 end
905 905 assert_select "tr#issue-2 td.relations" do
906 906 assert_select "span", 1
907 907 assert_select "span", :text => "Blocked by #12"
908 908 end
909 909 assert_select "tr#issue-3 td.relations" do
910 910 assert_select "span", 0
911 911 end
912 912
913 913 get :index, :set_filter => 1, :c => %w(relations), :format => 'csv'
914 914 assert_response :success
915 915 assert_equal 'text/csv; header=present', response.content_type
916 916 lines = response.body.chomp.split("\n")
917 917 assert_include '1,"Related to #7, Related to #8, Blocks #11"', lines
918 918 assert_include '2,Blocked by #12', lines
919 919 assert_include '3,""', lines
920 920
921 921 get :index, :set_filter => 1, :c => %w(subject relations), :format => 'pdf'
922 922 assert_response :success
923 923 assert_equal 'application/pdf', response.content_type
924 924 end
925 925
926 926 def test_index_with_description_column
927 927 get :index, :set_filter => 1, :c => %w(subject description)
928 928
929 929 assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject
930 930 assert_select 'td.description[colspan="3"]', :text => 'Unable to print recipes'
931 931
932 932 get :index, :set_filter => 1, :c => %w(subject description), :format => 'pdf'
933 933 assert_response :success
934 934 assert_equal 'application/pdf', response.content_type
935 935 end
936 936
937 937 def test_index_with_parent_column
938 938 Issue.delete_all
939 939 parent = Issue.generate!
940 940 child = Issue.generate!(:parent_issue_id => parent.id)
941 941
942 942 get :index, :c => %w(parent)
943 943
944 944 assert_select 'td.parent', :text => "#{parent.tracker} ##{parent.id}"
945 945 assert_select 'td.parent a[title=?]', parent.subject
946 946 end
947 947
948 948 def test_index_with_estimated_hours_total
949 949 Issue.delete_all
950 950 Issue.generate!(:estimated_hours => 5.5)
951 951 Issue.generate!(:estimated_hours => 1.1)
952 952
953 953 get :index, :t => %w(estimated_hours)
954 954 assert_response :success
955 955 assert_select '.query-totals'
956 956 assert_select '.total-for-estimated-hours span.value', :text => '6.60'
957 957 assert_select 'input[type=checkbox][name=?][value=estimated_hours][checked=checked]', 't[]'
958 958 end
959 959
960 960 def test_index_with_grouped_query_and_estimated_hours_total
961 961 Issue.delete_all
962 962 Issue.generate!(:estimated_hours => 5.5, :category_id => 1)
963 963 Issue.generate!(:estimated_hours => 2.3, :category_id => 1)
964 964 Issue.generate!(:estimated_hours => 1.1, :category_id => 2)
965 965 Issue.generate!(:estimated_hours => 4.6)
966 966
967 967 get :index, :t => %w(estimated_hours), :group_by => 'category'
968 968 assert_response :success
969 969 assert_select '.query-totals'
970 970 assert_select '.query-totals .total-for-estimated-hours span.value', :text => '13.50'
971 971 assert_select 'tr.group', :text => /Printing/ do
972 972 assert_select '.total-for-estimated-hours span.value', :text => '7.80'
973 973 end
974 974 assert_select 'tr.group', :text => /Recipes/ do
975 975 assert_select '.total-for-estimated-hours span.value', :text => '1.10'
976 976 end
977 977 assert_select 'tr.group', :text => /blank/ do
978 978 assert_select '.total-for-estimated-hours span.value', :text => '4.60'
979 979 end
980 980 end
981 981
982 982 def test_index_with_int_custom_field_total
983 983 field = IssueCustomField.generate!(:field_format => 'int', :is_for_all => true)
984 984 CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '2')
985 985 CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '7')
986 986
987 987 get :index, :t => ["cf_#{field.id}"]
988 988 assert_response :success
989 989 assert_select '.query-totals'
990 990 assert_select ".total-for-cf-#{field.id} span.value", :text => '9'
991 991 end
992 992
993 993 def test_index_totals_should_default_to_settings
994 994 with_settings :issue_list_default_totals => ['estimated_hours'] do
995 995 get :index
996 996 assert_response :success
997 997 assert_select '.total-for-estimated-hours span.value'
998 998 assert_select '.query-totals>span', 1
999 999 end
1000 1000 end
1001 1001
1002 1002 def test_index_send_html_if_query_is_invalid
1003 1003 get :index, :f => ['start_date'], :op => {:start_date => '='}
1004 1004 assert_equal 'text/html', @response.content_type
1005 1005 assert_template 'index'
1006 1006 end
1007 1007
1008 1008 def test_index_send_nothing_if_query_is_invalid
1009 1009 get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv'
1010 1010 assert_equal 'text/csv', @response.content_type
1011 1011 assert @response.body.blank?
1012 1012 end
1013 1013
1014 1014 def test_show_by_anonymous
1015 1015 get :show, :id => 1
1016 1016 assert_response :success
1017 1017 assert_template 'show'
1018 1018 assert_equal Issue.find(1), assigns(:issue)
1019 1019 assert_select 'div.issue div.description', :text => /Unable to print recipes/
1020 1020 # anonymous role is allowed to add a note
1021 1021 assert_select 'form#issue-form' do
1022 1022 assert_select 'fieldset' do
1023 1023 assert_select 'legend', :text => 'Notes'
1024 1024 assert_select 'textarea[name=?]', 'issue[notes]'
1025 1025 end
1026 1026 end
1027 1027 assert_select 'title', :text => "Bug #1: Cannot print recipes - eCookbook - Redmine"
1028 1028 end
1029 1029
1030 1030 def test_show_by_manager
1031 1031 @request.session[:user_id] = 2
1032 1032 get :show, :id => 1
1033 1033 assert_response :success
1034 1034 assert_select 'a', :text => /Quote/
1035 1035 assert_select 'form#issue-form' do
1036 1036 assert_select 'fieldset' do
1037 1037 assert_select 'legend', :text => 'Change properties'
1038 1038 assert_select 'input[name=?]', 'issue[subject]'
1039 1039 end
1040 1040 assert_select 'fieldset' do
1041 1041 assert_select 'legend', :text => 'Log time'
1042 1042 assert_select 'input[name=?]', 'time_entry[hours]'
1043 1043 end
1044 1044 assert_select 'fieldset' do
1045 1045 assert_select 'legend', :text => 'Notes'
1046 1046 assert_select 'textarea[name=?]', 'issue[notes]'
1047 1047 end
1048 1048 end
1049 1049 end
1050 1050
1051 1051 def test_show_should_display_update_form
1052 1052 @request.session[:user_id] = 2
1053 1053 get :show, :id => 1
1054 1054 assert_response :success
1055 1055
1056 1056 assert_select 'form#issue-form' do
1057 1057 assert_select 'input[name=?]', 'issue[is_private]'
1058 1058 assert_select 'select[name=?]', 'issue[project_id]'
1059 1059 assert_select 'select[name=?]', 'issue[tracker_id]'
1060 1060 assert_select 'input[name=?]', 'issue[subject]'
1061 1061 assert_select 'textarea[name=?]', 'issue[description]'
1062 1062 assert_select 'select[name=?]', 'issue[status_id]'
1063 1063 assert_select 'select[name=?]', 'issue[priority_id]'
1064 1064 assert_select 'select[name=?]', 'issue[assigned_to_id]'
1065 1065 assert_select 'select[name=?]', 'issue[category_id]'
1066 1066 assert_select 'select[name=?]', 'issue[fixed_version_id]'
1067 1067 assert_select 'input[name=?]', 'issue[parent_issue_id]'
1068 1068 assert_select 'input[name=?]', 'issue[start_date]'
1069 1069 assert_select 'input[name=?]', 'issue[due_date]'
1070 1070 assert_select 'select[name=?]', 'issue[done_ratio]'
1071 1071 assert_select 'input[name=?]', 'issue[custom_field_values][2]'
1072 1072 assert_select 'input[name=?]', 'issue[watcher_user_ids][]', 0
1073 1073 assert_select 'textarea[name=?]', 'issue[notes]'
1074 1074 end
1075 1075 end
1076 1076
1077 1077 def test_show_should_display_update_form_with_minimal_permissions
1078 1078 Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
1079 1079 WorkflowTransition.delete_all :role_id => 1
1080 1080
1081 1081 @request.session[:user_id] = 2
1082 1082 get :show, :id => 1
1083 1083 assert_response :success
1084 1084
1085 1085 assert_select 'form#issue-form' do
1086 1086 assert_select 'input[name=?]', 'issue[is_private]', 0
1087 1087 assert_select 'select[name=?]', 'issue[project_id]', 0
1088 1088 assert_select 'select[name=?]', 'issue[tracker_id]', 0
1089 1089 assert_select 'input[name=?]', 'issue[subject]', 0
1090 1090 assert_select 'textarea[name=?]', 'issue[description]', 0
1091 1091 assert_select 'select[name=?]', 'issue[status_id]', 0
1092 1092 assert_select 'select[name=?]', 'issue[priority_id]', 0
1093 1093 assert_select 'select[name=?]', 'issue[assigned_to_id]', 0
1094 1094 assert_select 'select[name=?]', 'issue[category_id]', 0
1095 1095 assert_select 'select[name=?]', 'issue[fixed_version_id]', 0
1096 1096 assert_select 'input[name=?]', 'issue[parent_issue_id]', 0
1097 1097 assert_select 'input[name=?]', 'issue[start_date]', 0
1098 1098 assert_select 'input[name=?]', 'issue[due_date]', 0
1099 1099 assert_select 'select[name=?]', 'issue[done_ratio]', 0
1100 1100 assert_select 'input[name=?]', 'issue[custom_field_values][2]', 0
1101 1101 assert_select 'input[name=?]', 'issue[watcher_user_ids][]', 0
1102 1102 assert_select 'textarea[name=?]', 'issue[notes]'
1103 1103 end
1104 1104 end
1105 1105
1106 1106 def test_show_should_not_display_update_form_without_permissions
1107 1107 Role.find(1).update_attribute :permissions, [:view_issues]
1108 1108
1109 1109 @request.session[:user_id] = 2
1110 1110 get :show, :id => 1
1111 1111 assert_response :success
1112 1112
1113 1113 assert_select 'form#issue-form', 0
1114 1114 end
1115 1115
1116 1116 def test_update_form_should_not_display_inactive_enumerations
1117 1117 assert !IssuePriority.find(15).active?
1118 1118
1119 1119 @request.session[:user_id] = 2
1120 1120 get :show, :id => 1
1121 1121 assert_response :success
1122 1122
1123 1123 assert_select 'form#issue-form' do
1124 1124 assert_select 'select[name=?]', 'issue[priority_id]' do
1125 1125 assert_select 'option[value="4"]'
1126 1126 assert_select 'option[value="15"]', 0
1127 1127 end
1128 1128 end
1129 1129 end
1130 1130
1131 1131 def test_update_form_should_allow_attachment_upload
1132 1132 @request.session[:user_id] = 2
1133 1133 get :show, :id => 1
1134 1134
1135 1135 assert_select 'form#issue-form[method=post][enctype="multipart/form-data"]' do
1136 1136 assert_select 'input[type=file][name=?]', 'attachments[dummy][file]'
1137 1137 end
1138 1138 end
1139 1139
1140 1140 def test_show_should_deny_anonymous_access_without_permission
1141 1141 Role.anonymous.remove_permission!(:view_issues)
1142 1142 get :show, :id => 1
1143 1143 assert_response :redirect
1144 1144 end
1145 1145
1146 1146 def test_show_should_deny_anonymous_access_to_private_issue
1147 1147 Issue.where(:id => 1).update_all(["is_private = ?", true])
1148 1148 get :show, :id => 1
1149 1149 assert_response :redirect
1150 1150 end
1151 1151
1152 1152 def test_show_should_deny_non_member_access_without_permission
1153 1153 Role.non_member.remove_permission!(:view_issues)
1154 1154 @request.session[:user_id] = 9
1155 1155 get :show, :id => 1
1156 1156 assert_response 403
1157 1157 end
1158 1158
1159 1159 def test_show_should_deny_non_member_access_to_private_issue
1160 1160 Issue.where(:id => 1).update_all(["is_private = ?", true])
1161 1161 @request.session[:user_id] = 9
1162 1162 get :show, :id => 1
1163 1163 assert_response 403
1164 1164 end
1165 1165
1166 1166 def test_show_should_deny_member_access_without_permission
1167 1167 Role.find(1).remove_permission!(:view_issues)
1168 1168 @request.session[:user_id] = 2
1169 1169 get :show, :id => 1
1170 1170 assert_response 403
1171 1171 end
1172 1172
1173 1173 def test_show_should_deny_member_access_to_private_issue_without_permission
1174 1174 Issue.where(:id => 1).update_all(["is_private = ?", true])
1175 1175 @request.session[:user_id] = 3
1176 1176 get :show, :id => 1
1177 1177 assert_response 403
1178 1178 end
1179 1179
1180 1180 def test_show_should_allow_author_access_to_private_issue
1181 1181 Issue.where(:id => 1).update_all(["is_private = ?, author_id = 3", true])
1182 1182 @request.session[:user_id] = 3
1183 1183 get :show, :id => 1
1184 1184 assert_response :success
1185 1185 end
1186 1186
1187 1187 def test_show_should_allow_assignee_access_to_private_issue
1188 1188 Issue.where(:id => 1).update_all(["is_private = ?, assigned_to_id = 3", true])
1189 1189 @request.session[:user_id] = 3
1190 1190 get :show, :id => 1
1191 1191 assert_response :success
1192 1192 end
1193 1193
1194 1194 def test_show_should_allow_member_access_to_private_issue_with_permission
1195 1195 Issue.where(:id => 1).update_all(["is_private = ?", true])
1196 1196 User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all'
1197 1197 @request.session[:user_id] = 3
1198 1198 get :show, :id => 1
1199 1199 assert_response :success
1200 1200 end
1201 1201
1202 1202 def test_show_should_not_disclose_relations_to_invisible_issues
1203 1203 Setting.cross_project_issue_relations = '1'
1204 1204 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
1205 1205 # Relation to a private project issue
1206 1206 IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
1207 1207
1208 1208 get :show, :id => 1
1209 1209 assert_response :success
1210 1210
1211 1211 assert_select 'div#relations' do
1212 1212 assert_select 'a', :text => /#2$/
1213 1213 assert_select 'a', :text => /#4$/, :count => 0
1214 1214 end
1215 1215 end
1216 1216
1217 1217 def test_show_should_list_subtasks
1218 1218 Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1219 1219
1220 1220 get :show, :id => 1
1221 1221 assert_response :success
1222 1222
1223 1223 assert_select 'div#issue_tree' do
1224 1224 assert_select 'td.subject', :text => /Child Issue/
1225 1225 end
1226 1226 end
1227 1227
1228 1228 def test_show_should_list_parents
1229 1229 issue = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue')
1230 1230
1231 1231 get :show, :id => issue.id
1232 1232 assert_response :success
1233 1233
1234 1234 assert_select 'div.subject' do
1235 1235 assert_select 'h3', 'Child Issue'
1236 1236 assert_select 'a[href="/issues/1"]'
1237 1237 end
1238 1238 end
1239 1239
1240 1240 def test_show_should_not_display_prev_next_links_without_query_in_session
1241 1241 get :show, :id => 1
1242 1242 assert_response :success
1243 1243 assert_nil assigns(:prev_issue_id)
1244 1244 assert_nil assigns(:next_issue_id)
1245 1245
1246 1246 assert_select 'div.next-prev-links', 0
1247 1247 end
1248 1248
1249 1249 def test_show_should_display_prev_next_links_with_query_in_session
1250 1250 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1251 1251 @request.session['issues_index_sort'] = 'id'
1252 1252
1253 1253 with_settings :display_subprojects_issues => '0' do
1254 1254 get :show, :id => 3
1255 1255 end
1256 1256
1257 1257 assert_response :success
1258 1258 # Previous and next issues for all projects
1259 1259 assert_equal 2, assigns(:prev_issue_id)
1260 1260 assert_equal 5, assigns(:next_issue_id)
1261 1261
1262 1262 count = Issue.open.visible.count
1263 1263
1264 1264 assert_select 'div.next-prev-links' do
1265 1265 assert_select 'a[href="/issues/2"]', :text => /Previous/
1266 1266 assert_select 'a[href="/issues/5"]', :text => /Next/
1267 1267 assert_select 'span.position', :text => "3 of #{count}"
1268 1268 end
1269 1269 end
1270 1270
1271 1271 def test_show_should_display_prev_next_links_with_saved_query_in_session
1272 1272 query = IssueQuery.create!(:name => 'test', :visibility => IssueQuery::VISIBILITY_PUBLIC, :user_id => 1,
1273 1273 :filters => {'status_id' => {:values => ['5'], :operator => '='}},
1274 1274 :sort_criteria => [['id', 'asc']])
1275 1275 @request.session[:query] = {:id => query.id, :project_id => nil}
1276 1276
1277 1277 get :show, :id => 11
1278 1278
1279 1279 assert_response :success
1280 1280 assert_equal query, assigns(:query)
1281 1281 # Previous and next issues for all projects
1282 1282 assert_equal 8, assigns(:prev_issue_id)
1283 1283 assert_equal 12, assigns(:next_issue_id)
1284 1284
1285 1285 assert_select 'div.next-prev-links' do
1286 1286 assert_select 'a[href="/issues/8"]', :text => /Previous/
1287 1287 assert_select 'a[href="/issues/12"]', :text => /Next/
1288 1288 end
1289 1289 end
1290 1290
1291 1291 def test_show_should_display_prev_next_links_with_query_and_sort_on_association
1292 1292 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
1293 1293
1294 1294 %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
1295 1295 @request.session['issues_index_sort'] = assoc_sort
1296 1296
1297 1297 get :show, :id => 3
1298 1298 assert_response :success, "Wrong response status for #{assoc_sort} sort"
1299 1299
1300 1300 assert_select 'div.next-prev-links' do
1301 1301 assert_select 'a', :text => /(Previous|Next)/
1302 1302 end
1303 1303 end
1304 1304 end
1305 1305
1306 1306 def test_show_should_display_prev_next_links_with_project_query_in_session
1307 1307 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1308 1308 @request.session['issues_index_sort'] = 'id'
1309 1309
1310 1310 with_settings :display_subprojects_issues => '0' do
1311 1311 get :show, :id => 3
1312 1312 end
1313 1313
1314 1314 assert_response :success
1315 1315 # Previous and next issues inside project
1316 1316 assert_equal 2, assigns(:prev_issue_id)
1317 1317 assert_equal 7, assigns(:next_issue_id)
1318 1318
1319 1319 assert_select 'div.next-prev-links' do
1320 1320 assert_select 'a[href="/issues/2"]', :text => /Previous/
1321 1321 assert_select 'a[href="/issues/7"]', :text => /Next/
1322 1322 end
1323 1323 end
1324 1324
1325 1325 def test_show_should_not_display_prev_link_for_first_issue
1326 1326 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1}
1327 1327 @request.session['issues_index_sort'] = 'id'
1328 1328
1329 1329 with_settings :display_subprojects_issues => '0' do
1330 1330 get :show, :id => 1
1331 1331 end
1332 1332
1333 1333 assert_response :success
1334 1334 assert_nil assigns(:prev_issue_id)
1335 1335 assert_equal 2, assigns(:next_issue_id)
1336 1336
1337 1337 assert_select 'div.next-prev-links' do
1338 1338 assert_select 'a', :text => /Previous/, :count => 0
1339 1339 assert_select 'a[href="/issues/2"]', :text => /Next/
1340 1340 end
1341 1341 end
1342 1342
1343 1343 def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results
1344 1344 @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'c'}}, :project_id => 1}
1345 1345 @request.session['issues_index_sort'] = 'id'
1346 1346
1347 1347 get :show, :id => 1
1348 1348
1349 1349 assert_response :success
1350 1350 assert_nil assigns(:prev_issue_id)
1351 1351 assert_nil assigns(:next_issue_id)
1352 1352
1353 1353 assert_select 'a', :text => /Previous/, :count => 0
1354 1354 assert_select 'a', :text => /Next/, :count => 0
1355 1355 end
1356 1356
1357 1357 def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field
1358 1358 cf = IssueCustomField.create!(:name => 'User', :is_for_all => true, :tracker_ids => [1,2,3], :field_format => 'user')
1359 1359 CustomValue.create!(:custom_field => cf, :customized => Issue.find(1), :value => '2')
1360 1360 CustomValue.create!(:custom_field => cf, :customized => Issue.find(2), :value => '3')
1361 1361 CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3')
1362 1362 CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '')
1363 1363
1364 1364 query = IssueQuery.create!(:name => 'test', :visibility => IssueQuery::VISIBILITY_PUBLIC, :user_id => 1, :filters => {},
1365 1365 :sort_criteria => [["cf_#{cf.id}", 'asc'], ['id', 'asc']])
1366 1366 @request.session[:query] = {:id => query.id, :project_id => nil}
1367 1367
1368 1368 get :show, :id => 3
1369 1369 assert_response :success
1370 1370
1371 1371 assert_equal 2, assigns(:prev_issue_id)
1372 1372 assert_equal 1, assigns(:next_issue_id)
1373 1373
1374 1374 assert_select 'div.next-prev-links' do
1375 1375 assert_select 'a[href="/issues/2"]', :text => /Previous/
1376 1376 assert_select 'a[href="/issues/1"]', :text => /Next/
1377 1377 end
1378 1378 end
1379 1379
1380 1380 def test_show_should_display_category_field_if_categories_are_defined
1381 1381 Issue.update_all :category_id => nil
1382 1382
1383 1383 get :show, :id => 1
1384 1384 assert_response :success
1385 assert_select 'table.attributes .category'
1385 assert_select '.attributes .category'
1386 1386 end
1387 1387
1388 1388 def test_show_should_not_display_category_field_if_no_categories_are_defined
1389 1389 Project.find(1).issue_categories.delete_all
1390 1390
1391 1391 get :show, :id => 1
1392 1392 assert_response :success
1393 1393 assert_select 'table.attributes .category', 0
1394 1394 end
1395 1395
1396 1396 def test_show_should_display_link_to_the_assignee
1397 1397 get :show, :id => 2
1398 1398 assert_response :success
1399 1399 assert_select '.assigned-to' do
1400 1400 assert_select 'a[href="/users/3"]'
1401 1401 end
1402 1402 end
1403 1403
1404 1404 def test_show_should_display_visible_changesets_from_other_projects
1405 1405 project = Project.find(2)
1406 1406 issue = project.issues.first
1407 1407 issue.changeset_ids = [102]
1408 1408 issue.save!
1409 1409 # changesets from other projects should be displayed even if repository
1410 1410 # is disabled on issue's project
1411 1411 project.disable_module! :repository
1412 1412
1413 1413 @request.session[:user_id] = 2
1414 1414 get :show, :id => issue.id
1415 1415
1416 1416 assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/3'
1417 1417 end
1418 1418
1419 1419 def test_show_should_display_watchers
1420 1420 @request.session[:user_id] = 2
1421 1421 Issue.find(1).add_watcher User.find(2)
1422 1422
1423 1423 get :show, :id => 1
1424 1424 assert_select 'div#watchers ul' do
1425 1425 assert_select 'li' do
1426 1426 assert_select 'a[href="/users/2"]'
1427 1427 assert_select 'a img[alt=Delete]'
1428 1428 end
1429 1429 end
1430 1430 end
1431 1431
1432 1432 def test_show_should_display_watchers_with_gravatars
1433 1433 @request.session[:user_id] = 2
1434 1434 Issue.find(1).add_watcher User.find(2)
1435 1435
1436 1436 with_settings :gravatar_enabled => '1' do
1437 1437 get :show, :id => 1
1438 1438 end
1439 1439
1440 1440 assert_select 'div#watchers ul' do
1441 1441 assert_select 'li' do
1442 1442 assert_select 'img.gravatar'
1443 1443 assert_select 'a[href="/users/2"]'
1444 1444 assert_select 'a img[alt=Delete]'
1445 1445 end
1446 1446 end
1447 1447 end
1448 1448
1449 1449 def test_show_with_thumbnails_enabled_should_display_thumbnails
1450 1450 @request.session[:user_id] = 2
1451 1451
1452 1452 with_settings :thumbnails_enabled => '1' do
1453 1453 get :show, :id => 14
1454 1454 assert_response :success
1455 1455 end
1456 1456
1457 1457 assert_select 'div.thumbnails' do
1458 1458 assert_select 'a[href="/attachments/16/testfile.png"]' do
1459 1459 assert_select 'img[src="/attachments/thumbnail/16"]'
1460 1460 end
1461 1461 end
1462 1462 end
1463 1463
1464 1464 def test_show_with_thumbnails_disabled_should_not_display_thumbnails
1465 1465 @request.session[:user_id] = 2
1466 1466
1467 1467 with_settings :thumbnails_enabled => '0' do
1468 1468 get :show, :id => 14
1469 1469 assert_response :success
1470 1470 end
1471 1471
1472 1472 assert_select 'div.thumbnails', 0
1473 1473 end
1474 1474
1475 1475 def test_show_with_multi_custom_field
1476 1476 field = CustomField.find(1)
1477 1477 field.update_attribute :multiple, true
1478 1478 issue = Issue.find(1)
1479 1479 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
1480 1480 issue.save!
1481 1481
1482 1482 get :show, :id => 1
1483 1483 assert_response :success
1484 1484
1485 assert_select 'td', :text => 'MySQL, Oracle'
1485 assert_select ".cf_1 .value", :text => 'MySQL, Oracle'
1486 1486 end
1487 1487
1488 1488 def test_show_with_multi_user_custom_field
1489 1489 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1490 1490 :tracker_ids => [1], :is_for_all => true)
1491 1491 issue = Issue.find(1)
1492 1492 issue.custom_field_values = {field.id => ['2', '3']}
1493 1493 issue.save!
1494 1494
1495 1495 get :show, :id => 1
1496 1496 assert_response :success
1497 1497
1498 assert_select "td.cf_#{field.id}", :text => 'Dave Lopper, John Smith' do
1498 assert_select ".cf_#{field.id} .value", :text => 'Dave Lopper, John Smith' do
1499 1499 assert_select 'a', :text => 'Dave Lopper'
1500 1500 assert_select 'a', :text => 'John Smith'
1501 1501 end
1502 1502 end
1503 1503
1504 1504 def test_show_should_display_private_notes_with_permission_only
1505 1505 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
1506 1506 @request.session[:user_id] = 2
1507 1507
1508 1508 get :show, :id => 2
1509 1509 assert_response :success
1510 1510 assert_include journal, assigns(:journals)
1511 1511
1512 1512 Role.find(1).remove_permission! :view_private_notes
1513 1513 get :show, :id => 2
1514 1514 assert_response :success
1515 1515 assert_not_include journal, assigns(:journals)
1516 1516 end
1517 1517
1518 1518 def test_show_atom
1519 1519 get :show, :id => 2, :format => 'atom'
1520 1520 assert_response :success
1521 1521 assert_template 'journals/index'
1522 1522 # Inline image
1523 1523 assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
1524 1524 end
1525 1525
1526 1526 def test_show_export_to_pdf
1527 1527 issue = Issue.find(3)
1528 1528 assert issue.relations.select{|r| r.other_issue(issue).visible?}.present?
1529 1529 get :show, :id => 3, :format => 'pdf'
1530 1530 assert_response :success
1531 1531 assert_equal 'application/pdf', @response.content_type
1532 1532 assert @response.body.starts_with?('%PDF')
1533 1533 assert_not_nil assigns(:issue)
1534 1534 end
1535 1535
1536 1536 def test_export_to_pdf_with_utf8_u_fffd
1537 1537 # U+FFFD
1538 1538 s = "\xef\xbf\xbd"
1539 1539 s.force_encoding('UTF-8') if s.respond_to?(:force_encoding)
1540 1540 issue = Issue.generate!(:subject => s)
1541 1541 ["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
1542 1542 with_settings :default_language => lang do
1543 1543 get :show, :id => issue.id, :format => 'pdf'
1544 1544 assert_response :success
1545 1545 assert_equal 'application/pdf', @response.content_type
1546 1546 assert @response.body.starts_with?('%PDF')
1547 1547 assert_not_nil assigns(:issue)
1548 1548 end
1549 1549 end
1550 1550 end
1551 1551
1552 1552 def test_show_export_to_pdf_with_ancestors
1553 1553 issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1554 1554
1555 1555 get :show, :id => issue.id, :format => 'pdf'
1556 1556 assert_response :success
1557 1557 assert_equal 'application/pdf', @response.content_type
1558 1558 assert @response.body.starts_with?('%PDF')
1559 1559 end
1560 1560
1561 1561 def test_show_export_to_pdf_with_descendants
1562 1562 c1 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1563 1563 c2 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1)
1564 1564 c3 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => c1.id)
1565 1565
1566 1566 get :show, :id => 1, :format => 'pdf'
1567 1567 assert_response :success
1568 1568 assert_equal 'application/pdf', @response.content_type
1569 1569 assert @response.body.starts_with?('%PDF')
1570 1570 end
1571 1571
1572 1572 def test_show_export_to_pdf_with_journals
1573 1573 get :show, :id => 1, :format => 'pdf'
1574 1574 assert_response :success
1575 1575 assert_equal 'application/pdf', @response.content_type
1576 1576 assert @response.body.starts_with?('%PDF')
1577 1577 end
1578 1578
1579 1579 def test_show_export_to_pdf_with_changesets
1580 1580 [[100], [100, 101], [100, 101, 102]].each do |cs|
1581 1581 issue1 = Issue.find(3)
1582 1582 issue1.changesets = Changeset.find(cs)
1583 1583 issue1.save!
1584 1584 issue = Issue.find(3)
1585 1585 assert_equal issue.changesets.count, cs.size
1586 1586 get :show, :id => 3, :format => 'pdf'
1587 1587 assert_response :success
1588 1588 assert_equal 'application/pdf', @response.content_type
1589 1589 assert @response.body.starts_with?('%PDF')
1590 1590 end
1591 1591 end
1592 1592
1593 1593 def test_show_invalid_should_respond_with_404
1594 1594 get :show, :id => 999
1595 1595 assert_response 404
1596 1596 end
1597 1597
1598 1598 def test_get_new
1599 1599 @request.session[:user_id] = 2
1600 1600 get :new, :project_id => 1, :tracker_id => 1
1601 1601 assert_response :success
1602 1602 assert_template 'new'
1603 1603
1604 1604 assert_select 'form#issue-form[action=?]', '/projects/ecookbook/issues'
1605 1605 assert_select 'form#issue-form' do
1606 1606 assert_select 'input[name=?]', 'issue[is_private]'
1607 1607 assert_select 'select[name=?]', 'issue[project_id]', 0
1608 1608 assert_select 'select[name=?]', 'issue[tracker_id]'
1609 1609 assert_select 'input[name=?]', 'issue[subject]'
1610 1610 assert_select 'textarea[name=?]', 'issue[description]'
1611 1611 assert_select 'select[name=?]', 'issue[status_id]'
1612 1612 assert_select 'select[name=?]', 'issue[priority_id]'
1613 1613 assert_select 'select[name=?]', 'issue[assigned_to_id]'
1614 1614 assert_select 'select[name=?]', 'issue[category_id]'
1615 1615 assert_select 'select[name=?]', 'issue[fixed_version_id]'
1616 1616 assert_select 'input[name=?]', 'issue[parent_issue_id]'
1617 1617 assert_select 'input[name=?]', 'issue[start_date]'
1618 1618 assert_select 'input[name=?]', 'issue[due_date]'
1619 1619 assert_select 'select[name=?]', 'issue[done_ratio]'
1620 1620 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', 'Default string'
1621 1621 assert_select 'input[name=?]', 'issue[watcher_user_ids][]'
1622 1622 end
1623 1623
1624 1624 # Be sure we don't display inactive IssuePriorities
1625 1625 assert ! IssuePriority.find(15).active?
1626 1626 assert_select 'select[name=?]', 'issue[priority_id]' do
1627 1627 assert_select 'option[value="15"]', 0
1628 1628 end
1629 1629 end
1630 1630
1631 1631 def test_get_new_with_minimal_permissions
1632 1632 Role.find(1).update_attribute :permissions, [:add_issues]
1633 1633 WorkflowTransition.delete_all :role_id => 1
1634 1634
1635 1635 @request.session[:user_id] = 2
1636 1636 get :new, :project_id => 1, :tracker_id => 1
1637 1637 assert_response :success
1638 1638 assert_template 'new'
1639 1639
1640 1640 assert_select 'form#issue-form' do
1641 1641 assert_select 'input[name=?]', 'issue[is_private]', 0
1642 1642 assert_select 'select[name=?]', 'issue[project_id]', 0
1643 1643 assert_select 'select[name=?]', 'issue[tracker_id]'
1644 1644 assert_select 'input[name=?]', 'issue[subject]'
1645 1645 assert_select 'textarea[name=?]', 'issue[description]'
1646 1646 assert_select 'select[name=?]', 'issue[status_id]'
1647 1647 assert_select 'select[name=?]', 'issue[priority_id]'
1648 1648 assert_select 'select[name=?]', 'issue[assigned_to_id]'
1649 1649 assert_select 'select[name=?]', 'issue[category_id]'
1650 1650 assert_select 'select[name=?]', 'issue[fixed_version_id]'
1651 1651 assert_select 'input[name=?]', 'issue[parent_issue_id]', 0
1652 1652 assert_select 'input[name=?]', 'issue[start_date]'
1653 1653 assert_select 'input[name=?]', 'issue[due_date]'
1654 1654 assert_select 'select[name=?]', 'issue[done_ratio]'
1655 1655 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', 'Default string'
1656 1656 assert_select 'input[name=?]', 'issue[watcher_user_ids][]', 0
1657 1657 end
1658 1658 end
1659 1659
1660 1660 def test_new_without_project_id
1661 1661 @request.session[:user_id] = 2
1662 1662 get :new
1663 1663 assert_response :success
1664 1664 assert_template 'new'
1665 1665
1666 1666 assert_select 'form#issue-form[action=?]', '/issues'
1667 1667 assert_select 'form#issue-form' do
1668 1668 assert_select 'select[name=?]', 'issue[project_id]'
1669 1669 end
1670 1670
1671 1671 assert_nil assigns(:project)
1672 1672 assert_not_nil assigns(:issue)
1673 1673 end
1674 1674
1675 1675 def test_new_should_select_default_status
1676 1676 @request.session[:user_id] = 2
1677 1677
1678 1678 get :new, :project_id => 1
1679 1679 assert_response :success
1680 1680 assert_template 'new'
1681 1681 assert_select 'select[name=?]', 'issue[status_id]' do
1682 1682 assert_select 'option[value="1"][selected=selected]'
1683 1683 end
1684 1684 assert_select 'input[name=was_default_status][value="1"]'
1685 1685 end
1686 1686
1687 1687 def test_new_should_propose_allowed_statuses
1688 1688 WorkflowTransition.delete_all
1689 1689 WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 1)
1690 1690 WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 3)
1691 1691 @request.session[:user_id] = 2
1692 1692
1693 1693 get :new, :project_id => 1
1694 1694 assert_response :success
1695 1695 assert_select 'select[name=?]', 'issue[status_id]' do
1696 1696 assert_select 'option[value="1"]'
1697 1697 assert_select 'option[value="3"]'
1698 1698 assert_select 'option', 2
1699 1699 assert_select 'option[value="1"][selected=selected]'
1700 1700 end
1701 1701 end
1702 1702
1703 1703 def test_new_should_propose_allowed_statuses_without_default_status_allowed
1704 1704 WorkflowTransition.delete_all
1705 1705 WorkflowTransition.create!(:tracker_id => 1, :role_id => 1, :old_status_id => 0, :new_status_id => 2)
1706 1706 assert_equal 1, Tracker.find(1).default_status_id
1707 1707 @request.session[:user_id] = 2
1708 1708
1709 1709 get :new, :project_id => 1
1710 1710 assert_response :success
1711 1711 assert_select 'select[name=?]', 'issue[status_id]' do
1712 1712 assert_select 'option[value="2"]'
1713 1713 assert_select 'option', 1
1714 1714 assert_select 'option[value="2"][selected=selected]'
1715 1715 end
1716 1716 end
1717 1717
1718 1718 def test_new_should_preselect_default_version
1719 1719 version = Version.generate!(:project_id => 1)
1720 1720 Project.find(1).update_attribute :default_version_id, version.id
1721 1721 @request.session[:user_id] = 2
1722 1722
1723 1723 get :new, :project_id => 1
1724 1724 assert_response :success
1725 1725 assert_equal version, assigns(:issue).fixed_version
1726 1726 assert_select 'select[name=?]', 'issue[fixed_version_id]' do
1727 1727 assert_select 'option[value=?][selected=selected]', version.id.to_s
1728 1728 end
1729 1729 end
1730 1730
1731 1731 def test_get_new_with_list_custom_field
1732 1732 @request.session[:user_id] = 2
1733 1733 get :new, :project_id => 1, :tracker_id => 1
1734 1734 assert_response :success
1735 1735 assert_template 'new'
1736 1736
1737 1737 assert_select 'select.list_cf[name=?]', 'issue[custom_field_values][1]' do
1738 1738 assert_select 'option', 4
1739 1739 assert_select 'option[value=MySQL]', :text => 'MySQL'
1740 1740 end
1741 1741 end
1742 1742
1743 1743 def test_get_new_with_multi_custom_field
1744 1744 field = IssueCustomField.find(1)
1745 1745 field.update_attribute :multiple, true
1746 1746
1747 1747 @request.session[:user_id] = 2
1748 1748 get :new, :project_id => 1, :tracker_id => 1
1749 1749 assert_response :success
1750 1750 assert_template 'new'
1751 1751
1752 1752 assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do
1753 1753 assert_select 'option', 3
1754 1754 assert_select 'option[value=MySQL]', :text => 'MySQL'
1755 1755 end
1756 1756 assert_select 'input[name=?][type=hidden][value=?]', 'issue[custom_field_values][1][]', ''
1757 1757 end
1758 1758
1759 1759 def test_get_new_with_multi_user_custom_field
1760 1760 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
1761 1761 :tracker_ids => [1], :is_for_all => true)
1762 1762
1763 1763 @request.session[:user_id] = 2
1764 1764 get :new, :project_id => 1, :tracker_id => 1
1765 1765 assert_response :success
1766 1766 assert_template 'new'
1767 1767
1768 1768 assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do
1769 1769 assert_select 'option', Project.find(1).users.count
1770 1770 assert_select 'option[value="2"]', :text => 'John Smith'
1771 1771 end
1772 1772 assert_select 'input[name=?][type=hidden][value=?]', "issue[custom_field_values][#{field.id}][]", ''
1773 1773 end
1774 1774
1775 1775 def test_get_new_with_date_custom_field
1776 1776 field = IssueCustomField.create!(:name => 'Date', :field_format => 'date', :tracker_ids => [1], :is_for_all => true)
1777 1777
1778 1778 @request.session[:user_id] = 2
1779 1779 get :new, :project_id => 1, :tracker_id => 1
1780 1780 assert_response :success
1781 1781
1782 1782 assert_select 'input[name=?]', "issue[custom_field_values][#{field.id}]"
1783 1783 end
1784 1784
1785 1785 def test_get_new_with_text_custom_field
1786 1786 field = IssueCustomField.create!(:name => 'Text', :field_format => 'text', :tracker_ids => [1], :is_for_all => true)
1787 1787
1788 1788 @request.session[:user_id] = 2
1789 1789 get :new, :project_id => 1, :tracker_id => 1
1790 1790 assert_response :success
1791 1791
1792 1792 assert_select 'textarea[name=?]', "issue[custom_field_values][#{field.id}]"
1793 1793 end
1794 1794
1795 1795 def test_get_new_without_default_start_date_is_creation_date
1796 1796 with_settings :default_issue_start_date_to_creation_date => 0 do
1797 1797 @request.session[:user_id] = 2
1798 1798 get :new, :project_id => 1, :tracker_id => 1
1799 1799 assert_response :success
1800 1800 assert_template 'new'
1801 1801 assert_select 'input[name=?]', 'issue[start_date]'
1802 1802 assert_select 'input[name=?][value]', 'issue[start_date]', 0
1803 1803 end
1804 1804 end
1805 1805
1806 1806 def test_get_new_with_default_start_date_is_creation_date
1807 1807 with_settings :default_issue_start_date_to_creation_date => 1 do
1808 1808 @request.session[:user_id] = 2
1809 1809 get :new, :project_id => 1, :tracker_id => 1
1810 1810 assert_response :success
1811 1811 assert_template 'new'
1812 1812 assert_select 'input[name=?][value=?]', 'issue[start_date]',
1813 1813 Date.today.to_s
1814 1814 end
1815 1815 end
1816 1816
1817 1817 def test_get_new_form_should_allow_attachment_upload
1818 1818 @request.session[:user_id] = 2
1819 1819 get :new, :project_id => 1, :tracker_id => 1
1820 1820
1821 1821 assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do
1822 1822 assert_select 'input[name=?][type=file]', 'attachments[dummy][file]'
1823 1823 end
1824 1824 end
1825 1825
1826 1826 def test_get_new_should_prefill_the_form_from_params
1827 1827 @request.session[:user_id] = 2
1828 1828 get :new, :project_id => 1,
1829 1829 :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}}
1830 1830
1831 1831 issue = assigns(:issue)
1832 1832 assert_equal 3, issue.tracker_id
1833 1833 assert_equal 'Prefilled', issue.description
1834 1834 assert_equal 'Custom field value', issue.custom_field_value(2)
1835 1835
1836 1836 assert_select 'select[name=?]', 'issue[tracker_id]' do
1837 1837 assert_select 'option[value="3"][selected=selected]'
1838 1838 end
1839 1839 assert_select 'textarea[name=?]', 'issue[description]', :text => /Prefilled/
1840 1840 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', 'Custom field value'
1841 1841 end
1842 1842
1843 1843 def test_get_new_should_mark_required_fields
1844 1844 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1845 1845 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1846 1846 WorkflowPermission.delete_all
1847 1847 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
1848 1848 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
1849 1849 @request.session[:user_id] = 2
1850 1850
1851 1851 get :new, :project_id => 1
1852 1852 assert_response :success
1853 1853 assert_template 'new'
1854 1854
1855 1855 assert_select 'label[for=issue_start_date]' do
1856 1856 assert_select 'span[class=required]', 0
1857 1857 end
1858 1858 assert_select 'label[for=issue_due_date]' do
1859 1859 assert_select 'span[class=required]'
1860 1860 end
1861 1861 assert_select 'label[for=?]', "issue_custom_field_values_#{cf1.id}" do
1862 1862 assert_select 'span[class=required]', 0
1863 1863 end
1864 1864 assert_select 'label[for=?]', "issue_custom_field_values_#{cf2.id}" do
1865 1865 assert_select 'span[class=required]'
1866 1866 end
1867 1867 end
1868 1868
1869 1869 def test_get_new_should_not_display_readonly_fields
1870 1870 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1871 1871 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
1872 1872 WorkflowPermission.delete_all
1873 1873 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
1874 1874 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
1875 1875 @request.session[:user_id] = 2
1876 1876
1877 1877 get :new, :project_id => 1
1878 1878 assert_response :success
1879 1879 assert_template 'new'
1880 1880
1881 1881 assert_select 'input[name=?]', 'issue[start_date]'
1882 1882 assert_select 'input[name=?]', 'issue[due_date]', 0
1883 1883 assert_select 'input[name=?]', "issue[custom_field_values][#{cf1.id}]"
1884 1884 assert_select 'input[name=?]', "issue[custom_field_values][#{cf2.id}]", 0
1885 1885 end
1886 1886
1887 1887 def test_new_with_tracker_set_as_readonly_should_accept_status
1888 1888 WorkflowPermission.delete_all
1889 1889 [1, 2].each do |status_id|
1890 1890 WorkflowPermission.create!(:tracker_id => 1, :old_status_id => status_id, :role_id => 1, :field_name => 'tracker_id', :rule => 'readonly')
1891 1891 end
1892 1892 @request.session[:user_id] = 2
1893 1893
1894 1894 get :new, :project_id => 1, :issue => {:status_id => 2}
1895 1895 assert_select 'select[name=?]', 'issue[tracker_id]', 0
1896 1896 assert_equal 2, assigns(:issue).status_id
1897 1897 end
1898 1898
1899 1899 def test_get_new_without_tracker_id
1900 1900 @request.session[:user_id] = 2
1901 1901 get :new, :project_id => 1
1902 1902 assert_response :success
1903 1903 assert_template 'new'
1904 1904
1905 1905 issue = assigns(:issue)
1906 1906 assert_not_nil issue
1907 1907 assert_equal Project.find(1).trackers.first, issue.tracker
1908 1908 end
1909 1909
1910 1910 def test_get_new_with_no_default_status_should_display_an_error
1911 1911 @request.session[:user_id] = 2
1912 1912 IssueStatus.delete_all
1913 1913
1914 1914 get :new, :project_id => 1
1915 1915 assert_response 500
1916 1916 assert_select_error /No default issue/
1917 1917 end
1918 1918
1919 1919 def test_get_new_with_no_tracker_should_display_an_error
1920 1920 @request.session[:user_id] = 2
1921 1921 Tracker.delete_all
1922 1922
1923 1923 get :new, :project_id => 1
1924 1924 assert_response 500
1925 1925 assert_select_error /No tracker/
1926 1926 end
1927 1927
1928 1928 def test_new_with_invalid_project_id
1929 1929 @request.session[:user_id] = 1
1930 1930 get :new, :project_id => 'invalid'
1931 1931 assert_response 404
1932 1932 end
1933 1933
1934 1934 def test_update_form_for_new_issue
1935 1935 @request.session[:user_id] = 2
1936 1936 xhr :post, :new, :project_id => 1,
1937 1937 :issue => {:tracker_id => 2,
1938 1938 :subject => 'This is the test_new issue',
1939 1939 :description => 'This is the description',
1940 1940 :priority_id => 5}
1941 1941 assert_response :success
1942 1942 assert_template 'new'
1943 1943 assert_template :partial => '_form'
1944 1944 assert_equal 'text/javascript', response.content_type
1945 1945
1946 1946 issue = assigns(:issue)
1947 1947 assert_kind_of Issue, issue
1948 1948 assert_equal 1, issue.project_id
1949 1949 assert_equal 2, issue.tracker_id
1950 1950 assert_equal 'This is the test_new issue', issue.subject
1951 1951 end
1952 1952
1953 1953 def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status
1954 1954 @request.session[:user_id] = 2
1955 1955 WorkflowTransition.delete_all
1956 1956 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 2)
1957 1957 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 5)
1958 1958 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
1959 1959
1960 1960 xhr :post, :new, :project_id => 1,
1961 1961 :issue => {:tracker_id => 1,
1962 1962 :status_id => 5,
1963 1963 :subject => 'This is an issue'}
1964 1964
1965 1965 assert_equal 5, assigns(:issue).status_id
1966 1966 assert_equal [2,5], assigns(:allowed_statuses).map(&:id).sort
1967 1967 end
1968 1968
1969 1969 def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals
1970 1970 @request.session[:user_id] = 2
1971 1971 tracker = Tracker.find(2)
1972 1972 tracker.update! :default_status_id => 2
1973 1973 tracker.generate_transitions! 2, 1, :clear => true
1974 1974
1975 1975 xhr :post, :new, :project_id => 1,
1976 1976 :issue => {:tracker_id => 2,
1977 1977 :status_id => 1},
1978 1978 :was_default_status => 1
1979 1979
1980 1980 assert_equal 2, assigns(:issue).status_id
1981 1981 end
1982 1982
1983 1983 def test_update_form_for_new_issue_should_ignore_version_when_changing_project
1984 1984 version = Version.generate!(:project_id => 1)
1985 1985 Project.find(1).update_attribute :default_version_id, version.id
1986 1986 @request.session[:user_id] = 2
1987 1987
1988 1988 xhr :post, :new, :issue => {:project_id => 1,
1989 1989 :fixed_version_id => ''},
1990 1990 :form_update_triggered_by => 'issue_project_id'
1991 1991 assert_response :success
1992 1992 assert_template 'new'
1993 1993
1994 1994 issue = assigns(:issue)
1995 1995 assert_equal 1, issue.project_id
1996 1996 assert_equal version, issue.fixed_version
1997 1997 end
1998 1998
1999 1999 def test_post_create
2000 2000 @request.session[:user_id] = 2
2001 2001 assert_difference 'Issue.count' do
2002 2002 assert_no_difference 'Journal.count' do
2003 2003 post :create, :project_id => 1,
2004 2004 :issue => {:tracker_id => 3,
2005 2005 :status_id => 2,
2006 2006 :subject => 'This is the test_new issue',
2007 2007 :description => 'This is the description',
2008 2008 :priority_id => 5,
2009 2009 :start_date => '2010-11-07',
2010 2010 :estimated_hours => '',
2011 2011 :custom_field_values => {'2' => 'Value for field 2'}}
2012 2012 end
2013 2013 end
2014 2014 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
2015 2015
2016 2016 issue = Issue.find_by_subject('This is the test_new issue')
2017 2017 assert_not_nil issue
2018 2018 assert_equal 2, issue.author_id
2019 2019 assert_equal 3, issue.tracker_id
2020 2020 assert_equal 2, issue.status_id
2021 2021 assert_equal Date.parse('2010-11-07'), issue.start_date
2022 2022 assert_nil issue.estimated_hours
2023 2023 v = issue.custom_values.where(:custom_field_id => 2).first
2024 2024 assert_not_nil v
2025 2025 assert_equal 'Value for field 2', v.value
2026 2026 end
2027 2027
2028 2028 def test_post_new_with_group_assignment
2029 2029 group = Group.find(11)
2030 2030 project = Project.find(1)
2031 2031 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
2032 2032
2033 2033 with_settings :issue_group_assignment => '1' do
2034 2034 @request.session[:user_id] = 2
2035 2035 assert_difference 'Issue.count' do
2036 2036 post :create, :project_id => project.id,
2037 2037 :issue => {:tracker_id => 3,
2038 2038 :status_id => 1,
2039 2039 :subject => 'This is the test_new_with_group_assignment issue',
2040 2040 :assigned_to_id => group.id}
2041 2041 end
2042 2042 end
2043 2043 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
2044 2044
2045 2045 issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
2046 2046 assert_not_nil issue
2047 2047 assert_equal group, issue.assigned_to
2048 2048 end
2049 2049
2050 2050 def test_post_create_without_start_date_and_default_start_date_is_not_creation_date
2051 2051 with_settings :default_issue_start_date_to_creation_date => 0 do
2052 2052 @request.session[:user_id] = 2
2053 2053 assert_difference 'Issue.count' do
2054 2054 post :create, :project_id => 1,
2055 2055 :issue => {:tracker_id => 3,
2056 2056 :status_id => 2,
2057 2057 :subject => 'This is the test_new issue',
2058 2058 :description => 'This is the description',
2059 2059 :priority_id => 5,
2060 2060 :estimated_hours => '',
2061 2061 :custom_field_values => {'2' => 'Value for field 2'}}
2062 2062 end
2063 2063 assert_redirected_to :controller => 'issues', :action => 'show',
2064 2064 :id => Issue.last.id
2065 2065 issue = Issue.find_by_subject('This is the test_new issue')
2066 2066 assert_not_nil issue
2067 2067 assert_nil issue.start_date
2068 2068 end
2069 2069 end
2070 2070
2071 2071 def test_post_create_without_start_date_and_default_start_date_is_creation_date
2072 2072 with_settings :default_issue_start_date_to_creation_date => 1 do
2073 2073 @request.session[:user_id] = 2
2074 2074 assert_difference 'Issue.count' do
2075 2075 post :create, :project_id => 1,
2076 2076 :issue => {:tracker_id => 3,
2077 2077 :status_id => 2,
2078 2078 :subject => 'This is the test_new issue',
2079 2079 :description => 'This is the description',
2080 2080 :priority_id => 5,
2081 2081 :estimated_hours => '',
2082 2082 :custom_field_values => {'2' => 'Value for field 2'}}
2083 2083 end
2084 2084 assert_redirected_to :controller => 'issues', :action => 'show',
2085 2085 :id => Issue.last.id
2086 2086 issue = Issue.find_by_subject('This is the test_new issue')
2087 2087 assert_not_nil issue
2088 2088 assert_equal Date.today, issue.start_date
2089 2089 end
2090 2090 end
2091 2091
2092 2092 def test_post_create_and_continue
2093 2093 @request.session[:user_id] = 2
2094 2094 assert_difference 'Issue.count' do
2095 2095 post :create, :project_id => 1,
2096 2096 :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5},
2097 2097 :continue => ''
2098 2098 end
2099 2099
2100 2100 issue = Issue.order('id DESC').first
2101 2101 assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3}
2102 2102 assert_not_nil flash[:notice], "flash was not set"
2103 2103 assert_select_in flash[:notice],
2104 2104 'a[href=?][title=?]', "/issues/#{issue.id}", "This is first issue", :text => "##{issue.id}"
2105 2105 end
2106 2106
2107 2107 def test_post_create_without_custom_fields_param
2108 2108 @request.session[:user_id] = 2
2109 2109 assert_difference 'Issue.count' do
2110 2110 post :create, :project_id => 1,
2111 2111 :issue => {:tracker_id => 1,
2112 2112 :subject => 'This is the test_new issue',
2113 2113 :description => 'This is the description',
2114 2114 :priority_id => 5}
2115 2115 end
2116 2116 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
2117 2117 end
2118 2118
2119 2119 def test_post_create_with_multi_custom_field
2120 2120 field = IssueCustomField.find_by_name('Database')
2121 2121 field.update_attribute(:multiple, true)
2122 2122
2123 2123 @request.session[:user_id] = 2
2124 2124 assert_difference 'Issue.count' do
2125 2125 post :create, :project_id => 1,
2126 2126 :issue => {:tracker_id => 1,
2127 2127 :subject => 'This is the test_new issue',
2128 2128 :description => 'This is the description',
2129 2129 :priority_id => 5,
2130 2130 :custom_field_values => {'1' => ['', 'MySQL', 'Oracle']}}
2131 2131 end
2132 2132 assert_response 302
2133 2133 issue = Issue.order('id DESC').first
2134 2134 assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort
2135 2135 end
2136 2136
2137 2137 def test_post_create_with_empty_multi_custom_field
2138 2138 field = IssueCustomField.find_by_name('Database')
2139 2139 field.update_attribute(:multiple, true)
2140 2140
2141 2141 @request.session[:user_id] = 2
2142 2142 assert_difference 'Issue.count' do
2143 2143 post :create, :project_id => 1,
2144 2144 :issue => {:tracker_id => 1,
2145 2145 :subject => 'This is the test_new issue',
2146 2146 :description => 'This is the description',
2147 2147 :priority_id => 5,
2148 2148 :custom_field_values => {'1' => ['']}}
2149 2149 end
2150 2150 assert_response 302
2151 2151 issue = Issue.order('id DESC').first
2152 2152 assert_equal [''], issue.custom_field_value(1).sort
2153 2153 end
2154 2154
2155 2155 def test_post_create_with_multi_user_custom_field
2156 2156 field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
2157 2157 :tracker_ids => [1], :is_for_all => true)
2158 2158
2159 2159 @request.session[:user_id] = 2
2160 2160 assert_difference 'Issue.count' do
2161 2161 post :create, :project_id => 1,
2162 2162 :issue => {:tracker_id => 1,
2163 2163 :subject => 'This is the test_new issue',
2164 2164 :description => 'This is the description',
2165 2165 :priority_id => 5,
2166 2166 :custom_field_values => {field.id.to_s => ['', '2', '3']}}
2167 2167 end
2168 2168 assert_response 302
2169 2169 issue = Issue.order('id DESC').first
2170 2170 assert_equal ['2', '3'], issue.custom_field_value(field).sort
2171 2171 end
2172 2172
2173 2173 def test_post_create_with_required_custom_field_and_without_custom_fields_param
2174 2174 field = IssueCustomField.find_by_name('Database')
2175 2175 field.update_attribute(:is_required, true)
2176 2176
2177 2177 @request.session[:user_id] = 2
2178 2178 assert_no_difference 'Issue.count' do
2179 2179 post :create, :project_id => 1,
2180 2180 :issue => {:tracker_id => 1,
2181 2181 :subject => 'This is the test_new issue',
2182 2182 :description => 'This is the description',
2183 2183 :priority_id => 5}
2184 2184 end
2185 2185 assert_response :success
2186 2186 assert_template 'new'
2187 2187 issue = assigns(:issue)
2188 2188 assert_not_nil issue
2189 2189 assert_select_error /Database cannot be blank/
2190 2190 end
2191 2191
2192 2192 def test_create_should_validate_required_fields
2193 2193 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2194 2194 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2195 2195 WorkflowPermission.delete_all
2196 2196 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'required')
2197 2197 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
2198 2198 @request.session[:user_id] = 2
2199 2199
2200 2200 assert_no_difference 'Issue.count' do
2201 2201 post :create, :project_id => 1, :issue => {
2202 2202 :tracker_id => 2,
2203 2203 :status_id => 1,
2204 2204 :subject => 'Test',
2205 2205 :start_date => '',
2206 2206 :due_date => '',
2207 2207 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
2208 2208 }
2209 2209 assert_response :success
2210 2210 assert_template 'new'
2211 2211 end
2212 2212
2213 2213 assert_select_error /Due date cannot be blank/i
2214 2214 assert_select_error /Bar cannot be blank/i
2215 2215 end
2216 2216
2217 2217 def test_create_should_validate_required_list_fields
2218 2218 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => false, :possible_values => ['a', 'b'])
2219 2219 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'list', :is_for_all => true, :tracker_ids => [1, 2], :multiple => true, :possible_values => ['a', 'b'])
2220 2220 WorkflowPermission.delete_all
2221 2221 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf1.id.to_s, :rule => 'required')
2222 2222 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
2223 2223 @request.session[:user_id] = 2
2224 2224
2225 2225 assert_no_difference 'Issue.count' do
2226 2226 post :create, :project_id => 1, :issue => {
2227 2227 :tracker_id => 2,
2228 2228 :status_id => 1,
2229 2229 :subject => 'Test',
2230 2230 :start_date => '',
2231 2231 :due_date => '',
2232 2232 :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']}
2233 2233 }
2234 2234 assert_response :success
2235 2235 assert_template 'new'
2236 2236 end
2237 2237
2238 2238 assert_select_error /Foo cannot be blank/i
2239 2239 assert_select_error /Bar cannot be blank/i
2240 2240 end
2241 2241
2242 2242 def test_create_should_ignore_readonly_fields
2243 2243 cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2244 2244 cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
2245 2245 WorkflowPermission.delete_all
2246 2246 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
2247 2247 WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
2248 2248 @request.session[:user_id] = 2
2249 2249
2250 2250 assert_difference 'Issue.count' do
2251 2251 post :create, :project_id => 1, :issue => {
2252 2252 :tracker_id => 2,
2253 2253 :status_id => 1,
2254 2254 :subject => 'Test',
2255 2255 :start_date => '2012-07-14',
2256 2256 :due_date => '2012-07-16',
2257 2257 :custom_field_values => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}
2258 2258 }
2259 2259 assert_response 302
2260 2260 end
2261 2261
2262 2262 issue = Issue.order('id DESC').first
2263 2263 assert_equal Date.parse('2012-07-14'), issue.start_date
2264 2264 assert_nil issue.due_date
2265 2265 assert_equal 'value1', issue.custom_field_value(cf1)
2266 2266 assert_nil issue.custom_field_value(cf2)
2267 2267 end
2268 2268
2269 2269 def test_post_create_with_watchers
2270 2270 @request.session[:user_id] = 2
2271 2271 ActionMailer::Base.deliveries.clear
2272 2272
2273 2273 with_settings :notified_events => %w(issue_added) do
2274 2274 assert_difference 'Watcher.count', 2 do
2275 2275 post :create, :project_id => 1,
2276 2276 :issue => {:tracker_id => 1,
2277 2277 :subject => 'This is a new issue with watchers',
2278 2278 :description => 'This is the description',
2279 2279 :priority_id => 5,
2280 2280 :watcher_user_ids => ['2', '3']}
2281 2281 end
2282 2282 end
2283 2283 issue = Issue.find_by_subject('This is a new issue with watchers')
2284 2284 assert_not_nil issue
2285 2285 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
2286 2286
2287 2287 # Watchers added
2288 2288 assert_equal [2, 3], issue.watcher_user_ids.sort
2289 2289 assert issue.watched_by?(User.find(3))
2290 2290 # Watchers notified
2291 2291 mail = ActionMailer::Base.deliveries.last
2292 2292 assert_not_nil mail
2293 2293 assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
2294 2294 end
2295 2295
2296 2296 def test_post_create_subissue
2297 2297 @request.session[:user_id] = 2
2298 2298
2299 2299 assert_difference 'Issue.count' do
2300 2300 post :create, :project_id => 1,
2301 2301 :issue => {:tracker_id => 1,
2302 2302 :subject => 'This is a child issue',
2303 2303 :parent_issue_id => '2'}
2304 2304 assert_response 302
2305 2305 end
2306 2306 issue = Issue.order('id DESC').first
2307 2307 assert_equal Issue.find(2), issue.parent
2308 2308 end
2309 2309
2310 2310 def test_post_create_subissue_with_sharp_parent_id
2311 2311 @request.session[:user_id] = 2
2312 2312
2313 2313 assert_difference 'Issue.count' do
2314 2314 post :create, :project_id => 1,
2315 2315 :issue => {:tracker_id => 1,
2316 2316 :subject => 'This is a child issue',
2317 2317 :parent_issue_id => '#2'}
2318 2318 assert_response 302
2319 2319 end
2320 2320 issue = Issue.order('id DESC').first
2321 2321 assert_equal Issue.find(2), issue.parent
2322 2322 end
2323 2323
2324 2324 def test_post_create_subissue_with_non_visible_parent_id_should_not_validate
2325 2325 @request.session[:user_id] = 2
2326 2326
2327 2327 assert_no_difference 'Issue.count' do
2328 2328 post :create, :project_id => 1,
2329 2329 :issue => {:tracker_id => 1,
2330 2330 :subject => 'This is a child issue',
2331 2331 :parent_issue_id => '4'}
2332 2332
2333 2333 assert_response :success
2334 2334 assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '4'
2335 2335 assert_select_error /Parent task is invalid/i
2336 2336 end
2337 2337 end
2338 2338
2339 2339 def test_post_create_subissue_with_non_numeric_parent_id_should_not_validate
2340 2340 @request.session[:user_id] = 2
2341 2341
2342 2342 assert_no_difference 'Issue.count' do
2343 2343 post :create, :project_id => 1,
2344 2344 :issue => {:tracker_id => 1,
2345 2345 :subject => 'This is a child issue',
2346 2346 :parent_issue_id => '01ABC'}
2347 2347
2348 2348 assert_response :success
2349 2349 assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '01ABC'
2350 2350 assert_select_error /Parent task is invalid/i
2351 2351 end
2352 2352 end
2353 2353
2354 2354 def test_post_create_private
2355 2355 @request.session[:user_id] = 2
2356 2356
2357 2357 assert_difference 'Issue.count' do
2358 2358 post :create, :project_id => 1,
2359 2359 :issue => {:tracker_id => 1,
2360 2360 :subject => 'This is a private issue',
2361 2361 :is_private => '1'}
2362 2362 end
2363 2363 issue = Issue.order('id DESC').first
2364 2364 assert issue.is_private?
2365 2365 end
2366 2366
2367 2367 def test_post_create_private_with_set_own_issues_private_permission
2368 2368 role = Role.find(1)
2369 2369 role.remove_permission! :set_issues_private
2370 2370 role.add_permission! :set_own_issues_private
2371 2371
2372 2372 @request.session[:user_id] = 2
2373 2373
2374 2374 assert_difference 'Issue.count' do
2375 2375 post :create, :project_id => 1,
2376 2376 :issue => {:tracker_id => 1,
2377 2377 :subject => 'This is a private issue',
2378 2378 :is_private => '1'}
2379 2379 end
2380 2380 issue = Issue.order('id DESC').first
2381 2381 assert issue.is_private?
2382 2382 end
2383 2383
2384 2384 def test_create_without_project_id
2385 2385 @request.session[:user_id] = 2
2386 2386
2387 2387 assert_difference 'Issue.count' do
2388 2388 post :create,
2389 2389 :issue => {:project_id => 3,
2390 2390 :tracker_id => 2,
2391 2391 :subject => 'Foo'}
2392 2392 assert_response 302
2393 2393 end
2394 2394 issue = Issue.order('id DESC').first
2395 2395 assert_equal 3, issue.project_id
2396 2396 assert_equal 2, issue.tracker_id
2397 2397 end
2398 2398
2399 2399 def test_create_without_project_id_and_continue_should_redirect_without_project_id
2400 2400 @request.session[:user_id] = 2
2401 2401
2402 2402 assert_difference 'Issue.count' do
2403 2403 post :create,
2404 2404 :issue => {:project_id => 3,
2405 2405 :tracker_id => 2,
2406 2406 :subject => 'Foo'},
2407 2407 :continue => '1'
2408 2408 assert_redirected_to '/issues/new?issue%5Bproject_id%5D=3&issue%5Btracker_id%5D=2'
2409 2409 end
2410 2410 end
2411 2411
2412 2412 def test_create_without_project_id_should_be_denied_without_permission
2413 2413 Role.non_member.remove_permission! :add_issues
2414 2414 Role.anonymous.remove_permission! :add_issues
2415 2415 @request.session[:user_id] = 2
2416 2416
2417 2417 assert_no_difference 'Issue.count' do
2418 2418 post :create,
2419 2419 :issue => {:project_id => 3,
2420 2420 :tracker_id => 2,
2421 2421 :subject => 'Foo'}
2422 2422 assert_response 422
2423 2423 end
2424 2424 end
2425 2425
2426 2426 def test_create_without_project_id_with_failure
2427 2427 @request.session[:user_id] = 2
2428 2428
2429 2429 post :create,
2430 2430 :issue => {:project_id => 3,
2431 2431 :tracker_id => 2,
2432 2432 :subject => ''}
2433 2433 assert_response :success
2434 2434 assert_nil assigns(:project)
2435 2435 end
2436 2436
2437 2437 def test_post_create_should_send_a_notification
2438 2438 ActionMailer::Base.deliveries.clear
2439 2439 @request.session[:user_id] = 2
2440 2440 with_settings :notified_events => %w(issue_added) do
2441 2441 assert_difference 'Issue.count' do
2442 2442 post :create, :project_id => 1,
2443 2443 :issue => {:tracker_id => 3,
2444 2444 :subject => 'This is the test_new issue',
2445 2445 :description => 'This is the description',
2446 2446 :priority_id => 5,
2447 2447 :estimated_hours => '',
2448 2448 :custom_field_values => {'2' => 'Value for field 2'}}
2449 2449 end
2450 2450 assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
2451 2451
2452 2452 assert_equal 1, ActionMailer::Base.deliveries.size
2453 2453 end
2454 2454 end
2455 2455
2456 2456 def test_post_create_should_preserve_fields_values_on_validation_failure
2457 2457 @request.session[:user_id] = 2
2458 2458 post :create, :project_id => 1,
2459 2459 :issue => {:tracker_id => 1,
2460 2460 # empty subject
2461 2461 :subject => '',
2462 2462 :description => 'This is a description',
2463 2463 :priority_id => 6,
2464 2464 :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
2465 2465 assert_response :success
2466 2466 assert_template 'new'
2467 2467
2468 2468 assert_select 'textarea[name=?]', 'issue[description]', :text => 'This is a description'
2469 2469 assert_select 'select[name=?]', 'issue[priority_id]' do
2470 2470 assert_select 'option[value="6"][selected=selected]', :text => 'High'
2471 2471 end
2472 2472 # Custom fields
2473 2473 assert_select 'select[name=?]', 'issue[custom_field_values][1]' do
2474 2474 assert_select 'option[value=Oracle][selected=selected]', :text => 'Oracle'
2475 2475 end
2476 2476 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', 'Value for field 2'
2477 2477 end
2478 2478
2479 2479 def test_post_create_with_failure_should_preserve_watchers
2480 2480 assert !User.find(8).member_of?(Project.find(1))
2481 2481
2482 2482 @request.session[:user_id] = 2
2483 2483 post :create, :project_id => 1,
2484 2484 :issue => {:tracker_id => 1,
2485 2485 :watcher_user_ids => ['3', '8']}
2486 2486 assert_response :success
2487 2487 assert_template 'new'
2488 2488
2489 2489 assert_select 'input[name=?][value="2"]:not(checked)', 'issue[watcher_user_ids][]'
2490 2490 assert_select 'input[name=?][value="3"][checked=checked]', 'issue[watcher_user_ids][]'
2491 2491 assert_select 'input[name=?][value="8"][checked=checked]', 'issue[watcher_user_ids][]'
2492 2492 end
2493 2493
2494 2494 def test_post_create_should_ignore_non_safe_attributes
2495 2495 @request.session[:user_id] = 2
2496 2496 assert_nothing_raised do
2497 2497 post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
2498 2498 end
2499 2499 end
2500 2500
2501 2501 def test_post_create_with_attachment
2502 2502 set_tmp_attachments_directory
2503 2503 @request.session[:user_id] = 2
2504 2504
2505 2505 assert_difference 'Issue.count' do
2506 2506 assert_difference 'Attachment.count' do
2507 2507 assert_no_difference 'Journal.count' do
2508 2508 post :create, :project_id => 1,
2509 2509 :issue => { :tracker_id => '1', :subject => 'With attachment' },
2510 2510 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2511 2511 end
2512 2512 end
2513 2513 end
2514 2514
2515 2515 issue = Issue.order('id DESC').first
2516 2516 attachment = Attachment.order('id DESC').first
2517 2517
2518 2518 assert_equal issue, attachment.container
2519 2519 assert_equal 2, attachment.author_id
2520 2520 assert_equal 'testfile.txt', attachment.filename
2521 2521 assert_equal 'text/plain', attachment.content_type
2522 2522 assert_equal 'test file', attachment.description
2523 2523 assert_equal 59, attachment.filesize
2524 2524 assert File.exists?(attachment.diskfile)
2525 2525 assert_equal 59, File.size(attachment.diskfile)
2526 2526 end
2527 2527
2528 2528 def test_post_create_with_attachment_should_notify_with_attachments
2529 2529 ActionMailer::Base.deliveries.clear
2530 2530 set_tmp_attachments_directory
2531 2531 @request.session[:user_id] = 2
2532 2532
2533 2533 with_settings :host_name => 'mydomain.foo', :protocol => 'http', :notified_events => %w(issue_added) do
2534 2534 assert_difference 'Issue.count' do
2535 2535 post :create, :project_id => 1,
2536 2536 :issue => { :tracker_id => '1', :subject => 'With attachment' },
2537 2537 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2538 2538 end
2539 2539 end
2540 2540
2541 2541 assert_not_nil ActionMailer::Base.deliveries.last
2542 2542 assert_select_email do
2543 2543 assert_select 'a[href^=?]', 'http://mydomain.foo/attachments/download', 'testfile.txt'
2544 2544 end
2545 2545 end
2546 2546
2547 2547 def test_post_create_with_failure_should_save_attachments
2548 2548 set_tmp_attachments_directory
2549 2549 @request.session[:user_id] = 2
2550 2550
2551 2551 assert_no_difference 'Issue.count' do
2552 2552 assert_difference 'Attachment.count' do
2553 2553 post :create, :project_id => 1,
2554 2554 :issue => { :tracker_id => '1', :subject => '' },
2555 2555 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
2556 2556 assert_response :success
2557 2557 assert_template 'new'
2558 2558 end
2559 2559 end
2560 2560
2561 2561 attachment = Attachment.order('id DESC').first
2562 2562 assert_equal 'testfile.txt', attachment.filename
2563 2563 assert File.exists?(attachment.diskfile)
2564 2564 assert_nil attachment.container
2565 2565
2566 2566 assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
2567 2567 assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
2568 2568 end
2569 2569
2570 2570 def test_post_create_with_failure_should_keep_saved_attachments
2571 2571 set_tmp_attachments_directory
2572 2572 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2573 2573 @request.session[:user_id] = 2
2574 2574
2575 2575 assert_no_difference 'Issue.count' do
2576 2576 assert_no_difference 'Attachment.count' do
2577 2577 post :create, :project_id => 1,
2578 2578 :issue => { :tracker_id => '1', :subject => '' },
2579 2579 :attachments => {'p0' => {'token' => attachment.token}}
2580 2580 assert_response :success
2581 2581 assert_template 'new'
2582 2582 end
2583 2583 end
2584 2584
2585 2585 assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
2586 2586 assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
2587 2587 end
2588 2588
2589 2589 def test_post_create_should_attach_saved_attachments
2590 2590 set_tmp_attachments_directory
2591 2591 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
2592 2592 @request.session[:user_id] = 2
2593 2593
2594 2594 assert_difference 'Issue.count' do
2595 2595 assert_no_difference 'Attachment.count' do
2596 2596 post :create, :project_id => 1,
2597 2597 :issue => { :tracker_id => '1', :subject => 'Saved attachments' },
2598 2598 :attachments => {'p0' => {'token' => attachment.token}}
2599 2599 assert_response 302
2600 2600 end
2601 2601 end
2602 2602
2603 2603 issue = Issue.order('id DESC').first
2604 2604 assert_equal 1, issue.attachments.count
2605 2605
2606 2606 attachment.reload
2607 2607 assert_equal issue, attachment.container
2608 2608 end
2609 2609
2610 2610 def setup_without_workflow_privilege
2611 2611 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2612 2612 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2613 2613 end
2614 2614 private :setup_without_workflow_privilege
2615 2615
2616 2616 test "without workflow privilege #new should propose default status only" do
2617 2617 setup_without_workflow_privilege
2618 2618 get :new, :project_id => 1
2619 2619 assert_response :success
2620 2620 assert_template 'new'
2621 2621
2622 2622 issue = assigns(:issue)
2623 2623 assert_not_nil issue.default_status
2624 2624
2625 2625 assert_select 'select[name=?]', 'issue[status_id]' do
2626 2626 assert_select 'option', 1
2627 2627 assert_select 'option[value=?]', issue.default_status.id.to_s
2628 2628 end
2629 2629 end
2630 2630
2631 2631 test "without workflow privilege #create should accept default status" do
2632 2632 setup_without_workflow_privilege
2633 2633 assert_difference 'Issue.count' do
2634 2634 post :create, :project_id => 1,
2635 2635 :issue => {:tracker_id => 1,
2636 2636 :subject => 'This is an issue',
2637 2637 :status_id => 1}
2638 2638 end
2639 2639 issue = Issue.order('id').last
2640 2640 assert_not_nil issue.default_status
2641 2641 assert_equal issue.default_status, issue.status
2642 2642 end
2643 2643
2644 2644 test "without workflow privilege #create should ignore unauthorized status" do
2645 2645 setup_without_workflow_privilege
2646 2646 assert_difference 'Issue.count' do
2647 2647 post :create, :project_id => 1,
2648 2648 :issue => {:tracker_id => 1,
2649 2649 :subject => 'This is an issue',
2650 2650 :status_id => 3}
2651 2651 end
2652 2652 issue = Issue.order('id').last
2653 2653 assert_not_nil issue.default_status
2654 2654 assert_equal issue.default_status, issue.status
2655 2655 end
2656 2656
2657 2657 test "without workflow privilege #update should ignore status change" do
2658 2658 setup_without_workflow_privilege
2659 2659 assert_difference 'Journal.count' do
2660 2660 put :update, :id => 1, :issue => {:status_id => 3, :notes => 'just trying'}
2661 2661 end
2662 2662 assert_equal 1, Issue.find(1).status_id
2663 2663 end
2664 2664
2665 2665 test "without workflow privilege #update ignore attributes changes" do
2666 2666 setup_without_workflow_privilege
2667 2667 assert_difference 'Journal.count' do
2668 2668 put :update, :id => 1,
2669 2669 :issue => {:subject => 'changed', :assigned_to_id => 2,
2670 2670 :notes => 'just trying'}
2671 2671 end
2672 2672 issue = Issue.find(1)
2673 2673 assert_equal "Cannot print recipes", issue.subject
2674 2674 assert_nil issue.assigned_to
2675 2675 end
2676 2676
2677 2677 def setup_with_workflow_privilege
2678 2678 WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
2679 2679 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
2680 2680 :old_status_id => 1, :new_status_id => 3)
2681 2681 WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
2682 2682 :old_status_id => 1, :new_status_id => 4)
2683 2683 Role.anonymous.add_permission! :add_issues, :add_issue_notes
2684 2684 end
2685 2685 private :setup_with_workflow_privilege
2686 2686
2687 2687 def setup_with_workflow_privilege_and_edit_issues_permission
2688 2688 setup_with_workflow_privilege
2689 2689 Role.anonymous.add_permission! :add_issues, :edit_issues
2690 2690 end
2691 2691 private :setup_with_workflow_privilege_and_edit_issues_permission
2692 2692
2693 2693 test "with workflow privilege and :edit_issues permission should accept authorized status" do
2694 2694 setup_with_workflow_privilege_and_edit_issues_permission
2695 2695 assert_difference 'Journal.count' do
2696 2696 put :update, :id => 1, :issue => {:status_id => 3, :notes => 'just trying'}
2697 2697 end
2698 2698 assert_equal 3, Issue.find(1).status_id
2699 2699 end
2700 2700
2701 2701 test "with workflow privilege and :edit_issues permission should ignore unauthorized status" do
2702 2702 setup_with_workflow_privilege_and_edit_issues_permission
2703 2703 assert_difference 'Journal.count' do
2704 2704 put :update, :id => 1, :issue => {:status_id => 2, :notes => 'just trying'}
2705 2705 end
2706 2706 assert_equal 1, Issue.find(1).status_id
2707 2707 end
2708 2708
2709 2709 test "with workflow privilege and :edit_issues permission should accept authorized attributes changes" do
2710 2710 setup_with_workflow_privilege_and_edit_issues_permission
2711 2711 assert_difference 'Journal.count' do
2712 2712 put :update, :id => 1,
2713 2713 :issue => {:subject => 'changed', :assigned_to_id => 2,
2714 2714 :notes => 'just trying'}
2715 2715 end
2716 2716 issue = Issue.find(1)
2717 2717 assert_equal "changed", issue.subject
2718 2718 assert_equal 2, issue.assigned_to_id
2719 2719 end
2720 2720
2721 2721 def test_new_as_copy
2722 2722 @request.session[:user_id] = 2
2723 2723 get :new, :project_id => 1, :copy_from => 1
2724 2724
2725 2725 assert_response :success
2726 2726 assert_template 'new'
2727 2727
2728 2728 assert_not_nil assigns(:issue)
2729 2729 orig = Issue.find(1)
2730 2730 assert_equal 1, assigns(:issue).project_id
2731 2731 assert_equal orig.subject, assigns(:issue).subject
2732 2732 assert assigns(:issue).copy?
2733 2733
2734 2734 assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do
2735 2735 assert_select 'select[name=?]', 'issue[project_id]' do
2736 2736 assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook'
2737 2737 assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore'
2738 2738 end
2739 2739 assert_select 'input[name=copy_from][value="1"]'
2740 2740 end
2741 2741
2742 2742 # "New issue" menu item should not link to copy
2743 2743 assert_select '#main-menu a.new-issue[href="/projects/ecookbook/issues/new"]'
2744 2744 end
2745 2745
2746 2746 def test_new_as_copy_without_add_issues_permission_should_not_propose_current_project_as_target
2747 2747 user = setup_user_with_copy_but_not_add_permission
2748 2748
2749 2749 @request.session[:user_id] = user.id
2750 2750 get :new, :project_id => 1, :copy_from => 1
2751 2751
2752 2752 assert_response :success
2753 2753 assert_template 'new'
2754 2754 assert_select 'select[name=?]', 'issue[project_id]' do
2755 2755 assert_select 'option[value="1"]', 0
2756 2756 assert_select 'option[value="2"]', :text => 'OnlineStore'
2757 2757 end
2758 2758 end
2759 2759
2760 2760 def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox
2761 2761 @request.session[:user_id] = 2
2762 2762 issue = Issue.find(3)
2763 2763 assert issue.attachments.count > 0
2764 2764 get :new, :project_id => 1, :copy_from => 3
2765 2765
2766 2766 assert_select 'input[name=copy_attachments][type=checkbox][checked=checked][value="1"]'
2767 2767 end
2768 2768
2769 2769 def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox
2770 2770 @request.session[:user_id] = 2
2771 2771 issue = Issue.find(3)
2772 2772 issue.attachments.delete_all
2773 2773 get :new, :project_id => 1, :copy_from => 3
2774 2774
2775 2775 assert_select 'input[name=copy_attachments]', 0
2776 2776 end
2777 2777
2778 2778 def test_new_as_copy_with_subtasks_should_show_copy_subtasks_checkbox
2779 2779 @request.session[:user_id] = 2
2780 2780 issue = Issue.generate_with_descendants!
2781 2781 get :new, :project_id => 1, :copy_from => issue.id
2782 2782
2783 2783 assert_select 'input[type=checkbox][name=copy_subtasks][checked=checked][value="1"]'
2784 2784 end
2785 2785
2786 2786 def test_new_as_copy_with_invalid_issue_should_respond_with_404
2787 2787 @request.session[:user_id] = 2
2788 2788 get :new, :project_id => 1, :copy_from => 99999
2789 2789 assert_response 404
2790 2790 end
2791 2791
2792 2792 def test_create_as_copy_on_different_project
2793 2793 @request.session[:user_id] = 2
2794 2794 assert_difference 'Issue.count' do
2795 2795 post :create, :project_id => 1, :copy_from => 1,
2796 2796 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2797 2797
2798 2798 assert_not_nil assigns(:issue)
2799 2799 assert assigns(:issue).copy?
2800 2800 end
2801 2801 issue = Issue.order('id DESC').first
2802 2802 assert_redirected_to "/issues/#{issue.id}"
2803 2803
2804 2804 assert_equal 2, issue.project_id
2805 2805 assert_equal 3, issue.tracker_id
2806 2806 assert_equal 'Copy', issue.subject
2807 2807 end
2808 2808
2809 2809 def test_create_as_copy_should_allow_status_to_be_set_to_default
2810 2810 copied = Issue.generate! :status_id => 2
2811 2811 assert_equal 2, copied.reload.status_id
2812 2812
2813 2813 @request.session[:user_id] = 2
2814 2814 assert_difference 'Issue.count' do
2815 2815 post :create, :project_id => 1, :copy_from => copied.id,
2816 2816 :issue => {:project_id => '1', :tracker_id => '1', :status_id => '1'},
2817 2817 :was_default_status => '1'
2818 2818 end
2819 2819 issue = Issue.order('id DESC').first
2820 2820 assert_equal 1, issue.status_id
2821 2821 end
2822 2822
2823 2823 def test_create_as_copy_should_copy_attachments
2824 2824 @request.session[:user_id] = 2
2825 2825 issue = Issue.find(3)
2826 2826 count = issue.attachments.count
2827 2827 assert count > 0
2828 2828 assert_difference 'Issue.count' do
2829 2829 assert_difference 'Attachment.count', count do
2830 2830 post :create, :project_id => 1, :copy_from => 3,
2831 2831 :issue => {:project_id => '1', :tracker_id => '3',
2832 2832 :status_id => '1', :subject => 'Copy with attachments'},
2833 2833 :copy_attachments => '1'
2834 2834 end
2835 2835 end
2836 2836 copy = Issue.order('id DESC').first
2837 2837 assert_equal count, copy.attachments.count
2838 2838 assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort
2839 2839 end
2840 2840
2841 2841 def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments
2842 2842 @request.session[:user_id] = 2
2843 2843 issue = Issue.find(3)
2844 2844 count = issue.attachments.count
2845 2845 assert count > 0
2846 2846 assert_difference 'Issue.count' do
2847 2847 assert_no_difference 'Attachment.count' do
2848 2848 post :create, :project_id => 1, :copy_from => 3,
2849 2849 :issue => {:project_id => '1', :tracker_id => '3',
2850 2850 :status_id => '1', :subject => 'Copy with attachments'}
2851 2851 end
2852 2852 end
2853 2853 copy = Issue.order('id DESC').first
2854 2854 assert_equal 0, copy.attachments.count
2855 2855 end
2856 2856
2857 2857 def test_create_as_copy_with_attachments_should_also_add_new_files
2858 2858 @request.session[:user_id] = 2
2859 2859 issue = Issue.find(3)
2860 2860 count = issue.attachments.count
2861 2861 assert count > 0
2862 2862 assert_difference 'Issue.count' do
2863 2863 assert_difference 'Attachment.count', count + 1 do
2864 2864 post :create, :project_id => 1, :copy_from => 3,
2865 2865 :issue => {:project_id => '1', :tracker_id => '3',
2866 2866 :status_id => '1', :subject => 'Copy with attachments'},
2867 2867 :copy_attachments => '1',
2868 2868 :attachments => {'1' =>
2869 2869 {'file' => uploaded_test_file('testfile.txt', 'text/plain'),
2870 2870 'description' => 'test file'}}
2871 2871 end
2872 2872 end
2873 2873 copy = Issue.order('id DESC').first
2874 2874 assert_equal count + 1, copy.attachments.count
2875 2875 end
2876 2876
2877 2877 def test_create_as_copy_should_add_relation_with_copied_issue
2878 2878 @request.session[:user_id] = 2
2879 2879 assert_difference 'Issue.count' do
2880 2880 assert_difference 'IssueRelation.count' do
2881 2881 post :create, :project_id => 1, :copy_from => 1, :link_copy => '1',
2882 2882 :issue => {:project_id => '1', :tracker_id => '3',
2883 2883 :status_id => '1', :subject => 'Copy'}
2884 2884 end
2885 2885 end
2886 2886 copy = Issue.order('id DESC').first
2887 2887 assert_equal 1, copy.relations.size
2888 2888 end
2889 2889
2890 2890 def test_create_as_copy_should_allow_not_to_add_relation_with_copied_issue
2891 2891 @request.session[:user_id] = 2
2892 2892 assert_difference 'Issue.count' do
2893 2893 assert_no_difference 'IssueRelation.count' do
2894 2894 post :create, :project_id => 1, :copy_from => 1,
2895 2895 :issue => {:subject => 'Copy'}
2896 2896 end
2897 2897 end
2898 2898 end
2899 2899
2900 2900 def test_create_as_copy_should_always_add_relation_with_copied_issue_by_setting
2901 2901 with_settings :link_copied_issue => 'yes' do
2902 2902 @request.session[:user_id] = 2
2903 2903 assert_difference 'Issue.count' do
2904 2904 assert_difference 'IssueRelation.count' do
2905 2905 post :create, :project_id => 1, :copy_from => 1,
2906 2906 :issue => {:subject => 'Copy'}
2907 2907 end
2908 2908 end
2909 2909 end
2910 2910 end
2911 2911
2912 2912 def test_create_as_copy_should_never_add_relation_with_copied_issue_by_setting
2913 2913 with_settings :link_copied_issue => 'no' do
2914 2914 @request.session[:user_id] = 2
2915 2915 assert_difference 'Issue.count' do
2916 2916 assert_no_difference 'IssueRelation.count' do
2917 2917 post :create, :project_id => 1, :copy_from => 1, :link_copy => '1',
2918 2918 :issue => {:subject => 'Copy'}
2919 2919 end
2920 2920 end
2921 2921 end
2922 2922 end
2923 2923
2924 2924 def test_create_as_copy_should_copy_subtasks
2925 2925 @request.session[:user_id] = 2
2926 2926 issue = Issue.generate_with_descendants!
2927 2927 count = issue.descendants.count
2928 2928 assert_difference 'Issue.count', count + 1 do
2929 2929 post :create, :project_id => 1, :copy_from => issue.id,
2930 2930 :issue => {:project_id => '1', :tracker_id => '3',
2931 2931 :status_id => '1', :subject => 'Copy with subtasks'},
2932 2932 :copy_subtasks => '1'
2933 2933 end
2934 2934 copy = Issue.where(:parent_id => nil).order('id DESC').first
2935 2935 assert_equal count, copy.descendants.count
2936 2936 assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort
2937 2937 end
2938 2938
2939 2939 def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
2940 2940 @request.session[:user_id] = 2
2941 2941 issue = Issue.generate_with_descendants!
2942 2942 assert_difference 'Issue.count', 1 do
2943 2943 post :create, :project_id => 1, :copy_from => 3,
2944 2944 :issue => {:project_id => '1', :tracker_id => '3',
2945 2945 :status_id => '1', :subject => 'Copy with subtasks'}
2946 2946 end
2947 2947 copy = Issue.where(:parent_id => nil).order('id DESC').first
2948 2948 assert_equal 0, copy.descendants.count
2949 2949 end
2950 2950
2951 2951 def test_create_as_copy_with_failure
2952 2952 @request.session[:user_id] = 2
2953 2953 post :create, :project_id => 1, :copy_from => 1,
2954 2954 :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
2955 2955
2956 2956 assert_response :success
2957 2957 assert_template 'new'
2958 2958
2959 2959 assert_not_nil assigns(:issue)
2960 2960 assert assigns(:issue).copy?
2961 2961
2962 2962 assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do
2963 2963 assert_select 'select[name=?]', 'issue[project_id]' do
2964 2964 assert_select 'option[value="1"]:not([selected])', :text => 'eCookbook'
2965 2965 assert_select 'option[value="2"][selected=selected]', :text => 'OnlineStore'
2966 2966 end
2967 2967 assert_select 'input[name=copy_from][value="1"]'
2968 2968 end
2969 2969 end
2970 2970
2971 2971 def test_create_as_copy_on_project_without_permission_should_ignore_target_project
2972 2972 @request.session[:user_id] = 2
2973 2973 assert !User.find(2).member_of?(Project.find(4))
2974 2974
2975 2975 assert_difference 'Issue.count' do
2976 2976 post :create, :project_id => 1, :copy_from => 1,
2977 2977 :issue => {:project_id => '4', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
2978 2978 end
2979 2979 issue = Issue.order('id DESC').first
2980 2980 assert_equal 1, issue.project_id
2981 2981 end
2982 2982
2983 2983 def test_get_edit
2984 2984 @request.session[:user_id] = 2
2985 2985 get :edit, :id => 1
2986 2986 assert_response :success
2987 2987 assert_template 'edit'
2988 2988 assert_not_nil assigns(:issue)
2989 2989 assert_equal Issue.find(1), assigns(:issue)
2990 2990
2991 2991 # Be sure we don't display inactive IssuePriorities
2992 2992 assert ! IssuePriority.find(15).active?
2993 2993 assert_select 'select[name=?]', 'issue[priority_id]' do
2994 2994 assert_select 'option[value="15"]', 0
2995 2995 end
2996 2996 end
2997 2997
2998 2998 def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
2999 2999 @request.session[:user_id] = 2
3000 3000 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
3001 3001
3002 3002 get :edit, :id => 1
3003 3003 assert_select 'input[name=?]', 'time_entry[hours]'
3004 3004 end
3005 3005
3006 3006 def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
3007 3007 @request.session[:user_id] = 2
3008 3008 Role.find_by_name('Manager').remove_permission! :log_time
3009 3009
3010 3010 get :edit, :id => 1
3011 3011 assert_select 'input[name=?]', 'time_entry[hours]', 0
3012 3012 end
3013 3013
3014 3014 def test_get_edit_with_params
3015 3015 @request.session[:user_id] = 2
3016 3016 get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 },
3017 3017 :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => 10 }
3018 3018 assert_response :success
3019 3019 assert_template 'edit'
3020 3020
3021 3021 issue = assigns(:issue)
3022 3022 assert_not_nil issue
3023 3023
3024 3024 assert_equal 5, issue.status_id
3025 3025 assert_select 'select[name=?]', 'issue[status_id]' do
3026 3026 assert_select 'option[value="5"][selected=selected]', :text => 'Closed'
3027 3027 end
3028 3028
3029 3029 assert_equal 7, issue.priority_id
3030 3030 assert_select 'select[name=?]', 'issue[priority_id]' do
3031 3031 assert_select 'option[value="7"][selected=selected]', :text => 'Urgent'
3032 3032 end
3033 3033
3034 3034 assert_select 'input[name=?][value="2.5"]', 'time_entry[hours]'
3035 3035 assert_select 'select[name=?]', 'time_entry[activity_id]' do
3036 3036 assert_select 'option[value="10"][selected=selected]', :text => 'Development'
3037 3037 end
3038 3038 assert_select 'input[name=?][value=test_get_edit_with_params]', 'time_entry[comments]'
3039 3039 end
3040 3040
3041 3041 def test_get_edit_with_multi_custom_field
3042 3042 field = CustomField.find(1)
3043 3043 field.update_attribute :multiple, true
3044 3044 issue = Issue.find(1)
3045 3045 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
3046 3046 issue.save!
3047 3047
3048 3048 @request.session[:user_id] = 2
3049 3049 get :edit, :id => 1
3050 3050 assert_response :success
3051 3051 assert_template 'edit'
3052 3052
3053 3053 assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do
3054 3054 assert_select 'option', 3
3055 3055 assert_select 'option[value=MySQL][selected=selected]'
3056 3056 assert_select 'option[value=Oracle][selected=selected]'
3057 3057 assert_select 'option[value=PostgreSQL]:not([selected])'
3058 3058 end
3059 3059 end
3060 3060
3061 3061 def test_update_form_for_existing_issue
3062 3062 @request.session[:user_id] = 2
3063 3063 xhr :patch, :edit, :id => 1,
3064 3064 :issue => {:tracker_id => 2,
3065 3065 :subject => 'This is the test_new issue',
3066 3066 :description => 'This is the description',
3067 3067 :priority_id => 5}
3068 3068 assert_response :success
3069 3069 assert_equal 'text/javascript', response.content_type
3070 3070 assert_template 'edit'
3071 3071 assert_template :partial => '_form'
3072 3072
3073 3073 issue = assigns(:issue)
3074 3074 assert_kind_of Issue, issue
3075 3075 assert_equal 1, issue.id
3076 3076 assert_equal 1, issue.project_id
3077 3077 assert_equal 2, issue.tracker_id
3078 3078 assert_equal 'This is the test_new issue', issue.subject
3079 3079 end
3080 3080
3081 3081 def test_update_form_for_existing_issue_should_keep_issue_author
3082 3082 @request.session[:user_id] = 3
3083 3083 xhr :patch, :edit, :id => 1, :issue => {:subject => 'Changed'}
3084 3084 assert_response :success
3085 3085 assert_equal 'text/javascript', response.content_type
3086 3086
3087 3087 issue = assigns(:issue)
3088 3088 assert_equal User.find(2), issue.author
3089 3089 assert_equal 2, issue.author_id
3090 3090 assert_not_equal User.current, issue.author
3091 3091 end
3092 3092
3093 3093 def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status
3094 3094 @request.session[:user_id] = 2
3095 3095 WorkflowTransition.delete_all
3096 3096 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
3097 3097 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
3098 3098 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
3099 3099
3100 3100 xhr :patch, :edit, :id => 2,
3101 3101 :issue => {:tracker_id => 2,
3102 3102 :status_id => 5,
3103 3103 :subject => 'This is an issue'}
3104 3104
3105 3105 assert_equal 5, assigns(:issue).status_id
3106 3106 assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort
3107 3107 end
3108 3108
3109 3109 def test_update_form_for_existing_issue_with_project_change
3110 3110 @request.session[:user_id] = 2
3111 3111 xhr :patch, :edit, :id => 1,
3112 3112 :issue => {:project_id => 2,
3113 3113 :tracker_id => 2,
3114 3114 :subject => 'This is the test_new issue',
3115 3115 :description => 'This is the description',
3116 3116 :priority_id => 5}
3117 3117 assert_response :success
3118 3118 assert_template :partial => '_form'
3119 3119
3120 3120 issue = assigns(:issue)
3121 3121 assert_kind_of Issue, issue
3122 3122 assert_equal 1, issue.id
3123 3123 assert_equal 2, issue.project_id
3124 3124 assert_equal 2, issue.tracker_id
3125 3125 assert_equal 'This is the test_new issue', issue.subject
3126 3126 end
3127 3127
3128 3128 def test_update_form_should_keep_category_with_same_when_changing_project
3129 3129 source = Project.generate!
3130 3130 target = Project.generate!
3131 3131 source_category = IssueCategory.create!(:name => 'Foo', :project => source)
3132 3132 target_category = IssueCategory.create!(:name => 'Foo', :project => target)
3133 3133 issue = Issue.generate!(:project => source, :category => source_category)
3134 3134
3135 3135 @request.session[:user_id] = 1
3136 3136 patch :edit, :id => issue.id,
3137 3137 :issue => {:project_id => target.id, :category_id => source_category.id}
3138 3138 assert_response :success
3139 3139
3140 3140 issue = assigns(:issue)
3141 3141 assert_equal target_category, issue.category
3142 3142 end
3143 3143
3144 3144 def test_update_form_should_propose_default_status_for_existing_issue
3145 3145 @request.session[:user_id] = 2
3146 3146 WorkflowTransition.delete_all
3147 3147 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
3148 3148
3149 3149 xhr :patch, :edit, :id => 2
3150 3150 assert_response :success
3151 3151 assert_equal [2,3], assigns(:allowed_statuses).map(&:id).sort
3152 3152 end
3153 3153
3154 3154 def test_put_update_without_custom_fields_param
3155 3155 @request.session[:user_id] = 2
3156 3156
3157 3157 issue = Issue.find(1)
3158 3158 assert_equal '125', issue.custom_value_for(2).value
3159 3159
3160 3160 assert_difference('Journal.count') do
3161 3161 assert_difference('JournalDetail.count') do
3162 3162 put :update, :id => 1, :issue => {:subject => 'New subject'}
3163 3163 end
3164 3164 end
3165 3165 assert_redirected_to :action => 'show', :id => '1'
3166 3166 issue.reload
3167 3167 assert_equal 'New subject', issue.subject
3168 3168 # Make sure custom fields were not cleared
3169 3169 assert_equal '125', issue.custom_value_for(2).value
3170 3170 end
3171 3171
3172 3172 def test_put_update_with_project_change
3173 3173 @request.session[:user_id] = 2
3174 3174 ActionMailer::Base.deliveries.clear
3175 3175
3176 3176 with_settings :notified_events => %w(issue_updated) do
3177 3177 assert_difference('Journal.count') do
3178 3178 assert_difference('JournalDetail.count', 3) do
3179 3179 put :update, :id => 1, :issue => {:project_id => '2',
3180 3180 :tracker_id => '1', # no change
3181 3181 :priority_id => '6',
3182 3182 :category_id => '3'
3183 3183 }
3184 3184 end
3185 3185 end
3186 3186 end
3187 3187 assert_redirected_to :action => 'show', :id => '1'
3188 3188 issue = Issue.find(1)
3189 3189 assert_equal 2, issue.project_id
3190 3190 assert_equal 1, issue.tracker_id
3191 3191 assert_equal 6, issue.priority_id
3192 3192 assert_equal 3, issue.category_id
3193 3193
3194 3194 mail = ActionMailer::Base.deliveries.last
3195 3195 assert_not_nil mail
3196 3196 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
3197 3197 assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail
3198 3198 end
3199 3199
3200 3200 def test_put_update_trying_to_move_issue_to_project_without_tracker_should_not_error
3201 3201 target = Project.generate!(:tracker_ids => [])
3202 3202 assert target.trackers.empty?
3203 3203 issue = Issue.generate!
3204 3204 @request.session[:user_id] = 1
3205 3205
3206 3206 put :update, :id => issue.id, :issue => {:project_id => target.id}
3207 3207 assert_response 302
3208 3208 end
3209 3209
3210 3210 def test_put_update_with_tracker_change
3211 3211 @request.session[:user_id] = 2
3212 3212 ActionMailer::Base.deliveries.clear
3213 3213
3214 3214 with_settings :notified_events => %w(issue_updated) do
3215 3215 assert_difference('Journal.count') do
3216 3216 assert_difference('JournalDetail.count', 2) do
3217 3217 put :update, :id => 1, :issue => {:project_id => '1',
3218 3218 :tracker_id => '2',
3219 3219 :priority_id => '6'
3220 3220 }
3221 3221 end
3222 3222 end
3223 3223 end
3224 3224 assert_redirected_to :action => 'show', :id => '1'
3225 3225 issue = Issue.find(1)
3226 3226 assert_equal 1, issue.project_id
3227 3227 assert_equal 2, issue.tracker_id
3228 3228 assert_equal 6, issue.priority_id
3229 3229 assert_equal 1, issue.category_id
3230 3230
3231 3231 mail = ActionMailer::Base.deliveries.last
3232 3232 assert_not_nil mail
3233 3233 assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
3234 3234 assert_mail_body_match "Tracker changed from Bug to Feature request", mail
3235 3235 end
3236 3236
3237 3237 def test_put_update_with_custom_field_change
3238 3238 @request.session[:user_id] = 2
3239 3239 issue = Issue.find(1)
3240 3240 assert_equal '125', issue.custom_value_for(2).value
3241 3241
3242 3242 with_settings :notified_events => %w(issue_updated) do
3243 3243 assert_difference('Journal.count') do
3244 3244 assert_difference('JournalDetail.count', 3) do
3245 3245 put :update, :id => 1, :issue => {:subject => 'Custom field change',
3246 3246 :priority_id => '6',
3247 3247 :category_id => '1', # no change
3248 3248 :custom_field_values => { '2' => 'New custom value' }
3249 3249 }
3250 3250 end
3251 3251 end
3252 3252 end
3253 3253 assert_redirected_to :action => 'show', :id => '1'
3254 3254 issue.reload
3255 3255 assert_equal 'New custom value', issue.custom_value_for(2).value
3256 3256
3257 3257 mail = ActionMailer::Base.deliveries.last
3258 3258 assert_not_nil mail
3259 3259 assert_mail_body_match "Searchable field changed from 125 to New custom value", mail
3260 3260 end
3261 3261
3262 3262 def test_put_update_with_multi_custom_field_change
3263 3263 field = CustomField.find(1)
3264 3264 field.update_attribute :multiple, true
3265 3265 issue = Issue.find(1)
3266 3266 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
3267 3267 issue.save!
3268 3268
3269 3269 @request.session[:user_id] = 2
3270 3270 assert_difference('Journal.count') do
3271 3271 assert_difference('JournalDetail.count', 3) do
3272 3272 put :update, :id => 1,
3273 3273 :issue => {
3274 3274 :subject => 'Custom field change',
3275 3275 :custom_field_values => { '1' => ['', 'Oracle', 'PostgreSQL'] }
3276 3276 }
3277 3277 end
3278 3278 end
3279 3279 assert_redirected_to :action => 'show', :id => '1'
3280 3280 assert_equal ['Oracle', 'PostgreSQL'], Issue.find(1).custom_field_value(1).sort
3281 3281 end
3282 3282
3283 3283 def test_put_update_with_status_and_assignee_change
3284 3284 issue = Issue.find(1)
3285 3285 assert_equal 1, issue.status_id
3286 3286 @request.session[:user_id] = 2
3287 3287
3288 3288 with_settings :notified_events => %w(issue_updated) do
3289 3289 assert_difference('TimeEntry.count', 0) do
3290 3290 put :update,
3291 3291 :id => 1,
3292 3292 :issue => { :status_id => 2, :assigned_to_id => 3, :notes => 'Assigned to dlopper' },
3293 3293 :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
3294 3294 end
3295 3295 end
3296 3296 assert_redirected_to :action => 'show', :id => '1'
3297 3297 issue.reload
3298 3298 assert_equal 2, issue.status_id
3299 3299 j = Journal.order('id DESC').first
3300 3300 assert_equal 'Assigned to dlopper', j.notes
3301 3301 assert_equal 2, j.details.size
3302 3302
3303 3303 mail = ActionMailer::Base.deliveries.last
3304 3304 assert_mail_body_match "Status changed from New to Assigned", mail
3305 3305 # subject should contain the new status
3306 3306 assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
3307 3307 end
3308 3308
3309 3309 def test_put_update_with_note_only
3310 3310 notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
3311 3311
3312 3312 with_settings :notified_events => %w(issue_updated) do
3313 3313 # anonymous user
3314 3314 put :update,
3315 3315 :id => 1,
3316 3316 :issue => { :notes => notes }
3317 3317 end
3318 3318 assert_redirected_to :action => 'show', :id => '1'
3319 3319 j = Journal.order('id DESC').first
3320 3320 assert_equal notes, j.notes
3321 3321 assert_equal 0, j.details.size
3322 3322 assert_equal User.anonymous, j.user
3323 3323
3324 3324 mail = ActionMailer::Base.deliveries.last
3325 3325 assert_mail_body_match notes, mail
3326 3326 end
3327 3327
3328 3328 def test_put_update_with_private_note_only
3329 3329 notes = 'Private note'
3330 3330 @request.session[:user_id] = 2
3331 3331
3332 3332 assert_difference 'Journal.count' do
3333 3333 put :update, :id => 1, :issue => {:notes => notes, :private_notes => '1'}
3334 3334 assert_redirected_to :action => 'show', :id => '1'
3335 3335 end
3336 3336
3337 3337 j = Journal.order('id DESC').first
3338 3338 assert_equal notes, j.notes
3339 3339 assert_equal true, j.private_notes
3340 3340 end
3341 3341
3342 3342 def test_put_update_with_private_note_and_changes
3343 3343 notes = 'Private note'
3344 3344 @request.session[:user_id] = 2
3345 3345
3346 3346 assert_difference 'Journal.count', 2 do
3347 3347 put :update, :id => 1, :issue => {:subject => 'New subject', :notes => notes, :private_notes => '1'}
3348 3348 assert_redirected_to :action => 'show', :id => '1'
3349 3349 end
3350 3350
3351 3351 j = Journal.order('id DESC').first
3352 3352 assert_equal notes, j.notes
3353 3353 assert_equal true, j.private_notes
3354 3354 assert_equal 0, j.details.count
3355 3355
3356 3356 j = Journal.order('id DESC').offset(1).first
3357 3357 assert_nil j.notes
3358 3358 assert_equal false, j.private_notes
3359 3359 assert_equal 1, j.details.count
3360 3360 end
3361 3361
3362 3362 def test_put_update_with_note_and_spent_time
3363 3363 @request.session[:user_id] = 2
3364 3364 spent_hours_before = Issue.find(1).spent_hours
3365 3365 assert_difference('TimeEntry.count') do
3366 3366 put :update,
3367 3367 :id => 1,
3368 3368 :issue => { :notes => '2.5 hours added' },
3369 3369 :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
3370 3370 end
3371 3371 assert_redirected_to :action => 'show', :id => '1'
3372 3372
3373 3373 issue = Issue.find(1)
3374 3374
3375 3375 j = Journal.order('id DESC').first
3376 3376 assert_equal '2.5 hours added', j.notes
3377 3377 assert_equal 0, j.details.size
3378 3378
3379 3379 t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
3380 3380 assert_not_nil t
3381 3381 assert_equal 2.5, t.hours
3382 3382 assert_equal spent_hours_before + 2.5, issue.spent_hours
3383 3383 end
3384 3384
3385 3385 def test_put_update_should_preserve_parent_issue_even_if_not_visible
3386 3386 parent = Issue.generate!(:project_id => 1, :is_private => true)
3387 3387 issue = Issue.generate!(:parent_issue_id => parent.id)
3388 3388 assert !parent.visible?(User.find(3))
3389 3389 @request.session[:user_id] = 3
3390 3390
3391 3391 get :edit, :id => issue.id
3392 3392 assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', parent.id.to_s
3393 3393
3394 3394 put :update, :id => issue.id, :issue => {:subject => 'New subject', :parent_issue_id => parent.id.to_s}
3395 3395 assert_response 302
3396 3396 assert_equal parent, issue.parent
3397 3397 end
3398 3398
3399 3399 def test_put_update_with_attachment_only
3400 3400 set_tmp_attachments_directory
3401 3401
3402 3402 # Delete all fixtured journals, a race condition can occur causing the wrong
3403 3403 # journal to get fetched in the next find.
3404 3404 Journal.delete_all
3405 3405
3406 3406 with_settings :notified_events => %w(issue_updated) do
3407 3407 # anonymous user
3408 3408 assert_difference 'Attachment.count' do
3409 3409 put :update, :id => 1,
3410 3410 :issue => {:notes => ''},
3411 3411 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
3412 3412 end
3413 3413 end
3414 3414
3415 3415 assert_redirected_to :action => 'show', :id => '1'
3416 3416 j = Issue.find(1).journals.reorder('id DESC').first
3417 3417 assert j.notes.blank?
3418 3418 assert_equal 1, j.details.size
3419 3419 assert_equal 'testfile.txt', j.details.first.value
3420 3420 assert_equal User.anonymous, j.user
3421 3421
3422 3422 attachment = Attachment.order('id DESC').first
3423 3423 assert_equal Issue.find(1), attachment.container
3424 3424 assert_equal User.anonymous, attachment.author
3425 3425 assert_equal 'testfile.txt', attachment.filename
3426 3426 assert_equal 'text/plain', attachment.content_type
3427 3427 assert_equal 'test file', attachment.description
3428 3428 assert_equal 59, attachment.filesize
3429 3429 assert File.exists?(attachment.diskfile)
3430 3430 assert_equal 59, File.size(attachment.diskfile)
3431 3431
3432 3432 mail = ActionMailer::Base.deliveries.last
3433 3433 assert_mail_body_match 'testfile.txt', mail
3434 3434 end
3435 3435
3436 3436 def test_put_update_with_failure_should_save_attachments
3437 3437 set_tmp_attachments_directory
3438 3438 @request.session[:user_id] = 2
3439 3439
3440 3440 assert_no_difference 'Journal.count' do
3441 3441 assert_difference 'Attachment.count' do
3442 3442 put :update, :id => 1,
3443 3443 :issue => { :subject => '' },
3444 3444 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
3445 3445 assert_response :success
3446 3446 assert_template 'edit'
3447 3447 end
3448 3448 end
3449 3449
3450 3450 attachment = Attachment.order('id DESC').first
3451 3451 assert_equal 'testfile.txt', attachment.filename
3452 3452 assert File.exists?(attachment.diskfile)
3453 3453 assert_nil attachment.container
3454 3454
3455 3455 assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
3456 3456 assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
3457 3457 end
3458 3458
3459 3459 def test_put_update_with_failure_should_keep_saved_attachments
3460 3460 set_tmp_attachments_directory
3461 3461 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
3462 3462 @request.session[:user_id] = 2
3463 3463
3464 3464 assert_no_difference 'Journal.count' do
3465 3465 assert_no_difference 'Attachment.count' do
3466 3466 put :update, :id => 1,
3467 3467 :issue => { :subject => '' },
3468 3468 :attachments => {'p0' => {'token' => attachment.token}}
3469 3469 assert_response :success
3470 3470 assert_template 'edit'
3471 3471 end
3472 3472 end
3473 3473
3474 3474 assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token
3475 3475 assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt'
3476 3476 end
3477 3477
3478 3478 def test_put_update_should_attach_saved_attachments
3479 3479 set_tmp_attachments_directory
3480 3480 attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
3481 3481 @request.session[:user_id] = 2
3482 3482
3483 3483 assert_difference 'Journal.count' do
3484 3484 assert_difference 'JournalDetail.count' do
3485 3485 assert_no_difference 'Attachment.count' do
3486 3486 put :update, :id => 1,
3487 3487 :issue => {:notes => 'Attachment added'},
3488 3488 :attachments => {'p0' => {'token' => attachment.token}}
3489 3489 assert_redirected_to '/issues/1'
3490 3490 end
3491 3491 end
3492 3492 end
3493 3493
3494 3494 attachment.reload
3495 3495 assert_equal Issue.find(1), attachment.container
3496 3496
3497 3497 journal = Journal.order('id DESC').first
3498 3498 assert_equal 1, journal.details.size
3499 3499 assert_equal 'testfile.txt', journal.details.first.value
3500 3500 end
3501 3501
3502 3502 def test_put_update_with_attachment_that_fails_to_save
3503 3503 set_tmp_attachments_directory
3504 3504
3505 3505 # anonymous user
3506 3506 with_settings :attachment_max_size => 0 do
3507 3507 put :update,
3508 3508 :id => 1,
3509 3509 :issue => {:notes => ''},
3510 3510 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
3511 3511 assert_redirected_to :action => 'show', :id => '1'
3512 3512 assert_equal '1 file(s) could not be saved.', flash[:warning]
3513 3513 end
3514 3514 end
3515 3515
3516 3516 def test_put_update_with_no_change
3517 3517 issue = Issue.find(1)
3518 3518 issue.journals.clear
3519 3519 ActionMailer::Base.deliveries.clear
3520 3520
3521 3521 put :update,
3522 3522 :id => 1,
3523 3523 :issue => {:notes => ''}
3524 3524 assert_redirected_to :action => 'show', :id => '1'
3525 3525
3526 3526 issue.reload
3527 3527 assert issue.journals.empty?
3528 3528 # No email should be sent
3529 3529 assert ActionMailer::Base.deliveries.empty?
3530 3530 end
3531 3531
3532 3532 def test_put_update_should_send_a_notification
3533 3533 @request.session[:user_id] = 2
3534 3534 ActionMailer::Base.deliveries.clear
3535 3535 issue = Issue.find(1)
3536 3536 old_subject = issue.subject
3537 3537 new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
3538 3538
3539 3539 with_settings :notified_events => %w(issue_updated) do
3540 3540 put :update, :id => 1, :issue => {:subject => new_subject,
3541 3541 :priority_id => '6',
3542 3542 :category_id => '1' # no change
3543 3543 }
3544 3544 assert_equal 1, ActionMailer::Base.deliveries.size
3545 3545 end
3546 3546 end
3547 3547
3548 3548 def test_put_update_with_invalid_spent_time_hours_only
3549 3549 @request.session[:user_id] = 2
3550 3550 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
3551 3551
3552 3552 assert_no_difference('Journal.count') do
3553 3553 put :update,
3554 3554 :id => 1,
3555 3555 :issue => {:notes => notes},
3556 3556 :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
3557 3557 end
3558 3558 assert_response :success
3559 3559 assert_template 'edit'
3560 3560
3561 3561 assert_select_error /Activity cannot be blank/
3562 3562 assert_select 'textarea[name=?]', 'issue[notes]', :text => notes
3563 3563 assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2z'
3564 3564 end
3565 3565
3566 3566 def test_put_update_with_invalid_spent_time_comments_only
3567 3567 @request.session[:user_id] = 2
3568 3568 notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
3569 3569
3570 3570 assert_no_difference('Journal.count') do
3571 3571 put :update,
3572 3572 :id => 1,
3573 3573 :issue => {:notes => notes},
3574 3574 :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""}
3575 3575 end
3576 3576 assert_response :success
3577 3577 assert_template 'edit'
3578 3578
3579 3579 assert_select_error /Activity cannot be blank/
3580 3580 assert_select_error /Hours cannot be blank/
3581 3581 assert_select 'textarea[name=?]', 'issue[notes]', :text => notes
3582 3582 assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'this is my comment'
3583 3583 end
3584 3584
3585 3585 def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
3586 3586 issue = Issue.find(2)
3587 3587 @request.session[:user_id] = 2
3588 3588
3589 3589 put :update,
3590 3590 :id => issue.id,
3591 3591 :issue => {
3592 3592 :fixed_version_id => 4
3593 3593 }
3594 3594
3595 3595 assert_response :redirect
3596 3596 issue.reload
3597 3597 assert_equal 4, issue.fixed_version_id
3598 3598 assert_not_equal issue.project_id, issue.fixed_version.project_id
3599 3599 end
3600 3600
3601 3601 def test_put_update_should_redirect_back_using_the_back_url_parameter
3602 3602 issue = Issue.find(2)
3603 3603 @request.session[:user_id] = 2
3604 3604
3605 3605 put :update,
3606 3606 :id => issue.id,
3607 3607 :issue => {
3608 3608 :fixed_version_id => 4
3609 3609 },
3610 3610 :back_url => '/issues'
3611 3611
3612 3612 assert_response :redirect
3613 3613 assert_redirected_to '/issues'
3614 3614 end
3615 3615
3616 3616 def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
3617 3617 issue = Issue.find(2)
3618 3618 @request.session[:user_id] = 2
3619 3619
3620 3620 put :update,
3621 3621 :id => issue.id,
3622 3622 :issue => {
3623 3623 :fixed_version_id => 4
3624 3624 },
3625 3625 :back_url => 'http://google.com'
3626 3626
3627 3627 assert_response :redirect
3628 3628 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
3629 3629 end
3630 3630
3631 3631 def test_get_bulk_edit
3632 3632 @request.session[:user_id] = 2
3633 3633 get :bulk_edit, :ids => [1, 3]
3634 3634 assert_response :success
3635 3635 assert_template 'bulk_edit'
3636 3636
3637 3637 assert_select 'ul#bulk-selection' do
3638 3638 assert_select 'li', 2
3639 3639 assert_select 'li a', :text => 'Bug #1'
3640 3640 end
3641 3641
3642 3642 assert_select 'form#bulk_edit_form[action=?]', '/issues/bulk_update' do
3643 3643 assert_select 'input[name=?]', 'ids[]', 2
3644 3644 assert_select 'input[name=?][value="1"][type=hidden]', 'ids[]'
3645 3645
3646 3646 assert_select 'select[name=?]', 'issue[project_id]'
3647 3647 assert_select 'input[name=?]', 'issue[parent_issue_id]'
3648 3648
3649 3649 # Project specific custom field, date type
3650 3650 field = CustomField.find(9)
3651 3651 assert !field.is_for_all?
3652 3652 assert_equal 'date', field.field_format
3653 3653 assert_select 'input[name=?]', 'issue[custom_field_values][9]'
3654 3654
3655 3655 # System wide custom field
3656 3656 assert CustomField.find(1).is_for_all?
3657 3657 assert_select 'select[name=?]', 'issue[custom_field_values][1]'
3658 3658
3659 3659 # Be sure we don't display inactive IssuePriorities
3660 3660 assert ! IssuePriority.find(15).active?
3661 3661 assert_select 'select[name=?]', 'issue[priority_id]' do
3662 3662 assert_select 'option[value="15"]', 0
3663 3663 end
3664 3664 end
3665 3665 end
3666 3666
3667 3667 def test_get_bulk_edit_on_different_projects
3668 3668 @request.session[:user_id] = 2
3669 3669 get :bulk_edit, :ids => [1, 2, 6]
3670 3670 assert_response :success
3671 3671 assert_template 'bulk_edit'
3672 3672
3673 3673 # Can not set issues from different projects as children of an issue
3674 3674 assert_select 'input[name=?]', 'issue[parent_issue_id]', 0
3675 3675
3676 3676 # Project specific custom field, date type
3677 3677 field = CustomField.find(9)
3678 3678 assert !field.is_for_all?
3679 3679 assert !field.project_ids.include?(Issue.find(6).project_id)
3680 3680 assert_select 'input[name=?]', 'issue[custom_field_values][9]', 0
3681 3681 end
3682 3682
3683 3683 def test_get_bulk_edit_with_user_custom_field
3684 3684 field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :tracker_ids => [1,2,3])
3685 3685
3686 3686 @request.session[:user_id] = 2
3687 3687 get :bulk_edit, :ids => [1, 2]
3688 3688 assert_response :success
3689 3689 assert_template 'bulk_edit'
3690 3690
3691 3691 assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
3692 3692 assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options
3693 3693 end
3694 3694 end
3695 3695
3696 3696 def test_get_bulk_edit_with_version_custom_field
3697 3697 field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1,2,3])
3698 3698
3699 3699 @request.session[:user_id] = 2
3700 3700 get :bulk_edit, :ids => [1, 2]
3701 3701 assert_response :success
3702 3702 assert_template 'bulk_edit'
3703 3703
3704 3704 assert_select 'select.version_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
3705 3705 assert_select 'option', Project.find(1).shared_versions.count + 2 # "no change" + "none" options
3706 3706 end
3707 3707 end
3708 3708
3709 3709 def test_get_bulk_edit_with_multi_custom_field
3710 3710 field = CustomField.find(1)
3711 3711 field.update_attribute :multiple, true
3712 3712
3713 3713 @request.session[:user_id] = 2
3714 3714 get :bulk_edit, :ids => [1, 3]
3715 3715 assert_response :success
3716 3716 assert_template 'bulk_edit'
3717 3717
3718 3718 assert_select 'select[name=?]', 'issue[custom_field_values][1][]' do
3719 3719 assert_select 'option', field.possible_values.size + 1 # "none" options
3720 3720 end
3721 3721 end
3722 3722
3723 3723 def test_bulk_edit_should_propose_to_clear_text_custom_fields
3724 3724 @request.session[:user_id] = 2
3725 3725 get :bulk_edit, :ids => [1, 3]
3726 3726 assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__'
3727 3727 end
3728 3728
3729 3729 def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
3730 3730 WorkflowTransition.delete_all
3731 3731 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
3732 3732 :old_status_id => 1, :new_status_id => 1)
3733 3733 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
3734 3734 :old_status_id => 1, :new_status_id => 3)
3735 3735 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
3736 3736 :old_status_id => 1, :new_status_id => 4)
3737 3737 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2,
3738 3738 :old_status_id => 2, :new_status_id => 1)
3739 3739 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2,
3740 3740 :old_status_id => 2, :new_status_id => 3)
3741 3741 WorkflowTransition.create!(:role_id => 1, :tracker_id => 2,
3742 3742 :old_status_id => 2, :new_status_id => 5)
3743 3743 @request.session[:user_id] = 2
3744 3744 get :bulk_edit, :ids => [1, 2]
3745 3745
3746 3746 assert_response :success
3747 3747 statuses = assigns(:available_statuses)
3748 3748 assert_not_nil statuses
3749 3749 assert_equal [1, 3], statuses.map(&:id).sort
3750 3750
3751 3751 assert_select 'select[name=?]', 'issue[status_id]' do
3752 3752 assert_select 'option', 3 # 2 statuses + "no change" option
3753 3753 end
3754 3754 end
3755 3755
3756 3756 def test_bulk_edit_should_propose_target_project_open_shared_versions
3757 3757 @request.session[:user_id] = 2
3758 3758 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3759 3759 assert_response :success
3760 3760 assert_template 'bulk_edit'
3761 3761 assert_equal Project.find(1).shared_versions.open.to_a.sort, assigns(:versions).sort
3762 3762
3763 3763 assert_select 'select[name=?]', 'issue[fixed_version_id]' do
3764 3764 assert_select 'option', :text => '2.0'
3765 3765 end
3766 3766 end
3767 3767
3768 3768 def test_bulk_edit_should_propose_target_project_categories
3769 3769 @request.session[:user_id] = 2
3770 3770 post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1}
3771 3771 assert_response :success
3772 3772 assert_template 'bulk_edit'
3773 3773 assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort
3774 3774
3775 3775 assert_select 'select[name=?]', 'issue[category_id]' do
3776 3776 assert_select 'option', :text => 'Recipes'
3777 3777 end
3778 3778 end
3779 3779
3780 3780 def test_bulk_edit_should_only_propose_issues_trackers_custom_fields
3781 3781 IssueCustomField.delete_all
3782 3782 field = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true)
3783 3783 IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true)
3784 3784 @request.session[:user_id] = 2
3785 3785
3786 3786 issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids
3787 3787 get :bulk_edit, :ids => issue_ids
3788 3788 assert_equal [field], assigns(:custom_fields)
3789 3789 end
3790 3790
3791 3791 def test_bulk_update
3792 3792 @request.session[:user_id] = 2
3793 3793 # update issues priority
3794 3794 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3795 3795 :issue => {:priority_id => 7,
3796 3796 :assigned_to_id => '',
3797 3797 :custom_field_values => {'2' => ''}}
3798 3798
3799 3799 assert_response 302
3800 3800 # check that the issues were updated
3801 3801 assert_equal [7, 7], Issue.where(:id =>[1, 2]).collect {|i| i.priority.id}
3802 3802
3803 3803 issue = Issue.find(1)
3804 3804 journal = issue.journals.reorder('created_on DESC').first
3805 3805 assert_equal '125', issue.custom_value_for(2).value
3806 3806 assert_equal 'Bulk editing', journal.notes
3807 3807 assert_equal 1, journal.details.size
3808 3808 end
3809 3809
3810 3810 def test_bulk_update_with_group_assignee
3811 3811 group = Group.find(11)
3812 3812 project = Project.find(1)
3813 3813 project.members << Member.new(:principal => group, :roles => [Role.givable.first])
3814 3814
3815 3815 @request.session[:user_id] = 2
3816 3816 # update issues assignee
3817 3817 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
3818 3818 :issue => {:priority_id => '',
3819 3819 :assigned_to_id => group.id,
3820 3820 :custom_field_values => {'2' => ''}}
3821 3821
3822 3822 assert_response 302
3823 3823 assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to}
3824 3824 end
3825 3825
3826 3826 def test_bulk_update_on_different_projects
3827 3827 @request.session[:user_id] = 2
3828 3828 # update issues priority
3829 3829 post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing',
3830 3830 :issue => {:priority_id => 7,
3831 3831 :assigned_to_id => '',
3832 3832 :custom_field_values => {'2' => ''}}
3833 3833
3834 3834 assert_response 302
3835 3835 # check that the issues were updated
3836 3836 assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id)
3837 3837
3838 3838 issue = Issue.find(1)
3839 3839 journal = issue.journals.reorder('created_on DESC').first
3840 3840 assert_equal '125', issue.custom_value_for(2).value
3841 3841 assert_equal 'Bulk editing', journal.notes
3842 3842 assert_equal 1, journal.details.size
3843 3843 end
3844 3844
3845 3845 def test_bulk_update_on_different_projects_without_rights
3846 3846 @request.session[:user_id] = 3
3847 3847 user = User.find(3)
3848 3848 action = { :controller => "issues", :action => "bulk_update" }
3849 3849 assert user.allowed_to?(action, Issue.find(1).project)
3850 3850 assert ! user.allowed_to?(action, Issue.find(6).project)
3851 3851 post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail',
3852 3852 :issue => {:priority_id => 7,
3853 3853 :assigned_to_id => '',
3854 3854 :custom_field_values => {'2' => ''}}
3855 3855 assert_response 403
3856 3856 assert_not_equal "Bulk should fail", Journal.last.notes
3857 3857 end
3858 3858
3859 3859 def test_bullk_update_should_send_a_notification
3860 3860 @request.session[:user_id] = 2
3861 3861 ActionMailer::Base.deliveries.clear
3862 3862 with_settings :notified_events => %w(issue_updated) do
3863 3863 post(:bulk_update,
3864 3864 {
3865 3865 :ids => [1, 2],
3866 3866 :notes => 'Bulk editing',
3867 3867 :issue => {
3868 3868 :priority_id => 7,
3869 3869 :assigned_to_id => '',
3870 3870 :custom_field_values => {'2' => ''}
3871 3871 }
3872 3872 })
3873 3873 assert_response 302
3874 3874 assert_equal 2, ActionMailer::Base.deliveries.size
3875 3875 end
3876 3876 end
3877 3877
3878 3878 def test_bulk_update_project
3879 3879 @request.session[:user_id] = 2
3880 3880 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}
3881 3881 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3882 3882 # Issues moved to project 2
3883 3883 assert_equal 2, Issue.find(1).project_id
3884 3884 assert_equal 2, Issue.find(2).project_id
3885 3885 # No tracker change
3886 3886 assert_equal 1, Issue.find(1).tracker_id
3887 3887 assert_equal 2, Issue.find(2).tracker_id
3888 3888 end
3889 3889
3890 3890 def test_bulk_update_project_on_single_issue_should_follow_when_needed
3891 3891 @request.session[:user_id] = 2
3892 3892 post :bulk_update, :id => 1, :issue => {:project_id => '2'}, :follow => '1'
3893 3893 assert_redirected_to '/issues/1'
3894 3894 end
3895 3895
3896 3896 def test_bulk_update_project_on_multiple_issues_should_follow_when_needed
3897 3897 @request.session[:user_id] = 2
3898 3898 post :bulk_update, :id => [1, 2], :issue => {:project_id => '2'}, :follow => '1'
3899 3899 assert_redirected_to '/projects/onlinestore/issues'
3900 3900 end
3901 3901
3902 3902 def test_bulk_update_tracker
3903 3903 @request.session[:user_id] = 2
3904 3904 post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2'}
3905 3905 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3906 3906 assert_equal 2, Issue.find(1).tracker_id
3907 3907 assert_equal 2, Issue.find(2).tracker_id
3908 3908 end
3909 3909
3910 3910 def test_bulk_update_status
3911 3911 @request.session[:user_id] = 2
3912 3912 # update issues priority
3913 3913 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status',
3914 3914 :issue => {:priority_id => '',
3915 3915 :assigned_to_id => '',
3916 3916 :status_id => '5'}
3917 3917
3918 3918 assert_response 302
3919 3919 issue = Issue.find(1)
3920 3920 assert issue.closed?
3921 3921 end
3922 3922
3923 3923 def test_bulk_update_priority
3924 3924 @request.session[:user_id] = 2
3925 3925 post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6}
3926 3926
3927 3927 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3928 3928 assert_equal 6, Issue.find(1).priority_id
3929 3929 assert_equal 6, Issue.find(2).priority_id
3930 3930 end
3931 3931
3932 3932 def test_bulk_update_with_notes
3933 3933 @request.session[:user_id] = 2
3934 3934 post :bulk_update, :ids => [1, 2], :notes => 'Moving two issues'
3935 3935
3936 3936 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook'
3937 3937 assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes
3938 3938 assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes
3939 3939 end
3940 3940
3941 3941 def test_bulk_update_parent_id
3942 3942 IssueRelation.delete_all
3943 3943 @request.session[:user_id] = 2
3944 3944 post :bulk_update, :ids => [1, 3],
3945 3945 :notes => 'Bulk editing parent',
3946 3946 :issue => {:priority_id => '', :assigned_to_id => '',
3947 3947 :status_id => '', :parent_issue_id => '2'}
3948 3948 assert_response 302
3949 3949 parent = Issue.find(2)
3950 3950 assert_equal parent.id, Issue.find(1).parent_id
3951 3951 assert_equal parent.id, Issue.find(3).parent_id
3952 3952 assert_equal [1, 3], parent.children.collect(&:id).sort
3953 3953 end
3954 3954
3955 3955 def test_bulk_update_custom_field
3956 3956 @request.session[:user_id] = 2
3957 3957 # update issues priority
3958 3958 post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field',
3959 3959 :issue => {:priority_id => '',
3960 3960 :assigned_to_id => '',
3961 3961 :custom_field_values => {'2' => '777'}}
3962 3962
3963 3963 assert_response 302
3964 3964
3965 3965 issue = Issue.find(1)
3966 3966 journal = issue.journals.reorder('created_on DESC').first
3967 3967 assert_equal '777', issue.custom_value_for(2).value
3968 3968 assert_equal 1, journal.details.size
3969 3969 assert_equal '125', journal.details.first.old_value
3970 3970 assert_equal '777', journal.details.first.value
3971 3971 end
3972 3972
3973 3973 def test_bulk_update_custom_field_to_blank
3974 3974 @request.session[:user_id] = 2
3975 3975 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field',
3976 3976 :issue => {:priority_id => '',
3977 3977 :assigned_to_id => '',
3978 3978 :custom_field_values => {'1' => '__none__'}}
3979 3979 assert_response 302
3980 3980 assert_equal '', Issue.find(1).custom_field_value(1)
3981 3981 assert_equal '', Issue.find(3).custom_field_value(1)
3982 3982 end
3983 3983
3984 3984 def test_bulk_update_multi_custom_field
3985 3985 field = CustomField.find(1)
3986 3986 field.update_attribute :multiple, true
3987 3987
3988 3988 @request.session[:user_id] = 2
3989 3989 post :bulk_update, :ids => [1, 2, 3], :notes => 'Bulk editing multi custom field',
3990 3990 :issue => {:priority_id => '',
3991 3991 :assigned_to_id => '',
3992 3992 :custom_field_values => {'1' => ['MySQL', 'Oracle']}}
3993 3993
3994 3994 assert_response 302
3995 3995
3996 3996 assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort
3997 3997 assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort
3998 3998 # the custom field is not associated with the issue tracker
3999 3999 assert_nil Issue.find(2).custom_field_value(1)
4000 4000 end
4001 4001
4002 4002 def test_bulk_update_multi_custom_field_to_blank
4003 4003 field = CustomField.find(1)
4004 4004 field.update_attribute :multiple, true
4005 4005
4006 4006 @request.session[:user_id] = 2
4007 4007 post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field',
4008 4008 :issue => {:priority_id => '',
4009 4009 :assigned_to_id => '',
4010 4010 :custom_field_values => {'1' => ['__none__']}}
4011 4011 assert_response 302
4012 4012 assert_equal [''], Issue.find(1).custom_field_value(1)
4013 4013 assert_equal [''], Issue.find(3).custom_field_value(1)
4014 4014 end
4015 4015
4016 4016 def test_bulk_update_unassign
4017 4017 assert_not_nil Issue.find(2).assigned_to
4018 4018 @request.session[:user_id] = 2
4019 4019 # unassign issues
4020 4020 post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
4021 4021 assert_response 302
4022 4022 # check that the issues were updated
4023 4023 assert_nil Issue.find(2).assigned_to
4024 4024 end
4025 4025
4026 4026 def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject
4027 4027 @request.session[:user_id] = 2
4028 4028
4029 4029 post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4}
4030 4030
4031 4031 assert_response :redirect
4032 4032 issues = Issue.find([1,2])
4033 4033 issues.each do |issue|
4034 4034 assert_equal 4, issue.fixed_version_id
4035 4035 assert_not_equal issue.project_id, issue.fixed_version.project_id
4036 4036 end
4037 4037 end
4038 4038
4039 4039 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
4040 4040 @request.session[:user_id] = 2
4041 4041 post :bulk_update, :ids => [1,2], :back_url => '/issues'
4042 4042
4043 4043 assert_response :redirect
4044 4044 assert_redirected_to '/issues'
4045 4045 end
4046 4046
4047 4047 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
4048 4048 @request.session[:user_id] = 2
4049 4049 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
4050 4050
4051 4051 assert_response :redirect
4052 4052 assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
4053 4053 end
4054 4054
4055 4055 def test_bulk_update_with_all_failures_should_show_errors
4056 4056 @request.session[:user_id] = 2
4057 4057 post :bulk_update, :ids => [1, 2], :issue => {:start_date => 'foo'}
4058 4058
4059 4059 assert_response :success
4060 4060 assert_template 'bulk_edit'
4061 4061 assert_select '#errorExplanation span', :text => 'Failed to save 2 issue(s) on 2 selected: #1, #2.'
4062 4062 assert_select '#errorExplanation ul li', :text => 'Start date is not a valid date: #1, #2'
4063 4063
4064 4064 assert_equal [1, 2], assigns[:issues].map(&:id)
4065 4065 end
4066 4066
4067 4067 def test_bulk_update_with_some_failures_should_show_errors
4068 4068 issue1 = Issue.generate!(:start_date => '2013-05-12')
4069 4069 issue2 = Issue.generate!(:start_date => '2013-05-15')
4070 4070 issue3 = Issue.generate!
4071 4071 @request.session[:user_id] = 2
4072 4072 post :bulk_update, :ids => [issue1.id, issue2.id, issue3.id],
4073 4073 :issue => {:due_date => '2013-05-01'}
4074 4074 assert_response :success
4075 4075 assert_template 'bulk_edit'
4076 4076 assert_select '#errorExplanation span',
4077 4077 :text => "Failed to save 2 issue(s) on 3 selected: ##{issue1.id}, ##{issue2.id}."
4078 4078 assert_select '#errorExplanation ul li',
4079 4079 :text => "Due date must be greater than start date: ##{issue1.id}, ##{issue2.id}"
4080 4080 assert_equal [issue1.id, issue2.id], assigns[:issues].map(&:id)
4081 4081 end
4082 4082
4083 4083 def test_bulk_update_with_failure_should_preserved_form_values
4084 4084 @request.session[:user_id] = 2
4085 4085 post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2', :start_date => 'foo'}
4086 4086
4087 4087 assert_response :success
4088 4088 assert_template 'bulk_edit'
4089 4089 assert_select 'select[name=?]', 'issue[tracker_id]' do
4090 4090 assert_select 'option[value="2"][selected=selected]'
4091 4091 end
4092 4092 assert_select 'input[name=?][value=?]', 'issue[start_date]', 'foo'
4093 4093 end
4094 4094
4095 4095 def test_get_bulk_copy
4096 4096 @request.session[:user_id] = 2
4097 4097 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
4098 4098 assert_response :success
4099 4099 assert_template 'bulk_edit'
4100 4100
4101 4101 issues = assigns(:issues)
4102 4102 assert_not_nil issues
4103 4103 assert_equal [1, 2, 3], issues.map(&:id).sort
4104 4104
4105 4105 assert_select 'select[name=?]', 'issue[project_id]' do
4106 4106 assert_select 'option[value=""]'
4107 4107 end
4108 4108 assert_select 'input[name=copy_attachments]'
4109 4109 end
4110 4110
4111 4111 def test_get_bulk_copy_without_add_issues_permission_should_not_propose_current_project_as_target
4112 4112 user = setup_user_with_copy_but_not_add_permission
4113 4113 @request.session[:user_id] = user.id
4114 4114
4115 4115 get :bulk_edit, :ids => [1, 2, 3], :copy => '1'
4116 4116 assert_response :success
4117 4117 assert_template 'bulk_edit'
4118 4118
4119 4119 assert_select 'select[name=?]', 'issue[project_id]' do
4120 4120 assert_select 'option[value=""]', 0
4121 4121 assert_select 'option[value="2"]'
4122 4122 end
4123 4123 end
4124 4124
4125 4125 def test_bulk_copy_to_another_project
4126 4126 @request.session[:user_id] = 2
4127 4127 assert_difference 'Issue.count', 2 do
4128 4128 assert_no_difference 'Project.find(1).issues.count' do
4129 4129 post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}, :copy => '1'
4130 4130 end
4131 4131 end
4132 4132 assert_redirected_to '/projects/ecookbook/issues'
4133 4133
4134 4134 copies = Issue.order('id DESC').limit(issues.size)
4135 4135 copies.each do |copy|
4136 4136 assert_equal 2, copy.project_id
4137 4137 end
4138 4138 end
4139 4139
4140 4140 def test_bulk_copy_without_add_issues_permission_should_be_allowed_on_project_with_permission
4141 4141 user = setup_user_with_copy_but_not_add_permission
4142 4142 @request.session[:user_id] = user.id
4143 4143
4144 4144 assert_difference 'Issue.count', 3 do
4145 4145 post :bulk_update, :ids => [1, 2, 3], :issue => {:project_id => '2'}, :copy => '1'
4146 4146 assert_response 302
4147 4147 end
4148 4148 end
4149 4149
4150 4150 def test_bulk_copy_on_same_project_without_add_issues_permission_should_be_denied
4151 4151 user = setup_user_with_copy_but_not_add_permission
4152 4152 @request.session[:user_id] = user.id
4153 4153
4154 4154 post :bulk_update, :ids => [1, 2, 3], :issue => {:project_id => ''}, :copy => '1'
4155 4155 assert_response 403
4156 4156 end
4157 4157
4158 4158 def test_bulk_copy_on_different_project_without_add_issues_permission_should_be_denied
4159 4159 user = setup_user_with_copy_but_not_add_permission
4160 4160 @request.session[:user_id] = user.id
4161 4161
4162 4162 post :bulk_update, :ids => [1, 2, 3], :issue => {:project_id => '1'}, :copy => '1'
4163 4163 assert_response 403
4164 4164 end
4165 4165
4166 4166 def test_bulk_copy_should_allow_not_changing_the_issue_attributes
4167 4167 @request.session[:user_id] = 2
4168 4168 issues = [
4169 4169 Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1,
4170 4170 :priority_id => 2, :subject => 'issue 1', :author_id => 1,
4171 4171 :assigned_to_id => nil),
4172 4172 Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2,
4173 4173 :priority_id => 1, :subject => 'issue 2', :author_id => 2,
4174 4174 :assigned_to_id => 3)
4175 4175 ]
4176 4176 assert_difference 'Issue.count', issues.size do
4177 4177 post :bulk_update, :ids => issues.map(&:id), :copy => '1',
4178 4178 :issue => {
4179 4179 :project_id => '', :tracker_id => '', :assigned_to_id => '',
4180 4180 :status_id => '', :start_date => '', :due_date => ''
4181 4181 }
4182 4182 end
4183 4183
4184 4184 copies = Issue.order('id DESC').limit(issues.size)
4185 4185 issues.each do |orig|
4186 4186 copy = copies.detect {|c| c.subject == orig.subject}
4187 4187 assert_not_nil copy
4188 4188 assert_equal orig.project_id, copy.project_id
4189 4189 assert_equal orig.tracker_id, copy.tracker_id
4190 4190 assert_equal orig.status_id, copy.status_id
4191 4191 assert_equal orig.assigned_to_id, copy.assigned_to_id
4192 4192 assert_equal orig.priority_id, copy.priority_id
4193 4193 end
4194 4194 end
4195 4195
4196 4196 def test_bulk_copy_should_allow_changing_the_issue_attributes
4197 4197 # Fixes random test failure with Mysql
4198 4198 # where Issue.where(:project_id => 2).limit(2).order('id desc')
4199 4199 # doesn't return the expected results
4200 4200 Issue.delete_all("project_id=2")
4201 4201
4202 4202 @request.session[:user_id] = 2
4203 4203 assert_difference 'Issue.count', 2 do
4204 4204 assert_no_difference 'Project.find(1).issues.count' do
4205 4205 post :bulk_update, :ids => [1, 2], :copy => '1',
4206 4206 :issue => {
4207 4207 :project_id => '2', :tracker_id => '', :assigned_to_id => '4',
4208 4208 :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
4209 4209 }
4210 4210 end
4211 4211 end
4212 4212
4213 4213 copied_issues = Issue.where(:project_id => 2).limit(2).order('id desc').to_a
4214 4214 assert_equal 2, copied_issues.size
4215 4215 copied_issues.each do |issue|
4216 4216 assert_equal 2, issue.project_id, "Project is incorrect"
4217 4217 assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect"
4218 4218 assert_equal 1, issue.status_id, "Status is incorrect"
4219 4219 assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect"
4220 4220 assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect"
4221 4221 end
4222 4222 end
4223 4223
4224 4224 def test_bulk_copy_should_allow_adding_a_note
4225 4225 @request.session[:user_id] = 2
4226 4226 assert_difference 'Issue.count', 1 do
4227 4227 post :bulk_update, :ids => [1], :copy => '1',
4228 4228 :notes => 'Copying one issue',
4229 4229 :issue => {
4230 4230 :project_id => '', :tracker_id => '', :assigned_to_id => '4',
4231 4231 :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
4232 4232 }
4233 4233 end
4234 4234 issue = Issue.order('id DESC').first
4235 4235 assert_equal 1, issue.journals.size
4236 4236 journal = issue.journals.first
4237 4237 assert_equal 'Copying one issue', journal.notes
4238 4238 end
4239 4239
4240 4240 def test_bulk_copy_should_allow_not_copying_the_attachments
4241 4241 attachment_count = Issue.find(3).attachments.size
4242 4242 assert attachment_count > 0
4243 4243 @request.session[:user_id] = 2
4244 4244
4245 4245 assert_difference 'Issue.count', 1 do
4246 4246 assert_no_difference 'Attachment.count' do
4247 4247 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '0',
4248 4248 :issue => {
4249 4249 :project_id => ''
4250 4250 }
4251 4251 end
4252 4252 end
4253 4253 end
4254 4254
4255 4255 def test_bulk_copy_should_allow_copying_the_attachments
4256 4256 attachment_count = Issue.find(3).attachments.size
4257 4257 assert attachment_count > 0
4258 4258 @request.session[:user_id] = 2
4259 4259
4260 4260 assert_difference 'Issue.count', 1 do
4261 4261 assert_difference 'Attachment.count', attachment_count do
4262 4262 post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1',
4263 4263 :issue => {
4264 4264 :project_id => ''
4265 4265 }
4266 4266 end
4267 4267 end
4268 4268 end
4269 4269
4270 4270 def test_bulk_copy_should_add_relations_with_copied_issues
4271 4271 @request.session[:user_id] = 2
4272 4272
4273 4273 assert_difference 'Issue.count', 2 do
4274 4274 assert_difference 'IssueRelation.count', 2 do
4275 4275 post :bulk_update, :ids => [1, 3], :copy => '1', :link_copy => '1',
4276 4276 :issue => {
4277 4277 :project_id => '1'
4278 4278 }
4279 4279 end
4280 4280 end
4281 4281 end
4282 4282
4283 4283 def test_bulk_copy_should_allow_not_copying_the_subtasks
4284 4284 issue = Issue.generate_with_descendants!
4285 4285 @request.session[:user_id] = 2
4286 4286
4287 4287 assert_difference 'Issue.count', 1 do
4288 4288 post :bulk_update, :ids => [issue.id], :copy => '1', :copy_subtasks => '0',
4289 4289 :issue => {
4290 4290 :project_id => ''
4291 4291 }
4292 4292 end
4293 4293 end
4294 4294
4295 4295 def test_bulk_copy_should_allow_copying_the_subtasks
4296 4296 issue = Issue.generate_with_descendants!
4297 4297 count = issue.descendants.count
4298 4298 @request.session[:user_id] = 2
4299 4299
4300 4300 assert_difference 'Issue.count', count+1 do
4301 4301 post :bulk_update, :ids => [issue.id], :copy => '1', :copy_subtasks => '1',
4302 4302 :issue => {
4303 4303 :project_id => ''
4304 4304 }
4305 4305 end
4306 4306 copy = Issue.where(:parent_id => nil).order("id DESC").first
4307 4307 assert_equal count, copy.descendants.count
4308 4308 end
4309 4309
4310 4310 def test_bulk_copy_should_not_copy_selected_subtasks_twice
4311 4311 issue = Issue.generate_with_descendants!
4312 4312 count = issue.descendants.count
4313 4313 @request.session[:user_id] = 2
4314 4314
4315 4315 assert_difference 'Issue.count', count+1 do
4316 4316 post :bulk_update, :ids => issue.self_and_descendants.map(&:id), :copy => '1', :copy_subtasks => '1',
4317 4317 :issue => {
4318 4318 :project_id => ''
4319 4319 }
4320 4320 end
4321 4321 copy = Issue.where(:parent_id => nil).order("id DESC").first
4322 4322 assert_equal count, copy.descendants.count
4323 4323 end
4324 4324
4325 4325 def test_bulk_copy_to_another_project_should_follow_when_needed
4326 4326 @request.session[:user_id] = 2
4327 4327 post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
4328 4328 issue = Issue.order('id DESC').first
4329 4329 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
4330 4330 end
4331 4331
4332 4332 def test_bulk_copy_with_all_failures_should_display_errors
4333 4333 @request.session[:user_id] = 2
4334 4334 post :bulk_update, :ids => [1, 2], :copy => '1', :issue => {:start_date => 'foo'}
4335 4335
4336 4336 assert_response :success
4337 4337 end
4338 4338
4339 4339 def test_destroy_issue_with_no_time_entries
4340 4340 assert_nil TimeEntry.find_by_issue_id(2)
4341 4341 @request.session[:user_id] = 2
4342 4342
4343 4343 assert_difference 'Issue.count', -1 do
4344 4344 delete :destroy, :id => 2
4345 4345 end
4346 4346 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
4347 4347 assert_nil Issue.find_by_id(2)
4348 4348 end
4349 4349
4350 4350 def test_destroy_issues_with_time_entries
4351 4351 @request.session[:user_id] = 2
4352 4352
4353 4353 assert_no_difference 'Issue.count' do
4354 4354 delete :destroy, :ids => [1, 3]
4355 4355 end
4356 4356 assert_response :success
4357 4357 assert_template 'destroy'
4358 4358 assert_not_nil assigns(:hours)
4359 4359 assert Issue.find_by_id(1) && Issue.find_by_id(3)
4360 4360
4361 4361 assert_select 'form' do
4362 4362 assert_select 'input[name=_method][value=delete]'
4363 4363 end
4364 4364 end
4365 4365
4366 4366 def test_destroy_issues_and_destroy_time_entries
4367 4367 @request.session[:user_id] = 2
4368 4368
4369 4369 assert_difference 'Issue.count', -2 do
4370 4370 assert_difference 'TimeEntry.count', -3 do
4371 4371 delete :destroy, :ids => [1, 3], :todo => 'destroy'
4372 4372 end
4373 4373 end
4374 4374 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
4375 4375 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
4376 4376 assert_nil TimeEntry.find_by_id([1, 2])
4377 4377 end
4378 4378
4379 4379 def test_destroy_issues_and_assign_time_entries_to_project
4380 4380 @request.session[:user_id] = 2
4381 4381
4382 4382 assert_difference 'Issue.count', -2 do
4383 4383 assert_no_difference 'TimeEntry.count' do
4384 4384 delete :destroy, :ids => [1, 3], :todo => 'nullify'
4385 4385 end
4386 4386 end
4387 4387 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
4388 4388 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
4389 4389 assert_nil TimeEntry.find(1).issue_id
4390 4390 assert_nil TimeEntry.find(2).issue_id
4391 4391 end
4392 4392
4393 4393 def test_destroy_issues_and_reassign_time_entries_to_another_issue
4394 4394 @request.session[:user_id] = 2
4395 4395
4396 4396 assert_difference 'Issue.count', -2 do
4397 4397 assert_no_difference 'TimeEntry.count' do
4398 4398 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
4399 4399 end
4400 4400 end
4401 4401 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
4402 4402 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
4403 4403 assert_equal 2, TimeEntry.find(1).issue_id
4404 4404 assert_equal 2, TimeEntry.find(2).issue_id
4405 4405 end
4406 4406
4407 4407 def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
4408 4408 @request.session[:user_id] = 2
4409 4409
4410 4410 assert_no_difference 'Issue.count' do
4411 4411 assert_no_difference 'TimeEntry.count' do
4412 4412 # try to reassign time to an issue of another project
4413 4413 delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 4
4414 4414 end
4415 4415 end
4416 4416 assert_response :success
4417 4417 assert_template 'destroy'
4418 4418 end
4419 4419
4420 4420 def test_destroy_issues_from_different_projects
4421 4421 @request.session[:user_id] = 2
4422 4422
4423 4423 assert_difference 'Issue.count', -3 do
4424 4424 delete :destroy, :ids => [1, 2, 6], :todo => 'destroy'
4425 4425 end
4426 4426 assert_redirected_to :controller => 'issues', :action => 'index'
4427 4427 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
4428 4428 end
4429 4429
4430 4430 def test_destroy_parent_and_child_issues
4431 4431 parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue')
4432 4432 child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id)
4433 4433 assert child.is_descendant_of?(parent.reload)
4434 4434
4435 4435 @request.session[:user_id] = 2
4436 4436 assert_difference 'Issue.count', -2 do
4437 4437 delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy'
4438 4438 end
4439 4439 assert_response 302
4440 4440 end
4441 4441
4442 4442 def test_destroy_invalid_should_respond_with_404
4443 4443 @request.session[:user_id] = 2
4444 4444 assert_no_difference 'Issue.count' do
4445 4445 delete :destroy, :id => 999
4446 4446 end
4447 4447 assert_response 404
4448 4448 end
4449 4449
4450 4450 def test_default_search_scope
4451 4451 get :index
4452 4452
4453 4453 assert_select 'div#quick-search form' do
4454 4454 assert_select 'input[name=issues][value="1"][type=hidden]'
4455 4455 end
4456 4456 end
4457 4457
4458 4458 def setup_user_with_copy_but_not_add_permission
4459 4459 Role.all.each {|r| r.remove_permission! :add_issues}
4460 4460 Role.find_by_name('Manager').add_permission! :add_issues
4461 4461 user = User.generate!
4462 4462 User.add_to_project(user, Project.find(1), Role.find_by_name('Developer'))
4463 4463 User.add_to_project(user, Project.find(2), Role.find_by_name('Manager'))
4464 4464 user
4465 4465 end
4466 4466 end
@@ -1,322 +1,322
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class IssuesCustomFieldsVisibilityTest < ActionController::TestCase
21 21 tests IssuesController
22 22 fixtures :projects,
23 23 :users, :email_addresses,
24 24 :roles,
25 25 :members,
26 26 :member_roles,
27 27 :issue_statuses,
28 28 :trackers,
29 29 :projects_trackers,
30 30 :enabled_modules,
31 31 :enumerations,
32 32 :workflows
33 33
34 34 def setup
35 35 CustomField.delete_all
36 36 Issue.delete_all
37 37 field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
38 38 @fields = []
39 39 @fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => true)))
40 40 @fields << (@field2 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 2', :visible => false, :role_ids => [1, 2])))
41 41 @fields << (@field3 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 3', :visible => false, :role_ids => [1, 3])))
42 42 @issue = Issue.generate!(
43 43 :author_id => 1,
44 44 :project_id => 1,
45 45 :tracker_id => 1,
46 46 :custom_field_values => {@field1.id => 'Value0', @field2.id => 'Value1', @field3.id => 'Value2'}
47 47 )
48 48
49 49 @user_with_role_on_other_project = User.generate!
50 50 User.add_to_project(@user_with_role_on_other_project, Project.find(2), Role.find(3))
51 51
52 52 @users_to_test = {
53 53 User.find(1) => [@field1, @field2, @field3],
54 54 User.find(3) => [@field1, @field2],
55 55 @user_with_role_on_other_project => [@field1], # should see field1 only on Project 1
56 56 User.generate! => [@field1],
57 57 User.anonymous => [@field1]
58 58 }
59 59
60 60 Member.where(:project_id => 1).each do |member|
61 61 member.destroy unless @users_to_test.keys.include?(member.principal)
62 62 end
63 63 end
64 64
65 65 def test_show_should_show_visible_custom_fields_only
66 66 @users_to_test.each do |user, fields|
67 67 @request.session[:user_id] = user.id
68 68 get :show, :id => @issue.id
69 69 @fields.each_with_index do |field, i|
70 70 if fields.include?(field)
71 assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
71 assert_select '.value', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
72 72 else
73 assert_select 'td', {:text => "Value#{i}", :count => 0}, "User #{user.id} was able to view #{field.name}"
73 assert_select '.value', {:text => "Value#{i}", :count => 0}, "User #{user.id} was able to view #{field.name}"
74 74 end
75 75 end
76 76 end
77 77 end
78 78
79 79 def test_show_should_show_visible_custom_fields_only_in_api
80 80 @users_to_test.each do |user, fields|
81 81 with_settings :rest_api_enabled => '1' do
82 82 get :show, :id => @issue.id, :format => 'xml', :include => 'custom_fields', :key => user.api_key
83 83 end
84 84 @fields.each_with_index do |field, i|
85 85 if fields.include?(field)
86 86 assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} in API"
87 87 else
88 88 assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 0}, "User #{user.id} was not able to view #{field.name} in API"
89 89 end
90 90 end
91 91 end
92 92 end
93 93
94 94 def test_show_should_show_visible_custom_fields_only_in_history
95 95 @issue.init_journal(User.find(1))
96 96 @issue.custom_field_values = {@field1.id => 'NewValue0', @field2.id => 'NewValue1', @field3.id => 'NewValue2'}
97 97 @issue.save!
98 98
99 99 @users_to_test.each do |user, fields|
100 100 @request.session[:user_id] = user.id
101 101 get :show, :id => @issue.id
102 102 @fields.each_with_index do |field, i|
103 103 if fields.include?(field)
104 104 assert_select 'ul.details i', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} change"
105 105 else
106 106 assert_select 'ul.details i', {:text => "Value#{i}", :count => 0}, "User #{user.id} was able to view #{field.name} change"
107 107 end
108 108 end
109 109 end
110 110 end
111 111
112 112 def test_show_should_show_visible_custom_fields_only_in_history_api
113 113 @issue.init_journal(User.find(1))
114 114 @issue.custom_field_values = {@field1.id => 'NewValue0', @field2.id => 'NewValue1', @field3.id => 'NewValue2'}
115 115 @issue.save!
116 116
117 117 @users_to_test.each do |user, fields|
118 118 with_settings :rest_api_enabled => '1' do
119 119 get :show, :id => @issue.id, :format => 'xml', :include => 'journals', :key => user.api_key
120 120 end
121 121 @fields.each_with_index do |field, i|
122 122 if fields.include?(field)
123 123 assert_select 'details old_value', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} change in API"
124 124 else
125 125 assert_select 'details old_value', {:text => "Value#{i}", :count => 0}, "User #{user.id} was able to view #{field.name} change in API"
126 126 end
127 127 end
128 128 end
129 129 end
130 130
131 131 def test_edit_should_show_visible_custom_fields_only
132 132 Role.anonymous.add_permission! :edit_issues
133 133
134 134 @users_to_test.each do |user, fields|
135 135 @request.session[:user_id] = user.id
136 136 get :edit, :id => @issue.id
137 137 @fields.each_with_index do |field, i|
138 138 if fields.include?(field)
139 139 assert_select 'input[value=?]', "Value#{i}", 1, "User #{user.id} was not able to edit #{field.name}"
140 140 else
141 141 assert_select 'input[value=?]', "Value#{i}", 0, "User #{user.id} was able to edit #{field.name}"
142 142 end
143 143 end
144 144 end
145 145 end
146 146
147 147 def test_update_should_update_visible_custom_fields_only
148 148 Role.anonymous.add_permission! :edit_issues
149 149
150 150 @users_to_test.each do |user, fields|
151 151 @request.session[:user_id] = user.id
152 152 put :update, :id => @issue.id,
153 153 :issue => {:custom_field_values => {
154 154 @field1.id.to_s => "User#{user.id}Value0",
155 155 @field2.id.to_s => "User#{user.id}Value1",
156 156 @field3.id.to_s => "User#{user.id}Value2",
157 157 }}
158 158 @issue.reload
159 159 @fields.each_with_index do |field, i|
160 160 if fields.include?(field)
161 161 assert_equal "User#{user.id}Value#{i}", @issue.custom_field_value(field), "User #{user.id} was not able to update #{field.name}"
162 162 else
163 163 assert_not_equal "User#{user.id}Value#{i}", @issue.custom_field_value(field), "User #{user.id} was able to update #{field.name}"
164 164 end
165 165 end
166 166 end
167 167 end
168 168
169 169 def test_index_should_show_visible_custom_fields_only
170 170 @users_to_test.each do |user, fields|
171 171 @request.session[:user_id] = user.id
172 172 get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"})
173 173 @fields.each_with_index do |field, i|
174 174 if fields.include?(field)
175 175 assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
176 176 else
177 177 assert_select 'td', {:text => "Value#{i}", :count => 0}, "User #{user.id} was able to view #{field.name}"
178 178 end
179 179 end
180 180 end
181 181 end
182 182
183 183 def test_index_as_csv_should_show_visible_custom_fields_only
184 184 @users_to_test.each do |user, fields|
185 185 @request.session[:user_id] = user.id
186 186 get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"}), :format => 'csv'
187 187 @fields.each_with_index do |field, i|
188 188 if fields.include?(field)
189 189 assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV"
190 190 else
191 191 assert_not_include "Value#{i}", response.body, "User #{user.id} was able to view #{field.name} in CSV"
192 192 end
193 193 end
194 194 end
195 195 end
196 196
197 197 def test_index_with_partial_custom_field_visibility
198 198 Issue.delete_all
199 199 p1 = Project.generate!
200 200 p2 = Project.generate!
201 201 user = User.generate!
202 202 User.add_to_project(user, p1, Role.where(:id => [1, 3]).to_a)
203 203 User.add_to_project(user, p2, Role.where(:id => 3).to_a)
204 204 Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueA'})
205 205 Issue.generate!(:project => p2, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueB'})
206 206 Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueC'})
207 207
208 208 @request.session[:user_id] = user.id
209 209 get :index, :c => ["subject", "cf_#{@field2.id}"]
210 210 assert_select 'td', :text => 'ValueA'
211 211 assert_select 'td', :text => 'ValueB', :count => 0
212 212 assert_select 'td', :text => 'ValueC'
213 213
214 214 get :index, :sort => "cf_#{@field2.id}"
215 215 # ValueB is not visible to user and ignored while sorting
216 216 assert_equal %w(ValueB ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
217 217
218 218 get :index, :set_filter => '1', "cf_#{@field2.id}" => '*'
219 219 assert_equal %w(ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
220 220
221 221 CustomField.update_all(:field_format => 'list')
222 222 get :index, :group => "cf_#{@field2.id}"
223 223 assert_equal %w(ValueA ValueC), assigns(:issues).map{|i| i.custom_field_value(@field2)}
224 224 end
225 225
226 226 def test_create_should_send_notifications_according_custom_fields_visibility
227 227 # anonymous user is never notified
228 228 users_to_test = @users_to_test.reject {|k,v| k.anonymous?}
229 229
230 230 ActionMailer::Base.deliveries.clear
231 231 @request.session[:user_id] = 1
232 232 with_settings :bcc_recipients => '1' do
233 233 assert_difference 'Issue.count' do
234 234 post :create,
235 235 :project_id => 1,
236 236 :issue => {
237 237 :tracker_id => 1,
238 238 :status_id => 1,
239 239 :subject => 'New issue',
240 240 :priority_id => 5,
241 241 :custom_field_values => {@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'},
242 242 :watcher_user_ids => users_to_test.keys.map(&:id)
243 243 }
244 244 assert_response 302
245 245 end
246 246 end
247 247 assert_equal users_to_test.values.uniq.size, ActionMailer::Base.deliveries.size
248 248 # tests that each user receives 1 email with the custom fields he is allowed to see only
249 249 users_to_test.each do |user, fields|
250 250 mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
251 251 assert_equal 1, mails.size
252 252 mail = mails.first
253 253 @fields.each_with_index do |field, i|
254 254 if fields.include?(field)
255 255 assert_mail_body_match "Value#{i}", mail, "User #{user.id} was not able to view #{field.name} in notification"
256 256 else
257 257 assert_mail_body_no_match "Value#{i}", mail, "User #{user.id} was able to view #{field.name} in notification"
258 258 end
259 259 end
260 260 end
261 261 end
262 262
263 263 def test_update_should_send_notifications_according_custom_fields_visibility
264 264 # anonymous user is never notified
265 265 users_to_test = @users_to_test.reject {|k,v| k.anonymous?}
266 266
267 267 users_to_test.keys.each do |user|
268 268 Watcher.create!(:user => user, :watchable => @issue)
269 269 end
270 270 ActionMailer::Base.deliveries.clear
271 271 @request.session[:user_id] = 1
272 272 with_settings :bcc_recipients => '1' do
273 273 put :update,
274 274 :id => @issue.id,
275 275 :issue => {
276 276 :custom_field_values => {@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
277 277 }
278 278 assert_response 302
279 279 end
280 280 assert_equal users_to_test.values.uniq.size, ActionMailer::Base.deliveries.size
281 281 # tests that each user receives 1 email with the custom fields he is allowed to see only
282 282 users_to_test.each do |user, fields|
283 283 mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
284 284 assert_equal 1, mails.size
285 285 mail = mails.first
286 286 @fields.each_with_index do |field, i|
287 287 if fields.include?(field)
288 288 assert_mail_body_match "Value#{i}", mail, "User #{user.id} was not able to view #{field.name} in notification"
289 289 else
290 290 assert_mail_body_no_match "Value#{i}", mail, "User #{user.id} was able to view #{field.name} in notification"
291 291 end
292 292 end
293 293 end
294 294 end
295 295
296 296 def test_updating_hidden_custom_fields_only_should_not_notifiy_user
297 297 # anonymous user is never notified
298 298 users_to_test = @users_to_test.reject {|k,v| k.anonymous?}
299 299
300 300 users_to_test.keys.each do |user|
301 301 Watcher.create!(:user => user, :watchable => @issue)
302 302 end
303 303 ActionMailer::Base.deliveries.clear
304 304 @request.session[:user_id] = 1
305 305 with_settings :bcc_recipients => '1' do
306 306 put :update,
307 307 :id => @issue.id,
308 308 :issue => {
309 309 :custom_field_values => {@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
310 310 }
311 311 assert_response 302
312 312 end
313 313 users_to_test.each do |user, fields|
314 314 mails = ActionMailer::Base.deliveries.select {|m| m.bcc.include? user.mail}
315 315 if (fields & [@field2, @field3]).any?
316 316 assert_equal 1, mails.size, "User #{user.id} was not notified"
317 317 else
318 318 assert_equal 0, mails.size, "User #{user.id} was notified"
319 319 end
320 320 end
321 321 end
322 322 end
@@ -1,215 +1,218
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class IssuesTest < Redmine::IntegrationTest
21 21 fixtures :projects,
22 22 :users, :email_addresses,
23 23 :roles,
24 24 :members,
25 25 :member_roles,
26 26 :trackers,
27 27 :projects_trackers,
28 28 :enabled_modules,
29 29 :issue_statuses,
30 30 :issues,
31 31 :enumerations,
32 32 :custom_fields,
33 33 :custom_values,
34 34 :custom_fields_trackers,
35 35 :attachments
36 36
37 37 # create an issue
38 38 def test_add_issue
39 39 log_user('jsmith', 'jsmith')
40 40
41 41 get '/projects/ecookbook/issues/new'
42 42 assert_response :success
43 43 assert_template 'issues/new'
44 44
45 45 issue = new_record(Issue) do
46 46 post '/projects/ecookbook/issues',
47 47 :issue => { :tracker_id => "1",
48 48 :start_date => "2006-12-26",
49 49 :priority_id => "4",
50 50 :subject => "new test issue",
51 51 :category_id => "",
52 52 :description => "new issue",
53 53 :done_ratio => "0",
54 54 :due_date => "",
55 55 :assigned_to_id => "" },
56 56 :custom_fields => {'2' => 'Value for field 2'}
57 57 end
58 58 # check redirection
59 59 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
60 60 follow_redirect!
61 61 assert_equal issue, assigns(:issue)
62 62
63 63 # check issue attributes
64 64 assert_equal 'jsmith', issue.author.login
65 65 assert_equal 1, issue.project.id
66 66 assert_equal 1, issue.status.id
67 67 end
68 68
69 69 def test_create_issue_by_anonymous_without_permission_should_fail
70 70 Role.anonymous.remove_permission! :add_issues
71 71
72 72 assert_no_difference 'Issue.count' do
73 73 post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
74 74 end
75 75 assert_response 302
76 76 end
77 77
78 78 def test_create_issue_by_anonymous_with_custom_permission_should_succeed
79 79 Role.anonymous.remove_permission! :add_issues
80 80 Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [3])
81 81
82 82 issue = new_record(Issue) do
83 83 post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
84 84 assert_response 302
85 85 end
86 86 assert_equal User.anonymous, issue.author
87 87 end
88 88
89 89 # add then remove 2 attachments to an issue
90 90 def test_issue_attachments
91 91 log_user('jsmith', 'jsmith')
92 92 set_tmp_attachments_directory
93 93
94 94 attachment = new_record(Attachment) do
95 95 put '/issues/1',
96 96 :notes => 'Some notes',
97 97 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
98 98 assert_redirected_to "/issues/1"
99 99 end
100 100
101 101 assert_equal Issue.find(1), attachment.container
102 102 assert_equal 'testfile.txt', attachment.filename
103 103 assert_equal 'This is an attachment', attachment.description
104 104 # verify the size of the attachment stored in db
105 105 #assert_equal file_data_1.length, attachment.filesize
106 106 # verify that the attachment was written to disk
107 107 assert File.exist?(attachment.diskfile)
108 108
109 109 # remove the attachments
110 110 Issue.find(1).attachments.each(&:destroy)
111 111 assert_equal 0, Issue.find(1).attachments.length
112 112 end
113 113
114 114 def test_other_formats_links_on_index
115 115 get '/projects/ecookbook/issues'
116 116
117 117 %w(Atom PDF CSV).each do |format|
118 118 assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
119 119 end
120 120 end
121 121
122 122 def test_other_formats_links_on_index_without_project_id_in_url
123 123 get '/issues', :project_id => 'ecookbook'
124 124
125 125 %w(Atom PDF CSV).each do |format|
126 126 assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
127 127 end
128 128 end
129 129
130 130 def test_pagination_links_on_index
131 131 with_settings :per_page_options => '2' do
132 132 get '/projects/ecookbook/issues'
133 133
134 134 assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
135 135 end
136 136 end
137 137
138 138 def test_pagination_links_on_index_without_project_id_in_url
139 139 with_settings :per_page_options => '2' do
140 140 get '/issues', :project_id => 'ecookbook'
141 141
142 142 assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
143 143 end
144 144 end
145 145
146 146 def test_issue_with_user_custom_field
147 147 @field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
148 148 Role.anonymous.add_permission! :add_issues, :edit_issues
149 149 users = Project.find(1).users.uniq.sort
150 150 tester = users.first
151 151
152 152 # Issue form
153 153 get '/projects/ecookbook/issues/new'
154 154 assert_response :success
155 155 assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
156 156 assert_select 'option', users.size + 1 # +1 for blank value
157 157 assert_select 'option[value=?]', tester.id.to_s, :text => tester.name
158 158 end
159 159
160 160 # Create issue
161 161 issue = new_record(Issue) do
162 162 post '/projects/ecookbook/issues',
163 163 :issue => {
164 164 :tracker_id => '1',
165 165 :priority_id => '4',
166 166 :subject => 'Issue with user custom field',
167 167 :custom_field_values => {@field.id.to_s => users.first.id.to_s}
168 168 }
169 169 assert_response 302
170 170 end
171 171
172 172 # Issue view
173 173 follow_redirect!
174 assert_select 'th:contains("Tester:") + td', :text => tester.name
174 assert_select ".cf_#{@field.id}" do
175 assert_select '.label', :text => 'Tester:'
176 assert_select '.value', :text => tester.name
177 end
175 178 assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
176 179 assert_select 'option', users.size + 1 # +1 for blank value
177 180 assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
178 181 end
179 182
180 183 new_tester = users[1]
181 184 with_settings :default_language => 'en' do
182 185 # Update issue
183 186 assert_difference 'Journal.count' do
184 187 put "/issues/#{issue.id}",
185 188 :notes => 'Updating custom field',
186 189 :issue => {
187 190 :custom_field_values => {@field.id.to_s => new_tester.id.to_s}
188 191 }
189 192 assert_redirected_to "/issues/#{issue.id}"
190 193 end
191 194 # Issue view
192 195 follow_redirect!
193 196 assert_select 'ul.details li', :text => "Tester changed from #{tester} to #{new_tester}"
194 197 end
195 198 end
196 199
197 200 def test_update_using_invalid_http_verbs
198 201 subject = 'Updated by an invalid http verb'
199 202
200 203 get '/issues/update/1', {:issue => {:subject => subject}}, credentials('jsmith')
201 204 assert_response 404
202 205 assert_not_equal subject, Issue.find(1).subject
203 206
204 207 post '/issues/1', {:issue => {:subject => subject}}, credentials('jsmith')
205 208 assert_response 404
206 209 assert_not_equal subject, Issue.find(1).subject
207 210 end
208 211
209 212 def test_get_watch_should_be_invalid
210 213 assert_no_difference 'Watcher.count' do
211 214 get '/watchers/watch?object_type=issue&object_id=1', {}, credentials('jsmith')
212 215 assert_response 404
213 216 end
214 217 end
215 218 end
General Comments 0
You need to be logged in to leave comments. Login now