@@ -1,152 +1,156 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | # |
|
3 | 3 | # Redmine - project management software |
|
4 | 4 | # Copyright (C) 2006-2012 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 CustomFieldsHelper |
|
21 | 21 | |
|
22 | 22 | def custom_fields_tabs |
|
23 | 23 | tabs = [{:name => 'IssueCustomField', :partial => 'custom_fields/index', :label => :label_issue_plural}, |
|
24 | 24 | {:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', :label => :label_spent_time}, |
|
25 | 25 | {:name => 'ProjectCustomField', :partial => 'custom_fields/index', :label => :label_project_plural}, |
|
26 | 26 | {:name => 'VersionCustomField', :partial => 'custom_fields/index', :label => :label_version_plural}, |
|
27 | 27 | {:name => 'UserCustomField', :partial => 'custom_fields/index', :label => :label_user_plural}, |
|
28 | 28 | {:name => 'GroupCustomField', :partial => 'custom_fields/index', :label => :label_group_plural}, |
|
29 | 29 | {:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index', :label => TimeEntryActivity::OptionName}, |
|
30 | 30 | {:name => 'IssuePriorityCustomField', :partial => 'custom_fields/index', :label => IssuePriority::OptionName}, |
|
31 | 31 | {:name => 'DocumentCategoryCustomField', :partial => 'custom_fields/index', :label => DocumentCategory::OptionName} |
|
32 | 32 | ] |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | # Return custom field html tag corresponding to its format |
|
36 | 36 | def custom_field_tag(name, custom_value) |
|
37 | 37 | custom_field = custom_value.custom_field |
|
38 | 38 | field_name = "#{name}[custom_field_values][#{custom_field.id}]" |
|
39 | 39 | field_name << "[]" if custom_field.multiple? |
|
40 | 40 | field_id = "#{name}_custom_field_values_#{custom_field.id}" |
|
41 | 41 | |
|
42 | tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"} | |
|
43 | ||
|
42 | 44 | field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) |
|
43 | 45 | case field_format.try(:edit_as) |
|
44 | 46 | when "date" |
|
45 |
text_field_tag(field_name, custom_value.value, |
|
|
47 | text_field_tag(field_name, custom_value.value, tag_options.merge(:size => 10)) + | |
|
46 | 48 | calendar_for(field_id) |
|
47 | 49 | when "text" |
|
48 |
text_area_tag(field_name, custom_value.value, |
|
|
50 | text_area_tag(field_name, custom_value.value, tag_options.merge(:rows => 3)) | |
|
49 | 51 | when "bool" |
|
50 |
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, |
|
|
52 | hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, tag_options) | |
|
51 | 53 | when "list" |
|
52 | 54 | blank_option = '' |
|
53 | 55 | unless custom_field.multiple? |
|
54 | 56 | if custom_field.is_required? |
|
55 | 57 | unless custom_field.default_value.present? |
|
56 | 58 | blank_option = "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" |
|
57 | 59 | end |
|
58 | 60 | else |
|
59 | 61 | blank_option = '<option></option>' |
|
60 | 62 | end |
|
61 | 63 | end |
|
62 | 64 | s = select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), |
|
63 |
|
|
|
65 | tag_options.merge(:multiple => custom_field.multiple?)) | |
|
64 | 66 | if custom_field.multiple? |
|
65 | 67 | s << hidden_field_tag(field_name, '') |
|
66 | 68 | end |
|
67 | 69 | s |
|
68 | 70 | else |
|
69 |
text_field_tag(field_name, custom_value.value, |
|
|
71 | text_field_tag(field_name, custom_value.value, tag_options) | |
|
70 | 72 | end |
|
71 | 73 | end |
|
72 | 74 | |
|
73 | 75 | # Return custom field label tag |
|
74 | 76 | def custom_field_label_tag(name, custom_value) |
|
75 | 77 | content_tag "label", h(custom_value.custom_field.name) + |
|
76 | 78 | (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>".html_safe : ""), |
|
77 | 79 | :for => "#{name}_custom_field_values_#{custom_value.custom_field.id}" |
|
78 | 80 | end |
|
79 | 81 | |
|
80 | 82 | # Return custom field tag with its label tag |
|
81 | 83 | def custom_field_tag_with_label(name, custom_value) |
|
82 | 84 | custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) |
|
83 | 85 | end |
|
84 | 86 | |
|
85 | 87 | def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil) |
|
86 | 88 | field_name = "#{name}[custom_field_values][#{custom_field.id}]" |
|
87 | 89 | field_name << "[]" if custom_field.multiple? |
|
88 | 90 | field_id = "#{name}_custom_field_values_#{custom_field.id}" |
|
91 | ||
|
92 | tag_options = {:id => field_id, :class => "#{custom_field.field_format}_cf"} | |
|
93 | ||
|
89 | 94 | field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) |
|
90 | 95 | case field_format.try(:edit_as) |
|
91 | 96 | when "date" |
|
92 |
text_field_tag(field_name, '', |
|
|
97 | text_field_tag(field_name, '', tag_options.merge(:size => 10)) + | |
|
93 | 98 | calendar_for(field_id) |
|
94 | 99 | when "text" |
|
95 |
text_area_tag(field_name, '', |
|
|
100 | text_area_tag(field_name, '', tag_options.merge(:rows => 3)) | |
|
96 | 101 | when "bool" |
|
97 | 102 | select_tag(field_name, options_for_select([[l(:label_no_change_option), ''], |
|
98 | 103 | [l(:general_text_yes), '1'], |
|
99 |
[l(:general_text_no), '0']]), |
|
|
104 | [l(:general_text_no), '0']]), tag_options) | |
|
100 | 105 | when "list" |
|
101 | 106 | options = [] |
|
102 | 107 | options << [l(:label_no_change_option), ''] unless custom_field.multiple? |
|
103 | 108 | options << [l(:label_none), '__none__'] unless custom_field.is_required? |
|
104 | 109 | options += custom_field.possible_values_options(projects) |
|
105 | select_tag(field_name, options_for_select(options), | |
|
106 | :id => field_id, :multiple => custom_field.multiple?) | |
|
110 | select_tag(field_name, options_for_select(options), tag_options.merge(:multiple => custom_field.multiple?)) | |
|
107 | 111 | else |
|
108 |
text_field_tag(field_name, '', |
|
|
112 | text_field_tag(field_name, '', tag_options) | |
|
109 | 113 | end |
|
110 | 114 | end |
|
111 | 115 | |
|
112 | 116 | # Return a string used to display a custom value |
|
113 | 117 | def show_value(custom_value) |
|
114 | 118 | return "" unless custom_value |
|
115 | 119 | format_value(custom_value.value, custom_value.custom_field.field_format) |
|
116 | 120 | end |
|
117 | 121 | |
|
118 | 122 | # Return a string used to display a custom value |
|
119 | 123 | def format_value(value, field_format) |
|
120 | 124 | if value.is_a?(Array) |
|
121 | 125 | value.collect {|v| format_value(v, field_format)}.compact.sort.join(', ') |
|
122 | 126 | else |
|
123 | 127 | Redmine::CustomFieldFormat.format_value(value, field_format) |
|
124 | 128 | end |
|
125 | 129 | end |
|
126 | 130 | |
|
127 | 131 | # Return an array of custom field formats which can be used in select_tag |
|
128 | 132 | def custom_field_formats_for_select(custom_field) |
|
129 | 133 | Redmine::CustomFieldFormat.as_select(custom_field.class.customized_class.name) |
|
130 | 134 | end |
|
131 | 135 | |
|
132 | 136 | # Renders the custom_values in api views |
|
133 | 137 | def render_api_custom_values(custom_values, api) |
|
134 | 138 | api.array :custom_fields do |
|
135 | 139 | custom_values.each do |custom_value| |
|
136 | 140 | attrs = {:id => custom_value.custom_field_id, :name => custom_value.custom_field.name} |
|
137 | 141 | attrs.merge!(:multiple => true) if custom_value.custom_field.multiple? |
|
138 | 142 | api.custom_field attrs do |
|
139 | 143 | if custom_value.value.is_a?(Array) |
|
140 | 144 | api.array :value do |
|
141 | 145 | custom_value.value.each do |value| |
|
142 | 146 | api.value value unless value.blank? |
|
143 | 147 | end |
|
144 | 148 | end |
|
145 | 149 | else |
|
146 | 150 | api.value custom_value.value |
|
147 | 151 | end |
|
148 | 152 | end |
|
149 | 153 | end |
|
150 | 154 | end unless custom_values.empty? |
|
151 | 155 | end |
|
152 | 156 | end |
@@ -1,1082 +1,1084 | |||
|
1 | 1 | html {overflow-y:scroll;} |
|
2 | 2 | body { font-family: Verdana, sans-serif; font-size: 12px; color:#484848; margin: 0; padding: 0; min-width: 900px; } |
|
3 | 3 | |
|
4 | 4 | h1, h2, h3, h4 { font-family: "Trebuchet MS", Verdana, sans-serif;} |
|
5 | 5 | h1 {margin:0; padding:0; font-size: 24px;} |
|
6 | 6 | h2, .wiki h1 {font-size: 20px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;} |
|
7 | 7 | h3, .wiki h2 {font-size: 16px;padding: 2px 10px 1px 0px;margin: 0 0 10px 0; border-bottom: 1px solid #bbbbbb; color: #444;} |
|
8 | 8 | h4, .wiki h3 {font-size: 13px;padding: 2px 10px 1px 0px;margin-bottom: 5px; border-bottom: 1px dotted #bbbbbb; color: #444;} |
|
9 | 9 | |
|
10 | 10 | /***** Layout *****/ |
|
11 | 11 | #wrapper {background: white;} |
|
12 | 12 | |
|
13 | 13 | #top-menu {background: #2C4056; color: #fff; height:1.8em; font-size: 0.8em; padding: 2px 2px 0px 6px;} |
|
14 | 14 | #top-menu ul {margin: 0; padding: 0;} |
|
15 | 15 | #top-menu li { |
|
16 | 16 | float:left; |
|
17 | 17 | list-style-type:none; |
|
18 | 18 | margin: 0px 0px 0px 0px; |
|
19 | 19 | padding: 0px 0px 0px 0px; |
|
20 | 20 | white-space:nowrap; |
|
21 | 21 | } |
|
22 | 22 | #top-menu a {color: #fff; margin-right: 8px; font-weight: bold;} |
|
23 | 23 | #top-menu #loggedas { float: right; margin-right: 0.5em; color: #fff; } |
|
24 | 24 | |
|
25 | 25 | #account {float:right;} |
|
26 | 26 | |
|
27 | 27 | #header {height:5.3em;margin:0;background-color:#507AAA;color:#f8f8f8; padding: 4px 8px 0px 6px; position:relative;} |
|
28 | 28 | #header a {color:#f8f8f8;} |
|
29 | 29 | #header h1 a.ancestor { font-size: 80%; } |
|
30 | 30 | #quick-search {float:right;} |
|
31 | 31 | |
|
32 | 32 | #main-menu {position: absolute; bottom: 0px; left:6px; margin-right: -500px;} |
|
33 | 33 | #main-menu ul {margin: 0; padding: 0;} |
|
34 | 34 | #main-menu li { |
|
35 | 35 | float:left; |
|
36 | 36 | list-style-type:none; |
|
37 | 37 | margin: 0px 2px 0px 0px; |
|
38 | 38 | padding: 0px 0px 0px 0px; |
|
39 | 39 | white-space:nowrap; |
|
40 | 40 | } |
|
41 | 41 | #main-menu li a { |
|
42 | 42 | display: block; |
|
43 | 43 | color: #fff; |
|
44 | 44 | text-decoration: none; |
|
45 | 45 | font-weight: bold; |
|
46 | 46 | margin: 0; |
|
47 | 47 | padding: 4px 10px 4px 10px; |
|
48 | 48 | } |
|
49 | 49 | #main-menu li a:hover {background:#759FCF; color:#fff;} |
|
50 | 50 | #main-menu li a.selected, #main-menu li a.selected:hover {background:#fff; color:#555;} |
|
51 | 51 | |
|
52 | 52 | #admin-menu ul {margin: 0; padding: 0;} |
|
53 | 53 | #admin-menu li {margin: 0; padding: 0 0 6px 0; list-style-type:none;} |
|
54 | 54 | |
|
55 | 55 | #admin-menu a { background-position: 0% 40%; background-repeat: no-repeat; padding-left: 20px; padding-top: 2px; padding-bottom: 3px;} |
|
56 | 56 | #admin-menu a.projects { background-image: url(../images/projects.png); } |
|
57 | 57 | #admin-menu a.users { background-image: url(../images/user.png); } |
|
58 | 58 | #admin-menu a.groups { background-image: url(../images/group.png); } |
|
59 | 59 | #admin-menu a.roles { background-image: url(../images/database_key.png); } |
|
60 | 60 | #admin-menu a.trackers { background-image: url(../images/ticket.png); } |
|
61 | 61 | #admin-menu a.issue_statuses { background-image: url(../images/ticket_edit.png); } |
|
62 | 62 | #admin-menu a.workflows { background-image: url(../images/ticket_go.png); } |
|
63 | 63 | #admin-menu a.custom_fields { background-image: url(../images/textfield.png); } |
|
64 | 64 | #admin-menu a.enumerations { background-image: url(../images/text_list_bullets.png); } |
|
65 | 65 | #admin-menu a.settings { background-image: url(../images/changeset.png); } |
|
66 | 66 | #admin-menu a.plugins { background-image: url(../images/plugin.png); } |
|
67 | 67 | #admin-menu a.info { background-image: url(../images/help.png); } |
|
68 | 68 | #admin-menu a.server_authentication { background-image: url(../images/server_key.png); } |
|
69 | 69 | |
|
70 | 70 | #main {background-color:#EEEEEE;} |
|
71 | 71 | |
|
72 | 72 | #sidebar{ float: right; width: 22%; position: relative; z-index: 9; padding: 0; margin: 0;} |
|
73 | 73 | * html #sidebar{ width: 22%; } |
|
74 | 74 | #sidebar h3{ font-size: 14px; margin-top:14px; color: #666; } |
|
75 | 75 | #sidebar hr{ width: 100%; margin: 0 auto; height: 1px; background: #ccc; border: 0; } |
|
76 | 76 | * html #sidebar hr{ width: 95%; position: relative; left: -6px; color: #ccc; } |
|
77 | 77 | #sidebar .contextual { margin-right: 1em; } |
|
78 | 78 | |
|
79 | 79 | #content { width: 75%; background-color: #fff; margin: 0px; border-right: 1px solid #ddd; padding: 6px 10px 10px 10px; z-index: 10; } |
|
80 | 80 | * html #content{ width: 75%; padding-left: 0; margin-top: 0px; padding: 6px 10px 10px 10px;} |
|
81 | 81 | html>body #content { min-height: 600px; } |
|
82 | 82 | * html body #content { height: 600px; } /* IE */ |
|
83 | 83 | |
|
84 | 84 | #main.nosidebar #sidebar{ display: none; } |
|
85 | 85 | #main.nosidebar #content{ width: auto; border-right: 0; } |
|
86 | 86 | |
|
87 | 87 | #footer {clear: both; border-top: 1px solid #bbb; font-size: 0.9em; color: #aaa; padding: 5px; text-align:center; background:#fff;} |
|
88 | 88 | |
|
89 | 89 | #login-form table {margin-top:5em; padding:1em; margin-left: auto; margin-right: auto; border: 2px solid #FDBF3B; background-color:#FFEBC1; } |
|
90 | 90 | #login-form table td {padding: 6px;} |
|
91 | 91 | #login-form label {font-weight: bold;} |
|
92 | 92 | #login-form input#username, #login-form input#password { width: 300px; } |
|
93 | 93 | |
|
94 | 94 | #modalbg {position:absolute; top:0; left:0; width:100%; height:100%; background:#ccc; z-index:49; opacity:0.5;} |
|
95 | 95 | html>body #modalbg {position:fixed;} |
|
96 | 96 | div.modal { border-radius:5px; position:absolute; top:25%; background:#fff; border:2px solid #759FCF; z-index:50; padding:0px; padding:8px; box-shadow: 1px 1px 8px #888; } |
|
97 | 97 | div.modal h3.title {background:#759FCF; color:#fff; border:0; padding-left:8px; margin:-8px; margin-bottom: 1em; border-top-left-radius:2px;border-top-right-radius:2px;} |
|
98 | 98 | div.modal p.buttons {text-align:right; margin-bottom:0;} |
|
99 | 99 | html>body div.modal {position:fixed;} |
|
100 | 100 | |
|
101 | 101 | input#openid_url { background: url(../images/openid-bg.gif) no-repeat; background-color: #fff; background-position: 0 50%; padding-left: 18px; } |
|
102 | 102 | |
|
103 | 103 | .clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; } |
|
104 | 104 | |
|
105 | 105 | /***** Links *****/ |
|
106 | 106 | a, a:link, a:visited{ color: #2A5685; text-decoration: none; } |
|
107 | 107 | a:hover, a:active{ color: #c61a1a; text-decoration: underline;} |
|
108 | 108 | a img{ border: 0; } |
|
109 | 109 | |
|
110 | 110 | a.issue.closed, a.issue.closed:link, a.issue.closed:visited { color: #999; text-decoration: line-through; } |
|
111 | 111 | |
|
112 | 112 | #sidebar a.selected {line-height:1.7em; padding:1px 3px 2px 2px; margin-left:-2px; background-color:#9DB9D5; color:#fff; border-radius:2px; -moz-border-radius:2px;} |
|
113 | 113 | #sidebar a.selected:hover {text-decoration:none;} |
|
114 | 114 | #admin-menu a {line-height:1.7em;} |
|
115 | 115 | #admin-menu a.selected {padding-left: 20px !important; background-position: 2px 40%;} |
|
116 | 116 | |
|
117 | 117 | a.collapsible {padding-left: 12px; background: url(../images/arrow_expanded.png) no-repeat -3px 40%;} |
|
118 | 118 | a.collapsible.collapsed {background: url(../images/arrow_collapsed.png) no-repeat -5px 40%;} |
|
119 | 119 | |
|
120 | 120 | a#toggle-completed-versions {color:#999;} |
|
121 | 121 | /***** Tables *****/ |
|
122 | 122 | table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; } |
|
123 | 123 | table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; } |
|
124 | 124 | table.list td { vertical-align: top; } |
|
125 | 125 | table.list td.id { width: 2%; text-align: center;} |
|
126 | 126 | table.list td.checkbox { width: 15px; padding: 2px 0 0 0; } |
|
127 | 127 | table.list td.checkbox input {padding:0px;} |
|
128 | 128 | table.list td.buttons { width: 15%; white-space:nowrap; text-align: right; } |
|
129 | 129 | table.list td.buttons a { padding-right: 0.6em; } |
|
130 | 130 | table.list caption { text-align: left; padding: 0.5em 0.5em 0.5em 0; } |
|
131 | 131 | |
|
132 | 132 | tr.project td.name a { white-space:nowrap; } |
|
133 | 133 | |
|
134 | 134 | tr.project.idnt td.name span {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%; padding-left: 16px;} |
|
135 | 135 | tr.project.idnt-1 td.name {padding-left: 0.5em;} |
|
136 | 136 | tr.project.idnt-2 td.name {padding-left: 2em;} |
|
137 | 137 | tr.project.idnt-3 td.name {padding-left: 3.5em;} |
|
138 | 138 | tr.project.idnt-4 td.name {padding-left: 5em;} |
|
139 | 139 | tr.project.idnt-5 td.name {padding-left: 6.5em;} |
|
140 | 140 | tr.project.idnt-6 td.name {padding-left: 8em;} |
|
141 | 141 | tr.project.idnt-7 td.name {padding-left: 9.5em;} |
|
142 | 142 | tr.project.idnt-8 td.name {padding-left: 11em;} |
|
143 | 143 | tr.project.idnt-9 td.name {padding-left: 12.5em;} |
|
144 | 144 | |
|
145 | 145 | tr.issue { text-align: center; white-space: nowrap; } |
|
146 | 146 | tr.issue td.subject, tr.issue td.category, td.assigned_to, tr.issue td.string, tr.issue td.text { white-space: normal; } |
|
147 | 147 | tr.issue td.subject { text-align: left; } |
|
148 | 148 | tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;} |
|
149 | 149 | |
|
150 | 150 | tr.issue.idnt td.subject a {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%; padding-left: 16px;} |
|
151 | 151 | tr.issue.idnt-1 td.subject {padding-left: 0.5em;} |
|
152 | 152 | tr.issue.idnt-2 td.subject {padding-left: 2em;} |
|
153 | 153 | tr.issue.idnt-3 td.subject {padding-left: 3.5em;} |
|
154 | 154 | tr.issue.idnt-4 td.subject {padding-left: 5em;} |
|
155 | 155 | tr.issue.idnt-5 td.subject {padding-left: 6.5em;} |
|
156 | 156 | tr.issue.idnt-6 td.subject {padding-left: 8em;} |
|
157 | 157 | tr.issue.idnt-7 td.subject {padding-left: 9.5em;} |
|
158 | 158 | tr.issue.idnt-8 td.subject {padding-left: 11em;} |
|
159 | 159 | tr.issue.idnt-9 td.subject {padding-left: 12.5em;} |
|
160 | 160 | |
|
161 | 161 | tr.entry { border: 1px solid #f8f8f8; } |
|
162 | 162 | tr.entry td { white-space: nowrap; } |
|
163 | 163 | tr.entry td.filename { width: 30%; } |
|
164 | 164 | tr.entry td.filename_no_report { width: 70%; } |
|
165 | 165 | tr.entry td.size { text-align: right; font-size: 90%; } |
|
166 | 166 | tr.entry td.revision, tr.entry td.author { text-align: center; } |
|
167 | 167 | tr.entry td.age { text-align: right; } |
|
168 | 168 | tr.entry.file td.filename a { margin-left: 16px; } |
|
169 | 169 | tr.entry.file td.filename_no_report a { margin-left: 16px; } |
|
170 | 170 | |
|
171 | 171 | tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} |
|
172 | 172 | tr.open span.expander {background-image: url(../images/bullet_toggle_minus.png);} |
|
173 | 173 | |
|
174 | 174 | tr.changeset { height: 20px } |
|
175 | 175 | tr.changeset ul, ol { margin-top: 0px; margin-bottom: 0px; } |
|
176 | 176 | tr.changeset td.revision_graph { width: 15%; background-color: #fffffb; } |
|
177 | 177 | tr.changeset td.author { text-align: center; width: 15%; white-space:nowrap;} |
|
178 | 178 | tr.changeset td.committed_on { text-align: center; width: 15%; white-space:nowrap;} |
|
179 | 179 | |
|
180 | 180 | table.files tr.file td { text-align: center; } |
|
181 | 181 | table.files tr.file td.filename { text-align: left; padding-left: 24px; } |
|
182 | 182 | table.files tr.file td.digest { font-size: 80%; } |
|
183 | 183 | |
|
184 | 184 | table.members td.roles, table.memberships td.roles { width: 45%; } |
|
185 | 185 | |
|
186 | 186 | tr.message { height: 2.6em; } |
|
187 | 187 | tr.message td.subject { padding-left: 20px; } |
|
188 | 188 | tr.message td.created_on { white-space: nowrap; } |
|
189 | 189 | tr.message td.last_message { font-size: 80%; white-space: nowrap; } |
|
190 | 190 | tr.message.locked td.subject { background: url(../images/locked.png) no-repeat 0 1px; } |
|
191 | 191 | tr.message.sticky td.subject { background: url(../images/bullet_go.png) no-repeat 0 1px; font-weight: bold; } |
|
192 | 192 | |
|
193 | 193 | tr.version.closed, tr.version.closed a { color: #999; } |
|
194 | 194 | tr.version td.name { padding-left: 20px; } |
|
195 | 195 | tr.version.shared td.name { background: url(../images/link.png) no-repeat 0% 70%; } |
|
196 | 196 | tr.version td.date, tr.version td.status, tr.version td.sharing { text-align: center; white-space:nowrap; } |
|
197 | 197 | |
|
198 | 198 | tr.user td { width:13%; } |
|
199 | 199 | tr.user td.email { width:18%; } |
|
200 | 200 | tr.user td { white-space: nowrap; } |
|
201 | 201 | tr.user.locked, tr.user.registered { color: #aaa; } |
|
202 | 202 | tr.user.locked a, tr.user.registered a { color: #aaa; } |
|
203 | 203 | |
|
204 | 204 | table.permissions td.role {color:#999;font-size:90%;font-weight:normal !important;text-align:center;vertical-align:bottom;} |
|
205 | 205 | |
|
206 | 206 | tr.wiki-page-version td.updated_on, tr.wiki-page-version td.author {text-align:center;} |
|
207 | 207 | |
|
208 | 208 | tr.time-entry { text-align: center; white-space: nowrap; } |
|
209 | 209 | tr.time-entry td.subject, tr.time-entry td.comments { text-align: left; white-space: normal; } |
|
210 | 210 | td.hours { text-align: right; font-weight: bold; padding-right: 0.5em; } |
|
211 | 211 | td.hours .hours-dec { font-size: 0.9em; } |
|
212 | 212 | |
|
213 | 213 | table.plugins td { vertical-align: middle; } |
|
214 | 214 | table.plugins td.configure { text-align: right; padding-right: 1em; } |
|
215 | 215 | table.plugins span.name { font-weight: bold; display: block; margin-bottom: 6px; } |
|
216 | 216 | table.plugins span.description { display: block; font-size: 0.9em; } |
|
217 | 217 | table.plugins span.url { display: block; font-size: 0.9em; } |
|
218 | 218 | |
|
219 | 219 | table.list tbody tr.group td { padding: 0.8em 0 0.5em 0.3em; font-weight: bold; border-bottom: 1px solid #ccc; } |
|
220 | 220 | table.list tbody tr.group span.count { color: #aaa; font-size: 80%; } |
|
221 | 221 | tr.group a.toggle-all { color: #aaa; font-size: 80%; font-weight: normal; display:none;} |
|
222 | 222 | tr.group:hover a.toggle-all { display:inline;} |
|
223 | 223 | a.toggle-all:hover {text-decoration:none;} |
|
224 | 224 | |
|
225 | 225 | table.list tbody tr:hover { background-color:#ffffdd; } |
|
226 | 226 | table.list tbody tr.group:hover { background-color:inherit; } |
|
227 | 227 | table td {padding:2px;} |
|
228 | 228 | table p {margin:0;} |
|
229 | 229 | .odd {background-color:#f6f7f8;} |
|
230 | 230 | .even {background-color: #fff;} |
|
231 | 231 | |
|
232 | 232 | a.sort { padding-right: 16px; background-position: 100% 50%; background-repeat: no-repeat; } |
|
233 | 233 | a.sort.asc { background-image: url(../images/sort_asc.png); } |
|
234 | 234 | a.sort.desc { background-image: url(../images/sort_desc.png); } |
|
235 | 235 | |
|
236 | 236 | table.attributes { width: 100% } |
|
237 | 237 | table.attributes th { vertical-align: top; text-align: left; } |
|
238 | 238 | table.attributes td { vertical-align: top; } |
|
239 | 239 | |
|
240 | 240 | table.boards a.board, h3.comments { background: url(../images/comment.png) no-repeat 0% 50%; padding-left: 20px; } |
|
241 | 241 | |
|
242 | 242 | table.query-columns { |
|
243 | 243 | border-collapse: collapse; |
|
244 | 244 | border: 0; |
|
245 | 245 | } |
|
246 | 246 | |
|
247 | 247 | table.query-columns td.buttons { |
|
248 | 248 | vertical-align: middle; |
|
249 | 249 | text-align: center; |
|
250 | 250 | } |
|
251 | 251 | |
|
252 | 252 | td.center {text-align:center;} |
|
253 | 253 | |
|
254 | 254 | h3.version { background: url(../images/package.png) no-repeat 0% 50%; padding-left: 20px; } |
|
255 | 255 | |
|
256 | 256 | div.issues h3 { background: url(../images/ticket.png) no-repeat 0% 50%; padding-left: 20px; } |
|
257 | 257 | div.members h3 { background: url(../images/group.png) no-repeat 0% 50%; padding-left: 20px; } |
|
258 | 258 | div.news h3 { background: url(../images/news.png) no-repeat 0% 50%; padding-left: 20px; } |
|
259 | 259 | div.projects h3 { background: url(../images/projects.png) no-repeat 0% 50%; padding-left: 20px; } |
|
260 | 260 | |
|
261 | 261 | #watchers ul {margin: 0; padding: 0;} |
|
262 | 262 | #watchers li {list-style-type:none;margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;} |
|
263 | 263 | #watchers select {width: 95%; display: block;} |
|
264 | 264 | #watchers a.delete {opacity: 0.4;} |
|
265 | 265 | #watchers a.delete:hover {opacity: 1;} |
|
266 | 266 | #watchers img.gravatar {margin: 0 4px 2px 0;} |
|
267 | 267 | |
|
268 | 268 | span#watchers_inputs {overflow:auto; display:block;} |
|
269 | 269 | span.search_for_watchers {display:block;} |
|
270 | 270 | span.search_for_watchers, span.add_attachment {font-size:80%; line-height:2.5em;} |
|
271 | 271 | span.search_for_watchers a, span.add_attachment a {padding-left:16px; background: url(../images/bullet_add.png) no-repeat 0 50%; } |
|
272 | 272 | |
|
273 | 273 | |
|
274 | 274 | .highlight { background-color: #FCFD8D;} |
|
275 | 275 | .highlight.token-1 { background-color: #faa;} |
|
276 | 276 | .highlight.token-2 { background-color: #afa;} |
|
277 | 277 | .highlight.token-3 { background-color: #aaf;} |
|
278 | 278 | |
|
279 | 279 | .box{ |
|
280 | 280 | padding:6px; |
|
281 | 281 | margin-bottom: 10px; |
|
282 | 282 | background-color:#f6f6f6; |
|
283 | 283 | color:#505050; |
|
284 | 284 | line-height:1.5em; |
|
285 | 285 | border: 1px solid #e4e4e4; |
|
286 | 286 | } |
|
287 | 287 | |
|
288 | 288 | div.square { |
|
289 | 289 | border: 1px solid #999; |
|
290 | 290 | float: left; |
|
291 | 291 | margin: .3em .4em 0 .4em; |
|
292 | 292 | overflow: hidden; |
|
293 | 293 | width: .6em; height: .6em; |
|
294 | 294 | } |
|
295 | 295 | .contextual {float:right; white-space: nowrap; line-height:1.4em;margin-top:5px; padding-left: 10px; font-size:0.9em;} |
|
296 | 296 | .contextual input, .contextual select {font-size:0.9em;} |
|
297 | 297 | .message .contextual { margin-top: 0; } |
|
298 | 298 | |
|
299 | 299 | .splitcontent {overflow:auto;} |
|
300 | 300 | .splitcontentleft{float:left; width:49%;} |
|
301 | 301 | .splitcontentright{float:right; width:49%;} |
|
302 | 302 | form {display: inline;} |
|
303 | 303 | input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;} |
|
304 | 304 | fieldset {border: 1px solid #e4e4e4; margin:0;} |
|
305 | 305 | legend {color: #484848;} |
|
306 | 306 | hr { width: 100%; height: 1px; background: #ccc; border: 0;} |
|
307 | 307 | blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0.6em; margin-left: 2.4em;} |
|
308 | 308 | blockquote blockquote { margin-left: 0;} |
|
309 | 309 | acronym { border-bottom: 1px dotted; cursor: help; } |
|
310 | 310 | textarea.wiki-edit { width: 99%; } |
|
311 | 311 | li p {margin-top: 0;} |
|
312 | 312 | div.issue {background:#ffffdd; padding:6px; margin-bottom:6px;border: 1px solid #d7d7d7;} |
|
313 | 313 | p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;} |
|
314 | 314 | p.subtitle { font-size: 0.9em; margin: -6px 0 12px 0; font-style: italic; } |
|
315 | 315 | p.footnote { font-size: 0.9em; margin-top: 0px; margin-bottom: 0px; } |
|
316 | 316 | |
|
317 | 317 | div.issue div.subject div div { padding-left: 16px; } |
|
318 | 318 | div.issue div.subject p {margin: 0; margin-bottom: 0.1em; font-size: 90%; color: #999;} |
|
319 | 319 | div.issue div.subject>div>p { margin-top: 0.5em; } |
|
320 | 320 | div.issue div.subject h3 {margin: 0; margin-bottom: 0.1em;} |
|
321 | 321 | div.issue 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; -moz-border-radius: 2px;} |
|
322 | 322 | div.issue .next-prev-links {color:#999;} |
|
323 | 323 | div.issue table.attributes th {width:22%;} |
|
324 | 324 | div.issue table.attributes td {width:28%;} |
|
325 | 325 | |
|
326 | 326 | #issue_tree table.issues, #relations table.issues { border: 0; } |
|
327 | 327 | #issue_tree td.checkbox, #relations td.checkbox {display:none;} |
|
328 | 328 | #relations td.buttons {padding:0;} |
|
329 | 329 | |
|
330 | 330 | fieldset.collapsible { border-width: 1px 0 0 0; font-size: 0.9em; } |
|
331 | 331 | fieldset.collapsible legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; } |
|
332 | 332 | fieldset.collapsible.collapsed legend { background-image: url(../images/arrow_collapsed.png); } |
|
333 | 333 | |
|
334 | 334 | fieldset#date-range p { margin: 2px 0 2px 0; } |
|
335 | 335 | fieldset#filters table { border-collapse: collapse; } |
|
336 | 336 | fieldset#filters table td { padding: 0; vertical-align: middle; } |
|
337 | 337 | fieldset#filters tr.filter { height: 2em; } |
|
338 | 338 | fieldset#filters td.field { width:200px; } |
|
339 | 339 | fieldset#filters td.operator { width:170px; } |
|
340 | 340 | fieldset#filters td.values { white-space:nowrap; } |
|
341 | 341 | fieldset#filters td.values select {min-width:130px;} |
|
342 | 342 | fieldset#filters td.values img { vertical-align: middle; margin-left:1px; } |
|
343 | 343 | fieldset#filters td.add-filter { text-align: right; vertical-align: top; } |
|
344 | 344 | .buttons { font-size: 0.9em; margin-bottom: 1.4em; margin-top: 1em; } |
|
345 | 345 | |
|
346 | 346 | div#issue-changesets {float:right; width:45%; margin-left: 1em; margin-bottom: 1em; background: #fff; padding-left: 1em; font-size: 90%;} |
|
347 | 347 | div#issue-changesets div.changeset { padding: 4px;} |
|
348 | 348 | div#issue-changesets div.changeset { border-bottom: 1px solid #ddd; } |
|
349 | 349 | div#issue-changesets p { margin-top: 0; margin-bottom: 1em;} |
|
350 | 350 | |
|
351 | 351 | .journal ul.details img {margin:0 0 -3px 4px;} |
|
352 | 352 | |
|
353 | 353 | div#activity dl, #search-results { margin-left: 2em; } |
|
354 | 354 | div#activity dd, #search-results dd { margin-bottom: 1em; padding-left: 18px; font-size: 0.9em; } |
|
355 | 355 | div#activity dt, #search-results dt { margin-bottom: 0px; padding-left: 20px; line-height: 18px; background-position: 0 50%; background-repeat: no-repeat; } |
|
356 | 356 | div#activity dt.me .time { border-bottom: 1px solid #999; } |
|
357 | 357 | div#activity dt .time { color: #777; font-size: 80%; } |
|
358 | 358 | div#activity dd .description, #search-results dd .description { font-style: italic; } |
|
359 | 359 | div#activity span.project:after, #search-results span.project:after { content: " -"; } |
|
360 | 360 | div#activity dd span.description, #search-results dd span.description { display:block; color: #808080; } |
|
361 | 361 | |
|
362 | 362 | #search-results dd { margin-bottom: 1em; padding-left: 20px; margin-left:0px; } |
|
363 | 363 | |
|
364 | 364 | div#search-results-counts {float:right;} |
|
365 | 365 | div#search-results-counts ul { margin-top: 0.5em; } |
|
366 | 366 | div#search-results-counts li { list-style-type:none; float: left; margin-left: 1em; } |
|
367 | 367 | |
|
368 | 368 | dt.issue { background-image: url(../images/ticket.png); } |
|
369 | 369 | dt.issue-edit { background-image: url(../images/ticket_edit.png); } |
|
370 | 370 | dt.issue-closed { background-image: url(../images/ticket_checked.png); } |
|
371 | 371 | dt.issue-note { background-image: url(../images/ticket_note.png); } |
|
372 | 372 | dt.changeset { background-image: url(../images/changeset.png); } |
|
373 | 373 | dt.news { background-image: url(../images/news.png); } |
|
374 | 374 | dt.message { background-image: url(../images/message.png); } |
|
375 | 375 | dt.reply { background-image: url(../images/comments.png); } |
|
376 | 376 | dt.wiki-page { background-image: url(../images/wiki_edit.png); } |
|
377 | 377 | dt.attachment { background-image: url(../images/attachment.png); } |
|
378 | 378 | dt.document { background-image: url(../images/document.png); } |
|
379 | 379 | dt.project { background-image: url(../images/projects.png); } |
|
380 | 380 | dt.time-entry { background-image: url(../images/time.png); } |
|
381 | 381 | |
|
382 | 382 | #search-results dt.issue.closed { background-image: url(../images/ticket_checked.png); } |
|
383 | 383 | |
|
384 | 384 | div#roadmap .related-issues { margin-bottom: 1em; } |
|
385 | 385 | div#roadmap .related-issues td.checkbox { display: none; } |
|
386 | 386 | div#roadmap .wiki h1:first-child { display: none; } |
|
387 | 387 | div#roadmap .wiki h1 { font-size: 120%; } |
|
388 | 388 | div#roadmap .wiki h2 { font-size: 110%; } |
|
389 | 389 | body.controller-versions.action-show div#roadmap .related-issues {width:70%;} |
|
390 | 390 | |
|
391 | 391 | div#version-summary { float:right; width:28%; margin-left: 16px; margin-bottom: 16px; background-color: #fff; } |
|
392 | 392 | div#version-summary fieldset { margin-bottom: 1em; } |
|
393 | 393 | div#version-summary fieldset.time-tracking table { width:100%; } |
|
394 | 394 | div#version-summary th, div#version-summary td.total-hours { text-align: right; } |
|
395 | 395 | |
|
396 | 396 | table#time-report td.hours, table#time-report th.period, table#time-report th.total { text-align: right; padding-right: 0.5em; } |
|
397 | 397 | table#time-report tbody tr.subtotal { font-style: italic; color:#777;} |
|
398 | 398 | table#time-report tbody tr.subtotal td.hours { color:#b0b0b0; } |
|
399 | 399 | table#time-report tbody tr.total { font-weight: bold; background-color:#EEEEEE; border-top:1px solid #e4e4e4;} |
|
400 | 400 | table#time-report .hours-dec { font-size: 0.9em; } |
|
401 | 401 | |
|
402 | 402 | div.wiki-page .contextual a {opacity: 0.4} |
|
403 | 403 | div.wiki-page .contextual a:hover {opacity: 1} |
|
404 | 404 | |
|
405 | 405 | form .attributes select { width: 60%; } |
|
406 | 406 | input#issue_subject { width: 99%; } |
|
407 | 407 | select#issue_done_ratio { width: 95px; } |
|
408 | 408 | |
|
409 | 409 | ul.projects { margin: 0; padding-left: 1em; } |
|
410 | 410 | ul.projects.root { margin: 0; padding: 0; } |
|
411 | 411 | ul.projects ul.projects { border-left: 3px solid #e0e0e0; } |
|
412 | 412 | ul.projects li.root { list-style-type:none; margin-bottom: 1em; } |
|
413 | 413 | ul.projects li.child { list-style-type:none; margin-top: 1em;} |
|
414 | 414 | ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 16px; margin: 0 0 10px 0; } |
|
415 | 415 | .my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; } |
|
416 | 416 | |
|
417 | 417 | #tracker_project_ids ul { margin: 0; padding-left: 1em; } |
|
418 | 418 | #tracker_project_ids li { list-style-type:none; } |
|
419 | 419 | |
|
420 | 420 | #related-issues li img {vertical-align:middle;} |
|
421 | 421 | |
|
422 | 422 | ul.properties {padding:0; font-size: 0.9em; color: #777;} |
|
423 | 423 | ul.properties li {list-style-type:none;} |
|
424 | 424 | ul.properties li span {font-style:italic;} |
|
425 | 425 | |
|
426 | 426 | .total-hours { font-size: 110%; font-weight: bold; } |
|
427 | 427 | .total-hours span.hours-int { font-size: 120%; } |
|
428 | 428 | |
|
429 | 429 | .autoscroll {overflow-x: auto; padding:1px; margin-bottom: 1.2em;} |
|
430 | 430 | #user_login, #user_firstname, #user_lastname, #user_mail, #my_account_form select, #user_form select, #user_identity_url { width: 90%; } |
|
431 | 431 | |
|
432 | 432 | #workflow_copy_form select { width: 200px; } |
|
433 | 433 | |
|
434 | 434 | textarea#custom_field_possible_values {width: 99%} |
|
435 | 435 | input#content_comments {width: 99%} |
|
436 | 436 | |
|
437 | 437 | .pagination {font-size: 90%} |
|
438 | 438 | p.pagination {margin-top:8px;} |
|
439 | 439 | |
|
440 | 440 | /***** Tabular forms ******/ |
|
441 | 441 | .tabular p{ |
|
442 | 442 | margin: 0; |
|
443 | 443 | padding: 3px 0 3px 0; |
|
444 | 444 | padding-left: 180px; /* width of left column containing the label elements */ |
|
445 | 445 | min-height: 1.8em; |
|
446 | 446 | clear:left; |
|
447 | 447 | } |
|
448 | 448 | |
|
449 | 449 | html>body .tabular p {overflow:hidden;} |
|
450 | 450 | |
|
451 | 451 | .tabular label{ |
|
452 | 452 | font-weight: bold; |
|
453 | 453 | float: left; |
|
454 | 454 | text-align: right; |
|
455 | 455 | /* width of left column */ |
|
456 | 456 | margin-left: -180px; |
|
457 | 457 | /* width of labels. Should be smaller than left column to create some right margin */ |
|
458 | 458 | width: 175px; |
|
459 | 459 | } |
|
460 | 460 | |
|
461 | 461 | .tabular label.floating{ |
|
462 | 462 | font-weight: normal; |
|
463 | 463 | margin-left: 0px; |
|
464 | 464 | text-align: left; |
|
465 | 465 | width: 270px; |
|
466 | 466 | } |
|
467 | 467 | |
|
468 | 468 | .tabular label.block{ |
|
469 | 469 | font-weight: normal; |
|
470 | 470 | margin-left: 0px !important; |
|
471 | 471 | text-align: left; |
|
472 | 472 | float: none; |
|
473 | 473 | display: block; |
|
474 | 474 | width: auto; |
|
475 | 475 | } |
|
476 | 476 | |
|
477 | 477 | .tabular label.inline{ |
|
478 | 478 | float:none; |
|
479 | 479 | margin-left: 5px !important; |
|
480 | 480 | width: auto; |
|
481 | 481 | } |
|
482 | 482 | |
|
483 | 483 | label.no-css { |
|
484 | 484 | font-weight: inherit; |
|
485 | 485 | float:none; |
|
486 | 486 | text-align:left; |
|
487 | 487 | margin-left:0px; |
|
488 | 488 | width:auto; |
|
489 | 489 | } |
|
490 | 490 | input#time_entry_comments { width: 90%;} |
|
491 | 491 | |
|
492 | 492 | #preview fieldset {margin-top: 1em; background: url(../images/draft.png)} |
|
493 | 493 | |
|
494 | 494 | .tabular.settings p{ padding-left: 300px; } |
|
495 | 495 | .tabular.settings label{ margin-left: -300px; width: 295px; } |
|
496 | 496 | .tabular.settings textarea { width: 99%; } |
|
497 | 497 | |
|
498 | 498 | .settings.enabled_scm table {width:100%} |
|
499 | 499 | .settings.enabled_scm td.scm_name{ font-weight: bold; } |
|
500 | 500 | |
|
501 | 501 | fieldset.settings label { display: block; } |
|
502 | 502 | fieldset#notified_events .parent { padding-left: 20px; } |
|
503 | 503 | |
|
504 | 504 | .required {color: #bb0000;} |
|
505 | 505 | .summary {font-style: italic;} |
|
506 | 506 | |
|
507 | 507 | #attachments_fields input.description {margin-left: 8px; width:340px;} |
|
508 | 508 | #attachments_fields span {display:block; white-space:nowrap;} |
|
509 | 509 | #attachments_fields img {vertical-align: middle;} |
|
510 | 510 | |
|
511 | 511 | div.attachments { margin-top: 12px; } |
|
512 | 512 | div.attachments p { margin:4px 0 2px 0; } |
|
513 | 513 | div.attachments img { vertical-align: middle; } |
|
514 | 514 | div.attachments span.author { font-size: 0.9em; color: #888; } |
|
515 | 515 | |
|
516 | 516 | p.other-formats { text-align: right; font-size:0.9em; color: #666; } |
|
517 | 517 | .other-formats span + span:before { content: "| "; } |
|
518 | 518 | |
|
519 | 519 | a.atom { background: url(../images/feed.png) no-repeat 1px 50%; padding: 2px 0px 3px 16px; } |
|
520 | 520 | |
|
521 | 521 | em.info {font-style:normal;font-size:90%;color:#888;display:block;} |
|
522 | 522 | em.info.error {padding-left:20px; background:url(../images/exclamation.png) no-repeat 0 50%;} |
|
523 | 523 | |
|
524 | textarea.text_cf {width:90%;} | |
|
525 | ||
|
524 | 526 | /* Project members tab */ |
|
525 | 527 | div#tab-content-members .splitcontentleft, div#tab-content-memberships .splitcontentleft, div#tab-content-users .splitcontentleft { width: 64% } |
|
526 | 528 | div#tab-content-members .splitcontentright, div#tab-content-memberships .splitcontentright, div#tab-content-users .splitcontentright { width: 34% } |
|
527 | 529 | div#tab-content-members fieldset, div#tab-content-memberships fieldset, div#tab-content-users fieldset { padding:1em; margin-bottom: 1em; } |
|
528 | 530 | div#tab-content-members fieldset legend, div#tab-content-memberships fieldset legend, div#tab-content-users fieldset legend { font-weight: bold; } |
|
529 | 531 | div#tab-content-members fieldset label, div#tab-content-memberships fieldset label, div#tab-content-users fieldset label { display: block; } |
|
530 | 532 | div#tab-content-members fieldset div, div#tab-content-users fieldset div { max-height: 400px; overflow:auto; } |
|
531 | 533 | |
|
532 | 534 | #users_for_watcher {height: 200px; overflow:auto;} |
|
533 | 535 | #users_for_watcher label {display: block;} |
|
534 | 536 | |
|
535 | 537 | table.members td.group { padding-left: 20px; background: url(../images/group.png) no-repeat 0% 50%; } |
|
536 | 538 | |
|
537 | 539 | input#principal_search, input#user_search {width:100%} |
|
538 | 540 | input#principal_search, input#user_search { |
|
539 | 541 | background: url(../images/magnifier.png) no-repeat 2px 50%; padding-left:20px; |
|
540 | 542 | border:1px solid #9EB1C2; border-radius:3px; height:1.5em; width:95%; |
|
541 | 543 | } |
|
542 | 544 | input#principal_search.ajax-loading, input#user_search.ajax-loading { |
|
543 | 545 | background-image: url(../images/loading.gif); |
|
544 | 546 | } |
|
545 | 547 | |
|
546 | 548 | * html div#tab-content-members fieldset div { height: 450px; } |
|
547 | 549 | |
|
548 | 550 | /***** Flash & error messages ****/ |
|
549 | 551 | #errorExplanation, div.flash, .nodata, .warning, .conflict { |
|
550 | 552 | padding: 4px 4px 4px 30px; |
|
551 | 553 | margin-bottom: 12px; |
|
552 | 554 | font-size: 1.1em; |
|
553 | 555 | border: 2px solid; |
|
554 | 556 | } |
|
555 | 557 | |
|
556 | 558 | div.flash {margin-top: 8px;} |
|
557 | 559 | |
|
558 | 560 | div.flash.error, #errorExplanation { |
|
559 | 561 | background: url(../images/exclamation.png) 8px 50% no-repeat; |
|
560 | 562 | background-color: #ffe3e3; |
|
561 | 563 | border-color: #dd0000; |
|
562 | 564 | color: #880000; |
|
563 | 565 | } |
|
564 | 566 | |
|
565 | 567 | div.flash.notice { |
|
566 | 568 | background: url(../images/true.png) 8px 5px no-repeat; |
|
567 | 569 | background-color: #dfffdf; |
|
568 | 570 | border-color: #9fcf9f; |
|
569 | 571 | color: #005f00; |
|
570 | 572 | } |
|
571 | 573 | |
|
572 | 574 | div.flash.warning, .conflict { |
|
573 | 575 | background: url(../images/warning.png) 8px 5px no-repeat; |
|
574 | 576 | background-color: #FFEBC1; |
|
575 | 577 | border-color: #FDBF3B; |
|
576 | 578 | color: #A6750C; |
|
577 | 579 | text-align: left; |
|
578 | 580 | } |
|
579 | 581 | |
|
580 | 582 | .nodata, .warning { |
|
581 | 583 | text-align: center; |
|
582 | 584 | background-color: #FFEBC1; |
|
583 | 585 | border-color: #FDBF3B; |
|
584 | 586 | color: #A6750C; |
|
585 | 587 | } |
|
586 | 588 | |
|
587 | 589 | #errorExplanation ul { font-size: 0.9em;} |
|
588 | 590 | #errorExplanation h2, #errorExplanation p { display: none; } |
|
589 | 591 | |
|
590 | 592 | .conflict-details {font-size:80%;} |
|
591 | 593 | |
|
592 | 594 | /***** Ajax indicator ******/ |
|
593 | 595 | #ajax-indicator { |
|
594 | 596 | position: absolute; /* fixed not supported by IE */ |
|
595 | 597 | background-color:#eee; |
|
596 | 598 | border: 1px solid #bbb; |
|
597 | 599 | top:35%; |
|
598 | 600 | left:40%; |
|
599 | 601 | width:20%; |
|
600 | 602 | font-weight:bold; |
|
601 | 603 | text-align:center; |
|
602 | 604 | padding:0.6em; |
|
603 | 605 | z-index:100; |
|
604 | 606 | opacity: 0.5; |
|
605 | 607 | } |
|
606 | 608 | |
|
607 | 609 | html>body #ajax-indicator { position: fixed; } |
|
608 | 610 | |
|
609 | 611 | #ajax-indicator span { |
|
610 | 612 | background-position: 0% 40%; |
|
611 | 613 | background-repeat: no-repeat; |
|
612 | 614 | background-image: url(../images/loading.gif); |
|
613 | 615 | padding-left: 26px; |
|
614 | 616 | vertical-align: bottom; |
|
615 | 617 | } |
|
616 | 618 | |
|
617 | 619 | /***** Calendar *****/ |
|
618 | 620 | table.cal {border-collapse: collapse; width: 100%; margin: 0px 0 6px 0;border: 1px solid #d7d7d7;} |
|
619 | 621 | table.cal thead th {width: 14%; background-color:#EEEEEE; padding: 4px; } |
|
620 | 622 | table.cal thead th.week-number {width: auto;} |
|
621 | 623 | table.cal tbody tr {height: 100px;} |
|
622 | 624 | table.cal td {border: 1px solid #d7d7d7; vertical-align: top; font-size: 0.9em;} |
|
623 | 625 | table.cal td.week-number { background-color:#EEEEEE; padding: 4px; border:none; font-size: 1em;} |
|
624 | 626 | table.cal td p.day-num {font-size: 1.1em; text-align:right;} |
|
625 | 627 | table.cal td.odd p.day-num {color: #bbb;} |
|
626 | 628 | table.cal td.today {background:#ffffdd;} |
|
627 | 629 | table.cal td.today p.day-num {font-weight: bold;} |
|
628 | 630 | table.cal .starting a, p.cal.legend .starting {background: url(../images/bullet_go.png) no-repeat -1px -2px; padding-left:16px;} |
|
629 | 631 | table.cal .ending a, p.cal.legend .ending {background: url(../images/bullet_end.png) no-repeat -1px -2px; padding-left:16px;} |
|
630 | 632 | table.cal .starting.ending a, p.cal.legend .starting.ending {background: url(../images/bullet_diamond.png) no-repeat -1px -2px; padding-left:16px;} |
|
631 | 633 | p.cal.legend span {display:block;} |
|
632 | 634 | |
|
633 | 635 | /***** Tooltips ******/ |
|
634 | 636 | .tooltip{position:relative;z-index:24;} |
|
635 | 637 | .tooltip:hover{z-index:25;color:#000;} |
|
636 | 638 | .tooltip span.tip{display: none; text-align:left;} |
|
637 | 639 | |
|
638 | 640 | div.tooltip:hover span.tip{ |
|
639 | 641 | display:block; |
|
640 | 642 | position:absolute; |
|
641 | 643 | top:12px; left:24px; width:270px; |
|
642 | 644 | border:1px solid #555; |
|
643 | 645 | background-color:#fff; |
|
644 | 646 | padding: 4px; |
|
645 | 647 | font-size: 0.8em; |
|
646 | 648 | color:#505050; |
|
647 | 649 | } |
|
648 | 650 | |
|
649 | 651 | /***** Progress bar *****/ |
|
650 | 652 | table.progress { |
|
651 | 653 | border-collapse: collapse; |
|
652 | 654 | border-spacing: 0pt; |
|
653 | 655 | empty-cells: show; |
|
654 | 656 | text-align: center; |
|
655 | 657 | float:left; |
|
656 | 658 | margin: 1px 6px 1px 0px; |
|
657 | 659 | } |
|
658 | 660 | |
|
659 | 661 | table.progress td { height: 1em; } |
|
660 | 662 | table.progress td.closed { background: #BAE0BA none repeat scroll 0%; } |
|
661 | 663 | table.progress td.done { background: #D3EDD3 none repeat scroll 0%; } |
|
662 | 664 | table.progress td.todo { background: #eee none repeat scroll 0%; } |
|
663 | 665 | p.pourcent {font-size: 80%;} |
|
664 | 666 | p.progress-info {clear: left; font-size: 80%; margin-top:-4px; color:#777;} |
|
665 | 667 | |
|
666 | 668 | #roadmap table.progress td { height: 1.2em; } |
|
667 | 669 | /***** Tabs *****/ |
|
668 | 670 | #content .tabs {height: 2.6em; margin-bottom:1.2em; position:relative; overflow:hidden;} |
|
669 | 671 | #content .tabs ul {margin:0; position:absolute; bottom:0; padding-left:0.5em; width: 2000px; border-bottom: 1px solid #bbbbbb;} |
|
670 | 672 | #content .tabs ul li { |
|
671 | 673 | float:left; |
|
672 | 674 | list-style-type:none; |
|
673 | 675 | white-space:nowrap; |
|
674 | 676 | margin-right:4px; |
|
675 | 677 | background:#fff; |
|
676 | 678 | position:relative; |
|
677 | 679 | margin-bottom:-1px; |
|
678 | 680 | } |
|
679 | 681 | #content .tabs ul li a{ |
|
680 | 682 | display:block; |
|
681 | 683 | font-size: 0.9em; |
|
682 | 684 | text-decoration:none; |
|
683 | 685 | line-height:1.3em; |
|
684 | 686 | padding:4px 6px 4px 6px; |
|
685 | 687 | border: 1px solid #ccc; |
|
686 | 688 | border-bottom: 1px solid #bbbbbb; |
|
687 | 689 | background-color: #f6f6f6; |
|
688 | 690 | color:#999; |
|
689 | 691 | font-weight:bold; |
|
690 | 692 | border-top-left-radius:3px; |
|
691 | 693 | border-top-right-radius:3px; |
|
692 | 694 | } |
|
693 | 695 | |
|
694 | 696 | #content .tabs ul li a:hover { |
|
695 | 697 | background-color: #ffffdd; |
|
696 | 698 | text-decoration:none; |
|
697 | 699 | } |
|
698 | 700 | |
|
699 | 701 | #content .tabs ul li a.selected { |
|
700 | 702 | background-color: #fff; |
|
701 | 703 | border: 1px solid #bbbbbb; |
|
702 | 704 | border-bottom: 1px solid #fff; |
|
703 | 705 | color:#444; |
|
704 | 706 | } |
|
705 | 707 | |
|
706 | 708 | #content .tabs ul li a.selected:hover { |
|
707 | 709 | background-color: #fff; |
|
708 | 710 | } |
|
709 | 711 | |
|
710 | 712 | div.tabs-buttons { position:absolute; right: 0; width: 48px; height: 24px; background: white; bottom: 0; border-bottom: 1px solid #bbbbbb; } |
|
711 | 713 | |
|
712 | 714 | button.tab-left, button.tab-right { |
|
713 | 715 | font-size: 0.9em; |
|
714 | 716 | cursor: pointer; |
|
715 | 717 | height:24px; |
|
716 | 718 | border: 1px solid #ccc; |
|
717 | 719 | border-bottom: 1px solid #bbbbbb; |
|
718 | 720 | position:absolute; |
|
719 | 721 | padding:4px; |
|
720 | 722 | width: 20px; |
|
721 | 723 | bottom: -1px; |
|
722 | 724 | } |
|
723 | 725 | |
|
724 | 726 | button.tab-left { |
|
725 | 727 | right: 20px; |
|
726 | 728 | background: #eeeeee url(../images/bullet_arrow_left.png) no-repeat 50% 50%; |
|
727 | 729 | border-top-left-radius:3px; |
|
728 | 730 | } |
|
729 | 731 | |
|
730 | 732 | button.tab-right { |
|
731 | 733 | right: 0; |
|
732 | 734 | background: #eeeeee url(../images/bullet_arrow_right.png) no-repeat 50% 50%; |
|
733 | 735 | border-top-right-radius:3px; |
|
734 | 736 | } |
|
735 | 737 | |
|
736 | 738 | /***** Auto-complete *****/ |
|
737 | 739 | div.autocomplete { |
|
738 | 740 | position:absolute; |
|
739 | 741 | width:400px; |
|
740 | 742 | margin:0; |
|
741 | 743 | padding:0; |
|
742 | 744 | } |
|
743 | 745 | div.autocomplete ul { |
|
744 | 746 | list-style-type:none; |
|
745 | 747 | margin:0; |
|
746 | 748 | padding:0; |
|
747 | 749 | } |
|
748 | 750 | div.autocomplete ul li { |
|
749 | 751 | list-style-type:none; |
|
750 | 752 | display:block; |
|
751 | 753 | margin:-1px 0 0 0; |
|
752 | 754 | padding:2px; |
|
753 | 755 | cursor:pointer; |
|
754 | 756 | font-size: 90%; |
|
755 | 757 | border: 1px solid #ccc; |
|
756 | 758 | border-left: 1px solid #ccc; |
|
757 | 759 | border-right: 1px solid #ccc; |
|
758 | 760 | background-color:white; |
|
759 | 761 | } |
|
760 | 762 | div.autocomplete ul li.selected { background-color: #ffb;} |
|
761 | 763 | div.autocomplete ul li span.informal { |
|
762 | 764 | font-size: 80%; |
|
763 | 765 | color: #aaa; |
|
764 | 766 | } |
|
765 | 767 | |
|
766 | 768 | #parent_issue_candidates ul li {width: 500px;} |
|
767 | 769 | #related_issue_candidates ul li {width: 500px;} |
|
768 | 770 | |
|
769 | 771 | /***** Diff *****/ |
|
770 | 772 | .diff_out { background: #fcc; } |
|
771 | 773 | .diff_out span { background: #faa; } |
|
772 | 774 | .diff_in { background: #cfc; } |
|
773 | 775 | .diff_in span { background: #afa; } |
|
774 | 776 | |
|
775 | 777 | .text-diff { |
|
776 | 778 | padding: 1em; |
|
777 | 779 | background-color:#f6f6f6; |
|
778 | 780 | color:#505050; |
|
779 | 781 | border: 1px solid #e4e4e4; |
|
780 | 782 | } |
|
781 | 783 | |
|
782 | 784 | /***** Wiki *****/ |
|
783 | 785 | div.wiki table { |
|
784 | 786 | border-collapse: collapse; |
|
785 | 787 | margin-bottom: 1em; |
|
786 | 788 | } |
|
787 | 789 | |
|
788 | 790 | div.wiki table, div.wiki td, div.wiki th { |
|
789 | 791 | border: 1px solid #bbb; |
|
790 | 792 | padding: 4px; |
|
791 | 793 | } |
|
792 | 794 | |
|
793 | 795 | div.wiki .noborder, div.wiki .noborder td, div.wiki .noborder th {border:0;} |
|
794 | 796 | |
|
795 | 797 | div.wiki .external { |
|
796 | 798 | background-position: 0% 60%; |
|
797 | 799 | background-repeat: no-repeat; |
|
798 | 800 | padding-left: 12px; |
|
799 | 801 | background-image: url(../images/external.png); |
|
800 | 802 | } |
|
801 | 803 | |
|
802 | 804 | div.wiki a.new { |
|
803 | 805 | color: #b73535; |
|
804 | 806 | } |
|
805 | 807 | |
|
806 | 808 | div.wiki ul, div.wiki ol {margin-bottom:1em;} |
|
807 | 809 | |
|
808 | 810 | div.wiki pre { |
|
809 | 811 | margin: 1em 1em 1em 1.6em; |
|
810 | 812 | padding: 2px 2px 2px 0; |
|
811 | 813 | background-color: #fafafa; |
|
812 | 814 | border: 1px solid #dadada; |
|
813 | 815 | width:auto; |
|
814 | 816 | overflow-x: auto; |
|
815 | 817 | overflow-y: hidden; |
|
816 | 818 | } |
|
817 | 819 | |
|
818 | 820 | div.wiki ul.toc { |
|
819 | 821 | background-color: #ffffdd; |
|
820 | 822 | border: 1px solid #e4e4e4; |
|
821 | 823 | padding: 4px; |
|
822 | 824 | line-height: 1.2em; |
|
823 | 825 | margin-bottom: 12px; |
|
824 | 826 | margin-right: 12px; |
|
825 | 827 | margin-left: 0; |
|
826 | 828 | display: table |
|
827 | 829 | } |
|
828 | 830 | * html div.wiki ul.toc { width: 50%; } /* IE6 doesn't autosize div */ |
|
829 | 831 | |
|
830 | 832 | div.wiki ul.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; } |
|
831 | 833 | div.wiki ul.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; } |
|
832 | 834 | div.wiki ul.toc ul { margin: 0; padding: 0; } |
|
833 | 835 | div.wiki ul.toc li { list-style-type:none; margin: 0;} |
|
834 | 836 | div.wiki ul.toc li li { margin-left: 1.5em; } |
|
835 | 837 | div.wiki ul.toc li li li { font-size: 0.8em; } |
|
836 | 838 | |
|
837 | 839 | div.wiki ul.toc a { |
|
838 | 840 | font-size: 0.9em; |
|
839 | 841 | font-weight: normal; |
|
840 | 842 | text-decoration: none; |
|
841 | 843 | color: #606060; |
|
842 | 844 | } |
|
843 | 845 | div.wiki ul.toc a:hover { color: #c61a1a; text-decoration: underline;} |
|
844 | 846 | |
|
845 | 847 | a.wiki-anchor { display: none; margin-left: 6px; text-decoration: none; } |
|
846 | 848 | a.wiki-anchor:hover { color: #aaa !important; text-decoration: none; } |
|
847 | 849 | h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display: inline; color: #ddd; } |
|
848 | 850 | |
|
849 | 851 | div.wiki img { vertical-align: middle; } |
|
850 | 852 | |
|
851 | 853 | /***** My page layout *****/ |
|
852 | 854 | .block-receiver { |
|
853 | 855 | border:1px dashed #c0c0c0; |
|
854 | 856 | margin-bottom: 20px; |
|
855 | 857 | padding: 15px 0 15px 0; |
|
856 | 858 | } |
|
857 | 859 | |
|
858 | 860 | .mypage-box { |
|
859 | 861 | margin:0 0 20px 0; |
|
860 | 862 | color:#505050; |
|
861 | 863 | line-height:1.5em; |
|
862 | 864 | } |
|
863 | 865 | |
|
864 | 866 | .handle { |
|
865 | 867 | cursor: move; |
|
866 | 868 | } |
|
867 | 869 | |
|
868 | 870 | a.close-icon { |
|
869 | 871 | display:block; |
|
870 | 872 | margin-top:3px; |
|
871 | 873 | overflow:hidden; |
|
872 | 874 | width:12px; |
|
873 | 875 | height:12px; |
|
874 | 876 | background-repeat: no-repeat; |
|
875 | 877 | cursor:pointer; |
|
876 | 878 | background-image:url('../images/close.png'); |
|
877 | 879 | } |
|
878 | 880 | |
|
879 | 881 | a.close-icon:hover { |
|
880 | 882 | background-image:url('../images/close_hl.png'); |
|
881 | 883 | } |
|
882 | 884 | |
|
883 | 885 | /***** Gantt chart *****/ |
|
884 | 886 | .gantt_hdr { |
|
885 | 887 | position:absolute; |
|
886 | 888 | top:0; |
|
887 | 889 | height:16px; |
|
888 | 890 | border-top: 1px solid #c0c0c0; |
|
889 | 891 | border-bottom: 1px solid #c0c0c0; |
|
890 | 892 | border-right: 1px solid #c0c0c0; |
|
891 | 893 | text-align: center; |
|
892 | 894 | overflow: hidden; |
|
893 | 895 | } |
|
894 | 896 | |
|
895 | 897 | .gantt_subjects { font-size: 0.8em; } |
|
896 | 898 | .gantt_subjects div { line-height:16px;height:16px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis; } |
|
897 | 899 | |
|
898 | 900 | .task { |
|
899 | 901 | position: absolute; |
|
900 | 902 | height:8px; |
|
901 | 903 | font-size:0.8em; |
|
902 | 904 | color:#888; |
|
903 | 905 | padding:0; |
|
904 | 906 | margin:0; |
|
905 | 907 | line-height:16px; |
|
906 | 908 | white-space:nowrap; |
|
907 | 909 | } |
|
908 | 910 | |
|
909 | 911 | .task.label {width:100%;} |
|
910 | 912 | .task.label.project, .task.label.version { font-weight: bold; } |
|
911 | 913 | |
|
912 | 914 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } |
|
913 | 915 | .task_done { background:#00c600 url(../images/task_done.png); border: 1px solid #00c600; } |
|
914 | 916 | .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; } |
|
915 | 917 | |
|
916 | 918 | .task_todo.parent { background: #888; border: 1px solid #888; height: 3px;} |
|
917 | 919 | .task_late.parent, .task_done.parent { height: 3px;} |
|
918 | 920 | .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;} |
|
919 | 921 | .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;} |
|
920 | 922 | |
|
921 | 923 | .version.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;} |
|
922 | 924 | .version.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;} |
|
923 | 925 | .version.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;} |
|
924 | 926 | .version.marker { background-image:url(../images/version_marker.png); background-repeat: no-repeat; border: 0; margin-left: -4px; margin-top: 1px; } |
|
925 | 927 | |
|
926 | 928 | .project.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;} |
|
927 | 929 | .project.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;} |
|
928 | 930 | .project.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;} |
|
929 | 931 | .project.marker { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; margin-left: -4px; margin-top: 1px; } |
|
930 | 932 | |
|
931 | 933 | .version-behind-schedule a, .issue-behind-schedule a {color: #f66914;} |
|
932 | 934 | .version-overdue a, .issue-overdue a, .project-overdue a {color: #f00;} |
|
933 | 935 | |
|
934 | 936 | /***** Icons *****/ |
|
935 | 937 | .icon { |
|
936 | 938 | background-position: 0% 50%; |
|
937 | 939 | background-repeat: no-repeat; |
|
938 | 940 | padding-left: 20px; |
|
939 | 941 | padding-top: 2px; |
|
940 | 942 | padding-bottom: 3px; |
|
941 | 943 | } |
|
942 | 944 | |
|
943 | 945 | .icon-add { background-image: url(../images/add.png); } |
|
944 | 946 | .icon-edit { background-image: url(../images/edit.png); } |
|
945 | 947 | .icon-copy { background-image: url(../images/copy.png); } |
|
946 | 948 | .icon-duplicate { background-image: url(../images/duplicate.png); } |
|
947 | 949 | .icon-del { background-image: url(../images/delete.png); } |
|
948 | 950 | .icon-move { background-image: url(../images/move.png); } |
|
949 | 951 | .icon-save { background-image: url(../images/save.png); } |
|
950 | 952 | .icon-cancel { background-image: url(../images/cancel.png); } |
|
951 | 953 | .icon-multiple { background-image: url(../images/table_multiple.png); } |
|
952 | 954 | .icon-folder { background-image: url(../images/folder.png); } |
|
953 | 955 | .open .icon-folder { background-image: url(../images/folder_open.png); } |
|
954 | 956 | .icon-package { background-image: url(../images/package.png); } |
|
955 | 957 | .icon-user { background-image: url(../images/user.png); } |
|
956 | 958 | .icon-projects { background-image: url(../images/projects.png); } |
|
957 | 959 | .icon-help { background-image: url(../images/help.png); } |
|
958 | 960 | .icon-attachment { background-image: url(../images/attachment.png); } |
|
959 | 961 | .icon-history { background-image: url(../images/history.png); } |
|
960 | 962 | .icon-time { background-image: url(../images/time.png); } |
|
961 | 963 | .icon-time-add { background-image: url(../images/time_add.png); } |
|
962 | 964 | .icon-stats { background-image: url(../images/stats.png); } |
|
963 | 965 | .icon-warning { background-image: url(../images/warning.png); } |
|
964 | 966 | .icon-fav { background-image: url(../images/fav.png); } |
|
965 | 967 | .icon-fav-off { background-image: url(../images/fav_off.png); } |
|
966 | 968 | .icon-reload { background-image: url(../images/reload.png); } |
|
967 | 969 | .icon-lock { background-image: url(../images/locked.png); } |
|
968 | 970 | .icon-unlock { background-image: url(../images/unlock.png); } |
|
969 | 971 | .icon-checked { background-image: url(../images/true.png); } |
|
970 | 972 | .icon-details { background-image: url(../images/zoom_in.png); } |
|
971 | 973 | .icon-report { background-image: url(../images/report.png); } |
|
972 | 974 | .icon-comment { background-image: url(../images/comment.png); } |
|
973 | 975 | .icon-summary { background-image: url(../images/lightning.png); } |
|
974 | 976 | .icon-server-authentication { background-image: url(../images/server_key.png); } |
|
975 | 977 | .icon-issue { background-image: url(../images/ticket.png); } |
|
976 | 978 | .icon-zoom-in { background-image: url(../images/zoom_in.png); } |
|
977 | 979 | .icon-zoom-out { background-image: url(../images/zoom_out.png); } |
|
978 | 980 | .icon-passwd { background-image: url(../images/textfield_key.png); } |
|
979 | 981 | .icon-test { background-image: url(../images/bullet_go.png); } |
|
980 | 982 | |
|
981 | 983 | .icon-file { background-image: url(../images/files/default.png); } |
|
982 | 984 | .icon-file.text-plain { background-image: url(../images/files/text.png); } |
|
983 | 985 | .icon-file.text-x-c { background-image: url(../images/files/c.png); } |
|
984 | 986 | .icon-file.text-x-csharp { background-image: url(../images/files/csharp.png); } |
|
985 | 987 | .icon-file.text-x-java { background-image: url(../images/files/java.png); } |
|
986 | 988 | .icon-file.text-x-javascript { background-image: url(../images/files/js.png); } |
|
987 | 989 | .icon-file.text-x-php { background-image: url(../images/files/php.png); } |
|
988 | 990 | .icon-file.text-x-ruby { background-image: url(../images/files/ruby.png); } |
|
989 | 991 | .icon-file.text-xml { background-image: url(../images/files/xml.png); } |
|
990 | 992 | .icon-file.text-css { background-image: url(../images/files/css.png); } |
|
991 | 993 | .icon-file.text-html { background-image: url(../images/files/html.png); } |
|
992 | 994 | .icon-file.image-gif { background-image: url(../images/files/image.png); } |
|
993 | 995 | .icon-file.image-jpeg { background-image: url(../images/files/image.png); } |
|
994 | 996 | .icon-file.image-png { background-image: url(../images/files/image.png); } |
|
995 | 997 | .icon-file.image-tiff { background-image: url(../images/files/image.png); } |
|
996 | 998 | .icon-file.application-pdf { background-image: url(../images/files/pdf.png); } |
|
997 | 999 | .icon-file.application-zip { background-image: url(../images/files/zip.png); } |
|
998 | 1000 | .icon-file.application-x-gzip { background-image: url(../images/files/zip.png); } |
|
999 | 1001 | |
|
1000 | 1002 | img.gravatar { |
|
1001 | 1003 | padding: 2px; |
|
1002 | 1004 | border: solid 1px #d5d5d5; |
|
1003 | 1005 | background: #fff; |
|
1004 | 1006 | vertical-align: middle; |
|
1005 | 1007 | } |
|
1006 | 1008 | |
|
1007 | 1009 | div.issue img.gravatar { |
|
1008 | 1010 | float: left; |
|
1009 | 1011 | margin: 0 6px 0 0; |
|
1010 | 1012 | padding: 5px; |
|
1011 | 1013 | } |
|
1012 | 1014 | |
|
1013 | 1015 | div.issue table img.gravatar { |
|
1014 | 1016 | height: 14px; |
|
1015 | 1017 | width: 14px; |
|
1016 | 1018 | padding: 2px; |
|
1017 | 1019 | float: left; |
|
1018 | 1020 | margin: 0 0.5em 0 0; |
|
1019 | 1021 | } |
|
1020 | 1022 | |
|
1021 | 1023 | h2 img.gravatar { |
|
1022 | 1024 | margin: -2px 4px -4px 0; |
|
1023 | 1025 | } |
|
1024 | 1026 | |
|
1025 | 1027 | h3 img.gravatar { |
|
1026 | 1028 | margin: -4px 4px -4px 0; |
|
1027 | 1029 | } |
|
1028 | 1030 | |
|
1029 | 1031 | h4 img.gravatar { |
|
1030 | 1032 | margin: -6px 4px -4px 0; |
|
1031 | 1033 | } |
|
1032 | 1034 | |
|
1033 | 1035 | td.username img.gravatar { |
|
1034 | 1036 | margin: 0 0.5em 0 0; |
|
1035 | 1037 | vertical-align: top; |
|
1036 | 1038 | } |
|
1037 | 1039 | |
|
1038 | 1040 | #activity dt img.gravatar { |
|
1039 | 1041 | float: left; |
|
1040 | 1042 | margin: 0 1em 1em 0; |
|
1041 | 1043 | } |
|
1042 | 1044 | |
|
1043 | 1045 | /* Used on 12px Gravatar img tags without the icon background */ |
|
1044 | 1046 | .icon-gravatar { |
|
1045 | 1047 | float: left; |
|
1046 | 1048 | margin-right: 4px; |
|
1047 | 1049 | } |
|
1048 | 1050 | |
|
1049 | 1051 | #activity dt, |
|
1050 | 1052 | .journal { |
|
1051 | 1053 | clear: left; |
|
1052 | 1054 | } |
|
1053 | 1055 | |
|
1054 | 1056 | .journal-link { |
|
1055 | 1057 | float: right; |
|
1056 | 1058 | } |
|
1057 | 1059 | |
|
1058 | 1060 | h2 img { vertical-align:middle; } |
|
1059 | 1061 | |
|
1060 | 1062 | .hascontextmenu { cursor: context-menu; } |
|
1061 | 1063 | |
|
1062 | 1064 | /***** Media print specific styles *****/ |
|
1063 | 1065 | @media print { |
|
1064 | 1066 | #top-menu, #header, #main-menu, #sidebar, #footer, .contextual, .other-formats { display:none; } |
|
1065 | 1067 | #main { background: #fff; } |
|
1066 | 1068 | #content { width: 99%; margin: 0; padding: 0; border: 0; background: #fff; overflow: visible !important;} |
|
1067 | 1069 | #wiki_add_attachment { display:none; } |
|
1068 | 1070 | .hide-when-print { display: none; } |
|
1069 | 1071 | .autoscroll {overflow-x: visible;} |
|
1070 | 1072 | table.list {margin-top:0.5em;} |
|
1071 | 1073 | table.list th, table.list td {border: 1px solid #aaa;} |
|
1072 | 1074 | } |
|
1073 | 1075 | |
|
1074 | 1076 | /* Accessibility specific styles */ |
|
1075 | 1077 | .hidden-for-sighted { |
|
1076 | 1078 | position:absolute; |
|
1077 | 1079 | left:-10000px; |
|
1078 | 1080 | top:auto; |
|
1079 | 1081 | width:1px; |
|
1080 | 1082 | height:1px; |
|
1081 | 1083 | overflow:hidden; |
|
1082 | 1084 | } |
@@ -1,3328 +1,3328 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 | require 'issues_controller' |
|
20 | 20 | |
|
21 | 21 | class IssuesControllerTest < ActionController::TestCase |
|
22 | 22 | fixtures :projects, |
|
23 | 23 | :users, |
|
24 | 24 | :roles, |
|
25 | 25 | :members, |
|
26 | 26 | :member_roles, |
|
27 | 27 | :issues, |
|
28 | 28 | :issue_statuses, |
|
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 | @controller = IssuesController.new |
|
52 | 52 | @request = ActionController::TestRequest.new |
|
53 | 53 | @response = ActionController::TestResponse.new |
|
54 | 54 | User.current = nil |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | def test_index |
|
58 | 58 | with_settings :default_language => "en" do |
|
59 | 59 | get :index |
|
60 | 60 | assert_response :success |
|
61 | 61 | assert_template 'index' |
|
62 | 62 | assert_not_nil assigns(:issues) |
|
63 | 63 | assert_nil assigns(:project) |
|
64 | 64 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
65 | 65 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
66 | 66 | # private projects hidden |
|
67 | 67 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
68 | 68 | assert_no_tag :tag => 'a', :content => /Issue on project 2/ |
|
69 | 69 | # project column |
|
70 | 70 | assert_tag :tag => 'th', :content => /Project/ |
|
71 | 71 | end |
|
72 | 72 | end |
|
73 | 73 | |
|
74 | 74 | def test_index_should_not_list_issues_when_module_disabled |
|
75 | 75 | EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1") |
|
76 | 76 | get :index |
|
77 | 77 | assert_response :success |
|
78 | 78 | assert_template 'index' |
|
79 | 79 | assert_not_nil assigns(:issues) |
|
80 | 80 | assert_nil assigns(:project) |
|
81 | 81 | assert_no_tag :tag => 'a', :content => /Can't print recipes/ |
|
82 | 82 | assert_tag :tag => 'a', :content => /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 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
99 | 99 | assert_no_tag :tag => 'a', :content => /Subproject issue/ |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def test_index_with_project_and_subprojects |
|
103 | 103 | Setting.display_subprojects_issues = 1 |
|
104 | 104 | get :index, :project_id => 1 |
|
105 | 105 | assert_response :success |
|
106 | 106 | assert_template 'index' |
|
107 | 107 | assert_not_nil assigns(:issues) |
|
108 | 108 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
109 | 109 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
110 | 110 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
111 | 111 | end |
|
112 | 112 | |
|
113 | 113 | def test_index_with_project_and_subprojects_should_show_private_subprojects |
|
114 | 114 | @request.session[:user_id] = 2 |
|
115 | 115 | Setting.display_subprojects_issues = 1 |
|
116 | 116 | get :index, :project_id => 1 |
|
117 | 117 | assert_response :success |
|
118 | 118 | assert_template 'index' |
|
119 | 119 | assert_not_nil assigns(:issues) |
|
120 | 120 | assert_tag :tag => 'a', :content => /Can't print recipes/ |
|
121 | 121 | assert_tag :tag => 'a', :content => /Subproject issue/ |
|
122 | 122 | assert_tag :tag => 'a', :content => /Issue of a private subproject/ |
|
123 | 123 | end |
|
124 | 124 | |
|
125 | 125 | def test_index_with_project_and_default_filter |
|
126 | 126 | get :index, :project_id => 1, :set_filter => 1 |
|
127 | 127 | assert_response :success |
|
128 | 128 | assert_template 'index' |
|
129 | 129 | assert_not_nil assigns(:issues) |
|
130 | 130 | |
|
131 | 131 | query = assigns(:query) |
|
132 | 132 | assert_not_nil query |
|
133 | 133 | # default filter |
|
134 | 134 | assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters) |
|
135 | 135 | end |
|
136 | 136 | |
|
137 | 137 | def test_index_with_project_and_filter |
|
138 | 138 | get :index, :project_id => 1, :set_filter => 1, |
|
139 | 139 | :f => ['tracker_id'], |
|
140 | 140 | :op => {'tracker_id' => '='}, |
|
141 | 141 | :v => {'tracker_id' => ['1']} |
|
142 | 142 | assert_response :success |
|
143 | 143 | assert_template 'index' |
|
144 | 144 | assert_not_nil assigns(:issues) |
|
145 | 145 | |
|
146 | 146 | query = assigns(:query) |
|
147 | 147 | assert_not_nil query |
|
148 | 148 | assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters) |
|
149 | 149 | end |
|
150 | 150 | |
|
151 | 151 | def test_index_with_short_filters |
|
152 | 152 | to_test = { |
|
153 | 153 | 'status_id' => { |
|
154 | 154 | 'o' => { :op => 'o', :values => [''] }, |
|
155 | 155 | 'c' => { :op => 'c', :values => [''] }, |
|
156 | 156 | '7' => { :op => '=', :values => ['7'] }, |
|
157 | 157 | '7|3|4' => { :op => '=', :values => ['7', '3', '4'] }, |
|
158 | 158 | '=7' => { :op => '=', :values => ['7'] }, |
|
159 | 159 | '!3' => { :op => '!', :values => ['3'] }, |
|
160 | 160 | '!7|3|4' => { :op => '!', :values => ['7', '3', '4'] }}, |
|
161 | 161 | 'subject' => { |
|
162 | 162 | 'This is a subject' => { :op => '=', :values => ['This is a subject'] }, |
|
163 | 163 | 'o' => { :op => '=', :values => ['o'] }, |
|
164 | 164 | '~This is part of a subject' => { :op => '~', :values => ['This is part of a subject'] }, |
|
165 | 165 | '!~This is part of a subject' => { :op => '!~', :values => ['This is part of a subject'] }}, |
|
166 | 166 | 'tracker_id' => { |
|
167 | 167 | '3' => { :op => '=', :values => ['3'] }, |
|
168 | 168 | '=3' => { :op => '=', :values => ['3'] }}, |
|
169 | 169 | 'start_date' => { |
|
170 | 170 | '2011-10-12' => { :op => '=', :values => ['2011-10-12'] }, |
|
171 | 171 | '=2011-10-12' => { :op => '=', :values => ['2011-10-12'] }, |
|
172 | 172 | '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] }, |
|
173 | 173 | '<=2011-10-12' => { :op => '<=', :values => ['2011-10-12'] }, |
|
174 | 174 | '><2011-10-01|2011-10-30' => { :op => '><', :values => ['2011-10-01', '2011-10-30'] }, |
|
175 | 175 | '<t+2' => { :op => '<t+', :values => ['2'] }, |
|
176 | 176 | '>t+2' => { :op => '>t+', :values => ['2'] }, |
|
177 | 177 | 't+2' => { :op => 't+', :values => ['2'] }, |
|
178 | 178 | 't' => { :op => 't', :values => [''] }, |
|
179 | 179 | 'w' => { :op => 'w', :values => [''] }, |
|
180 | 180 | '>t-2' => { :op => '>t-', :values => ['2'] }, |
|
181 | 181 | '<t-2' => { :op => '<t-', :values => ['2'] }, |
|
182 | 182 | 't-2' => { :op => 't-', :values => ['2'] }}, |
|
183 | 183 | 'created_on' => { |
|
184 | 184 | '>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] }, |
|
185 | 185 | '<t-2' => { :op => '<t-', :values => ['2'] }, |
|
186 | 186 | '>t-2' => { :op => '>t-', :values => ['2'] }, |
|
187 | 187 | 't-2' => { :op => 't-', :values => ['2'] }}, |
|
188 | 188 | 'cf_1' => { |
|
189 | 189 | 'c' => { :op => '=', :values => ['c'] }, |
|
190 | 190 | '!c' => { :op => '!', :values => ['c'] }, |
|
191 | 191 | '!*' => { :op => '!*', :values => [''] }, |
|
192 | 192 | '*' => { :op => '*', :values => [''] }}, |
|
193 | 193 | 'estimated_hours' => { |
|
194 | 194 | '=13.4' => { :op => '=', :values => ['13.4'] }, |
|
195 | 195 | '>=45' => { :op => '>=', :values => ['45'] }, |
|
196 | 196 | '<=125' => { :op => '<=', :values => ['125'] }, |
|
197 | 197 | '><10.5|20.5' => { :op => '><', :values => ['10.5', '20.5'] }, |
|
198 | 198 | '!*' => { :op => '!*', :values => [''] }, |
|
199 | 199 | '*' => { :op => '*', :values => [''] }} |
|
200 | 200 | } |
|
201 | 201 | |
|
202 | 202 | default_filter = { 'status_id' => {:operator => 'o', :values => [''] }} |
|
203 | 203 | |
|
204 | 204 | to_test.each do |field, expression_and_expected| |
|
205 | 205 | expression_and_expected.each do |filter_expression, expected| |
|
206 | 206 | |
|
207 | 207 | get :index, :set_filter => 1, field => filter_expression |
|
208 | 208 | |
|
209 | 209 | assert_response :success |
|
210 | 210 | assert_template 'index' |
|
211 | 211 | assert_not_nil assigns(:issues) |
|
212 | 212 | |
|
213 | 213 | query = assigns(:query) |
|
214 | 214 | assert_not_nil query |
|
215 | 215 | assert query.has_filter?(field) |
|
216 | 216 | assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters) |
|
217 | 217 | end |
|
218 | 218 | end |
|
219 | 219 | end |
|
220 | 220 | |
|
221 | 221 | def test_index_with_project_and_empty_filters |
|
222 | 222 | get :index, :project_id => 1, :set_filter => 1, :fields => [''] |
|
223 | 223 | assert_response :success |
|
224 | 224 | assert_template 'index' |
|
225 | 225 | assert_not_nil assigns(:issues) |
|
226 | 226 | |
|
227 | 227 | query = assigns(:query) |
|
228 | 228 | assert_not_nil query |
|
229 | 229 | # no filter |
|
230 | 230 | assert_equal({}, query.filters) |
|
231 | 231 | end |
|
232 | 232 | |
|
233 | 233 | def test_index_with_query |
|
234 | 234 | get :index, :project_id => 1, :query_id => 5 |
|
235 | 235 | assert_response :success |
|
236 | 236 | assert_template 'index' |
|
237 | 237 | assert_not_nil assigns(:issues) |
|
238 | 238 | assert_nil assigns(:issue_count_by_group) |
|
239 | 239 | end |
|
240 | 240 | |
|
241 | 241 | def test_index_with_query_grouped_by_tracker |
|
242 | 242 | get :index, :project_id => 1, :query_id => 6 |
|
243 | 243 | assert_response :success |
|
244 | 244 | assert_template 'index' |
|
245 | 245 | assert_not_nil assigns(:issues) |
|
246 | 246 | assert_not_nil assigns(:issue_count_by_group) |
|
247 | 247 | end |
|
248 | 248 | |
|
249 | 249 | def test_index_with_query_grouped_by_list_custom_field |
|
250 | 250 | get :index, :project_id => 1, :query_id => 9 |
|
251 | 251 | assert_response :success |
|
252 | 252 | assert_template 'index' |
|
253 | 253 | assert_not_nil assigns(:issues) |
|
254 | 254 | assert_not_nil assigns(:issue_count_by_group) |
|
255 | 255 | end |
|
256 | 256 | |
|
257 | 257 | def test_index_with_query_id_and_project_id_should_set_session_query |
|
258 | 258 | get :index, :project_id => 1, :query_id => 4 |
|
259 | 259 | assert_response :success |
|
260 | 260 | assert_kind_of Hash, session[:query] |
|
261 | 261 | assert_equal 4, session[:query][:id] |
|
262 | 262 | assert_equal 1, session[:query][:project_id] |
|
263 | 263 | end |
|
264 | 264 | |
|
265 | 265 | def test_index_with_invalid_query_id_should_respond_404 |
|
266 | 266 | get :index, :project_id => 1, :query_id => 999 |
|
267 | 267 | assert_response 404 |
|
268 | 268 | end |
|
269 | 269 | |
|
270 | 270 | def test_index_with_cross_project_query_in_session_should_show_project_issues |
|
271 | 271 | q = Query.create!(:name => "test", :user_id => 2, :is_public => false, :project => nil) |
|
272 | 272 | @request.session[:query] = {:id => q.id, :project_id => 1} |
|
273 | 273 | |
|
274 | 274 | with_settings :display_subprojects_issues => '0' do |
|
275 | 275 | get :index, :project_id => 1 |
|
276 | 276 | end |
|
277 | 277 | assert_response :success |
|
278 | 278 | assert_not_nil assigns(:query) |
|
279 | 279 | assert_equal q.id, assigns(:query).id |
|
280 | 280 | assert_equal 1, assigns(:query).project_id |
|
281 | 281 | assert_equal [1], assigns(:issues).map(&:project_id).uniq |
|
282 | 282 | end |
|
283 | 283 | |
|
284 | 284 | def test_private_query_should_not_be_available_to_other_users |
|
285 | 285 | q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) |
|
286 | 286 | @request.session[:user_id] = 3 |
|
287 | 287 | |
|
288 | 288 | get :index, :query_id => q.id |
|
289 | 289 | assert_response 403 |
|
290 | 290 | end |
|
291 | 291 | |
|
292 | 292 | def test_private_query_should_be_available_to_its_user |
|
293 | 293 | q = Query.create!(:name => "private", :user => User.find(2), :is_public => false, :project => nil) |
|
294 | 294 | @request.session[:user_id] = 2 |
|
295 | 295 | |
|
296 | 296 | get :index, :query_id => q.id |
|
297 | 297 | assert_response :success |
|
298 | 298 | end |
|
299 | 299 | |
|
300 | 300 | def test_public_query_should_be_available_to_other_users |
|
301 | 301 | q = Query.create!(:name => "private", :user => User.find(2), :is_public => true, :project => nil) |
|
302 | 302 | @request.session[:user_id] = 3 |
|
303 | 303 | |
|
304 | 304 | get :index, :query_id => q.id |
|
305 | 305 | assert_response :success |
|
306 | 306 | end |
|
307 | 307 | |
|
308 | 308 | def test_index_should_omit_page_param_in_export_links |
|
309 | 309 | get :index, :page => 2 |
|
310 | 310 | assert_response :success |
|
311 | 311 | assert_select 'a.atom[href=/issues.atom]' |
|
312 | 312 | assert_select 'a.csv[href=/issues.csv]' |
|
313 | 313 | assert_select 'a.pdf[href=/issues.pdf]' |
|
314 | 314 | assert_select 'form#csv-export-form[action=/issues.csv]' |
|
315 | 315 | end |
|
316 | 316 | |
|
317 | 317 | def test_index_csv |
|
318 | 318 | get :index, :format => 'csv' |
|
319 | 319 | assert_response :success |
|
320 | 320 | assert_not_nil assigns(:issues) |
|
321 | 321 | assert_equal 'text/csv; header=present', @response.content_type |
|
322 | 322 | assert @response.body.starts_with?("#,") |
|
323 | 323 | lines = @response.body.chomp.split("\n") |
|
324 | 324 | assert_equal assigns(:query).columns.size + 1, lines[0].split(',').size |
|
325 | 325 | end |
|
326 | 326 | |
|
327 | 327 | def test_index_csv_with_project |
|
328 | 328 | get :index, :project_id => 1, :format => 'csv' |
|
329 | 329 | assert_response :success |
|
330 | 330 | assert_not_nil assigns(:issues) |
|
331 | 331 | assert_equal 'text/csv; header=present', @response.content_type |
|
332 | 332 | end |
|
333 | 333 | |
|
334 | 334 | def test_index_csv_with_description |
|
335 | 335 | get :index, :format => 'csv', :description => '1' |
|
336 | 336 | assert_response :success |
|
337 | 337 | assert_not_nil assigns(:issues) |
|
338 | 338 | assert_equal 'text/csv; header=present', @response.content_type |
|
339 | 339 | assert @response.body.starts_with?("#,") |
|
340 | 340 | lines = @response.body.chomp.split("\n") |
|
341 | 341 | assert_equal assigns(:query).columns.size + 2, lines[0].split(',').size |
|
342 | 342 | end |
|
343 | 343 | |
|
344 | 344 | def test_index_csv_with_spent_time_column |
|
345 | 345 | issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2) |
|
346 | 346 | TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today) |
|
347 | 347 | |
|
348 | 348 | get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours) |
|
349 | 349 | assert_response :success |
|
350 | 350 | assert_equal 'text/csv; header=present', @response.content_type |
|
351 | 351 | lines = @response.body.chomp.split("\n") |
|
352 | 352 | assert_include "#{issue.id},#{issue.subject},7.33", lines |
|
353 | 353 | end |
|
354 | 354 | |
|
355 | 355 | def test_index_csv_with_all_columns |
|
356 | 356 | get :index, :format => 'csv', :columns => 'all' |
|
357 | 357 | assert_response :success |
|
358 | 358 | assert_not_nil assigns(:issues) |
|
359 | 359 | assert_equal 'text/csv; header=present', @response.content_type |
|
360 | 360 | assert @response.body.starts_with?("#,") |
|
361 | 361 | lines = @response.body.chomp.split("\n") |
|
362 | 362 | assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size |
|
363 | 363 | end |
|
364 | 364 | |
|
365 | 365 | def test_index_csv_with_multi_column_field |
|
366 | 366 | CustomField.find(1).update_attribute :multiple, true |
|
367 | 367 | issue = Issue.find(1) |
|
368 | 368 | issue.custom_field_values = {1 => ['MySQL', 'Oracle']} |
|
369 | 369 | issue.save! |
|
370 | 370 | |
|
371 | 371 | get :index, :format => 'csv', :columns => 'all' |
|
372 | 372 | assert_response :success |
|
373 | 373 | lines = @response.body.chomp.split("\n") |
|
374 | 374 | assert lines.detect {|line| line.include?('"MySQL, Oracle"')} |
|
375 | 375 | end |
|
376 | 376 | |
|
377 | 377 | def test_index_csv_big_5 |
|
378 | 378 | with_settings :default_language => "zh-TW" do |
|
379 | 379 | str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88" |
|
380 | 380 | str_big5 = "\xa4@\xa4\xeb" |
|
381 | 381 | if str_utf8.respond_to?(:force_encoding) |
|
382 | 382 | str_utf8.force_encoding('UTF-8') |
|
383 | 383 | str_big5.force_encoding('Big5') |
|
384 | 384 | end |
|
385 | 385 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, |
|
386 | 386 | :status_id => 1, :priority => IssuePriority.all.first, |
|
387 | 387 | :subject => str_utf8) |
|
388 | 388 | assert issue.save |
|
389 | 389 | |
|
390 | 390 | get :index, :project_id => 1, |
|
391 | 391 | :f => ['subject'], |
|
392 | 392 | :op => '=', :values => [str_utf8], |
|
393 | 393 | :format => 'csv' |
|
394 | 394 | assert_equal 'text/csv; header=present', @response.content_type |
|
395 | 395 | lines = @response.body.chomp.split("\n") |
|
396 | 396 | s1 = "\xaa\xac\xbaA" |
|
397 | 397 | if str_utf8.respond_to?(:force_encoding) |
|
398 | 398 | s1.force_encoding('Big5') |
|
399 | 399 | end |
|
400 | 400 | assert lines[0].include?(s1) |
|
401 | 401 | assert lines[1].include?(str_big5) |
|
402 | 402 | end |
|
403 | 403 | end |
|
404 | 404 | |
|
405 | 405 | def test_index_csv_cannot_convert_should_be_replaced_big_5 |
|
406 | 406 | with_settings :default_language => "zh-TW" do |
|
407 | 407 | str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85" |
|
408 | 408 | if str_utf8.respond_to?(:force_encoding) |
|
409 | 409 | str_utf8.force_encoding('UTF-8') |
|
410 | 410 | end |
|
411 | 411 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, |
|
412 | 412 | :status_id => 1, :priority => IssuePriority.all.first, |
|
413 | 413 | :subject => str_utf8) |
|
414 | 414 | assert issue.save |
|
415 | 415 | |
|
416 | 416 | get :index, :project_id => 1, |
|
417 | 417 | :f => ['subject'], |
|
418 | 418 | :op => '=', :values => [str_utf8], |
|
419 | 419 | :c => ['status', 'subject'], |
|
420 | 420 | :format => 'csv', |
|
421 | 421 | :set_filter => 1 |
|
422 | 422 | assert_equal 'text/csv; header=present', @response.content_type |
|
423 | 423 | lines = @response.body.chomp.split("\n") |
|
424 | 424 | s1 = "\xaa\xac\xbaA" # status |
|
425 | 425 | if str_utf8.respond_to?(:force_encoding) |
|
426 | 426 | s1.force_encoding('Big5') |
|
427 | 427 | end |
|
428 | 428 | assert lines[0].include?(s1) |
|
429 | 429 | s2 = lines[1].split(",")[2] |
|
430 | 430 | if s1.respond_to?(:force_encoding) |
|
431 | 431 | s3 = "\xa5H?" # subject |
|
432 | 432 | s3.force_encoding('Big5') |
|
433 | 433 | assert_equal s3, s2 |
|
434 | 434 | elsif RUBY_PLATFORM == 'java' |
|
435 | 435 | assert_equal "??", s2 |
|
436 | 436 | else |
|
437 | 437 | assert_equal "\xa5H???", s2 |
|
438 | 438 | end |
|
439 | 439 | end |
|
440 | 440 | end |
|
441 | 441 | |
|
442 | 442 | def test_index_csv_tw |
|
443 | 443 | with_settings :default_language => "zh-TW" do |
|
444 | 444 | str1 = "test_index_csv_tw" |
|
445 | 445 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, |
|
446 | 446 | :status_id => 1, :priority => IssuePriority.all.first, |
|
447 | 447 | :subject => str1, :estimated_hours => '1234.5') |
|
448 | 448 | assert issue.save |
|
449 | 449 | assert_equal 1234.5, issue.estimated_hours |
|
450 | 450 | |
|
451 | 451 | get :index, :project_id => 1, |
|
452 | 452 | :f => ['subject'], |
|
453 | 453 | :op => '=', :values => [str1], |
|
454 | 454 | :c => ['estimated_hours', 'subject'], |
|
455 | 455 | :format => 'csv', |
|
456 | 456 | :set_filter => 1 |
|
457 | 457 | assert_equal 'text/csv; header=present', @response.content_type |
|
458 | 458 | lines = @response.body.chomp.split("\n") |
|
459 | 459 | assert_equal "#{issue.id},1234.50,#{str1}", lines[1] |
|
460 | 460 | |
|
461 | 461 | str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)" |
|
462 | 462 | if str_tw.respond_to?(:force_encoding) |
|
463 | 463 | str_tw.force_encoding('UTF-8') |
|
464 | 464 | end |
|
465 | 465 | assert_equal str_tw, l(:general_lang_name) |
|
466 | 466 | assert_equal ',', l(:general_csv_separator) |
|
467 | 467 | assert_equal '.', l(:general_csv_decimal_separator) |
|
468 | 468 | end |
|
469 | 469 | end |
|
470 | 470 | |
|
471 | 471 | def test_index_csv_fr |
|
472 | 472 | with_settings :default_language => "fr" do |
|
473 | 473 | str1 = "test_index_csv_fr" |
|
474 | 474 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, |
|
475 | 475 | :status_id => 1, :priority => IssuePriority.all.first, |
|
476 | 476 | :subject => str1, :estimated_hours => '1234.5') |
|
477 | 477 | assert issue.save |
|
478 | 478 | assert_equal 1234.5, issue.estimated_hours |
|
479 | 479 | |
|
480 | 480 | get :index, :project_id => 1, |
|
481 | 481 | :f => ['subject'], |
|
482 | 482 | :op => '=', :values => [str1], |
|
483 | 483 | :c => ['estimated_hours', 'subject'], |
|
484 | 484 | :format => 'csv', |
|
485 | 485 | :set_filter => 1 |
|
486 | 486 | assert_equal 'text/csv; header=present', @response.content_type |
|
487 | 487 | lines = @response.body.chomp.split("\n") |
|
488 | 488 | assert_equal "#{issue.id};1234,50;#{str1}", lines[1] |
|
489 | 489 | |
|
490 | 490 | str_fr = "Fran\xc3\xa7ais" |
|
491 | 491 | if str_fr.respond_to?(:force_encoding) |
|
492 | 492 | str_fr.force_encoding('UTF-8') |
|
493 | 493 | end |
|
494 | 494 | assert_equal str_fr, l(:general_lang_name) |
|
495 | 495 | assert_equal ';', l(:general_csv_separator) |
|
496 | 496 | assert_equal ',', l(:general_csv_decimal_separator) |
|
497 | 497 | end |
|
498 | 498 | end |
|
499 | 499 | |
|
500 | 500 | def test_index_pdf |
|
501 | 501 | ["en", "zh", "zh-TW", "ja", "ko"].each do |lang| |
|
502 | 502 | with_settings :default_language => lang do |
|
503 | 503 | |
|
504 | 504 | get :index |
|
505 | 505 | assert_response :success |
|
506 | 506 | assert_template 'index' |
|
507 | 507 | |
|
508 | 508 | if lang == "ja" |
|
509 | 509 | if RUBY_PLATFORM != 'java' |
|
510 | 510 | assert_equal "CP932", l(:general_pdf_encoding) |
|
511 | 511 | end |
|
512 | 512 | if RUBY_PLATFORM == 'java' && l(:general_pdf_encoding) == "CP932" |
|
513 | 513 | next |
|
514 | 514 | end |
|
515 | 515 | end |
|
516 | 516 | |
|
517 | 517 | get :index, :format => 'pdf' |
|
518 | 518 | assert_response :success |
|
519 | 519 | assert_not_nil assigns(:issues) |
|
520 | 520 | assert_equal 'application/pdf', @response.content_type |
|
521 | 521 | |
|
522 | 522 | get :index, :project_id => 1, :format => 'pdf' |
|
523 | 523 | assert_response :success |
|
524 | 524 | assert_not_nil assigns(:issues) |
|
525 | 525 | assert_equal 'application/pdf', @response.content_type |
|
526 | 526 | |
|
527 | 527 | get :index, :project_id => 1, :query_id => 6, :format => 'pdf' |
|
528 | 528 | assert_response :success |
|
529 | 529 | assert_not_nil assigns(:issues) |
|
530 | 530 | assert_equal 'application/pdf', @response.content_type |
|
531 | 531 | end |
|
532 | 532 | end |
|
533 | 533 | end |
|
534 | 534 | |
|
535 | 535 | def test_index_pdf_with_query_grouped_by_list_custom_field |
|
536 | 536 | get :index, :project_id => 1, :query_id => 9, :format => 'pdf' |
|
537 | 537 | assert_response :success |
|
538 | 538 | assert_not_nil assigns(:issues) |
|
539 | 539 | assert_not_nil assigns(:issue_count_by_group) |
|
540 | 540 | assert_equal 'application/pdf', @response.content_type |
|
541 | 541 | end |
|
542 | 542 | |
|
543 | 543 | def test_index_atom |
|
544 | 544 | get :index, :project_id => 'ecookbook', :format => 'atom' |
|
545 | 545 | assert_response :success |
|
546 | 546 | assert_template 'common/feed' |
|
547 | 547 | |
|
548 | 548 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
549 | 549 | :attributes => {:rel => 'self', :href => 'http://test.host/projects/ecookbook/issues.atom'} |
|
550 | 550 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
551 | 551 | :attributes => {:rel => 'alternate', :href => 'http://test.host/projects/ecookbook/issues'} |
|
552 | 552 | |
|
553 | 553 | assert_tag :tag => 'entry', :child => { |
|
554 | 554 | :tag => 'link', |
|
555 | 555 | :attributes => {:href => 'http://test.host/issues/1'}} |
|
556 | 556 | end |
|
557 | 557 | |
|
558 | 558 | def test_index_sort |
|
559 | 559 | get :index, :sort => 'tracker,id:desc' |
|
560 | 560 | assert_response :success |
|
561 | 561 | |
|
562 | 562 | sort_params = @request.session['issues_index_sort'] |
|
563 | 563 | assert sort_params.is_a?(String) |
|
564 | 564 | assert_equal 'tracker,id:desc', sort_params |
|
565 | 565 | |
|
566 | 566 | issues = assigns(:issues) |
|
567 | 567 | assert_not_nil issues |
|
568 | 568 | assert !issues.empty? |
|
569 | 569 | assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id) |
|
570 | 570 | end |
|
571 | 571 | |
|
572 | 572 | def test_index_sort_by_field_not_included_in_columns |
|
573 | 573 | Setting.issue_list_default_columns = %w(subject author) |
|
574 | 574 | get :index, :sort => 'tracker' |
|
575 | 575 | end |
|
576 | 576 | |
|
577 | 577 | def test_index_sort_by_assigned_to |
|
578 | 578 | get :index, :sort => 'assigned_to' |
|
579 | 579 | assert_response :success |
|
580 | 580 | assignees = assigns(:issues).collect(&:assigned_to).compact |
|
581 | 581 | assert_equal assignees.sort, assignees |
|
582 | 582 | end |
|
583 | 583 | |
|
584 | 584 | def test_index_sort_by_assigned_to_desc |
|
585 | 585 | get :index, :sort => 'assigned_to:desc' |
|
586 | 586 | assert_response :success |
|
587 | 587 | assignees = assigns(:issues).collect(&:assigned_to).compact |
|
588 | 588 | assert_equal assignees.sort.reverse, assignees |
|
589 | 589 | end |
|
590 | 590 | |
|
591 | 591 | def test_index_group_by_assigned_to |
|
592 | 592 | get :index, :group_by => 'assigned_to', :sort => 'priority' |
|
593 | 593 | assert_response :success |
|
594 | 594 | end |
|
595 | 595 | |
|
596 | 596 | def test_index_sort_by_author |
|
597 | 597 | get :index, :sort => 'author' |
|
598 | 598 | assert_response :success |
|
599 | 599 | authors = assigns(:issues).collect(&:author) |
|
600 | 600 | assert_equal authors.sort, authors |
|
601 | 601 | end |
|
602 | 602 | |
|
603 | 603 | def test_index_sort_by_author_desc |
|
604 | 604 | get :index, :sort => 'author:desc' |
|
605 | 605 | assert_response :success |
|
606 | 606 | authors = assigns(:issues).collect(&:author) |
|
607 | 607 | assert_equal authors.sort.reverse, authors |
|
608 | 608 | end |
|
609 | 609 | |
|
610 | 610 | def test_index_group_by_author |
|
611 | 611 | get :index, :group_by => 'author', :sort => 'priority' |
|
612 | 612 | assert_response :success |
|
613 | 613 | end |
|
614 | 614 | |
|
615 | 615 | def test_index_sort_by_spent_hours |
|
616 | 616 | get :index, :sort => 'spent_hours:desc' |
|
617 | 617 | assert_response :success |
|
618 | 618 | hours = assigns(:issues).collect(&:spent_hours) |
|
619 | 619 | assert_equal hours.sort.reverse, hours |
|
620 | 620 | end |
|
621 | 621 | |
|
622 | 622 | def test_index_with_columns |
|
623 | 623 | columns = ['tracker', 'subject', 'assigned_to'] |
|
624 | 624 | get :index, :set_filter => 1, :c => columns |
|
625 | 625 | assert_response :success |
|
626 | 626 | |
|
627 | 627 | # query should use specified columns |
|
628 | 628 | query = assigns(:query) |
|
629 | 629 | assert_kind_of Query, query |
|
630 | 630 | assert_equal columns, query.column_names.map(&:to_s) |
|
631 | 631 | |
|
632 | 632 | # columns should be stored in session |
|
633 | 633 | assert_kind_of Hash, session[:query] |
|
634 | 634 | assert_kind_of Array, session[:query][:column_names] |
|
635 | 635 | assert_equal columns, session[:query][:column_names].map(&:to_s) |
|
636 | 636 | |
|
637 | 637 | # ensure only these columns are kept in the selected columns list |
|
638 | 638 | assert_tag :tag => 'select', :attributes => { :id => 'selected_columns' }, |
|
639 | 639 | :children => { :count => 3 } |
|
640 | 640 | assert_no_tag :tag => 'option', :attributes => { :value => 'project' }, |
|
641 | 641 | :parent => { :tag => 'select', :attributes => { :id => "selected_columns" } } |
|
642 | 642 | end |
|
643 | 643 | |
|
644 | 644 | def test_index_without_project_should_implicitly_add_project_column_to_default_columns |
|
645 | 645 | Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to'] |
|
646 | 646 | get :index, :set_filter => 1 |
|
647 | 647 | |
|
648 | 648 | # query should use specified columns |
|
649 | 649 | query = assigns(:query) |
|
650 | 650 | assert_kind_of Query, query |
|
651 | 651 | assert_equal [:project, :tracker, :subject, :assigned_to], query.columns.map(&:name) |
|
652 | 652 | end |
|
653 | 653 | |
|
654 | 654 | def test_index_without_project_and_explicit_default_columns_should_not_add_project_column |
|
655 | 655 | Setting.issue_list_default_columns = ['tracker', 'subject', 'assigned_to'] |
|
656 | 656 | columns = ['tracker', 'subject', 'assigned_to'] |
|
657 | 657 | get :index, :set_filter => 1, :c => columns |
|
658 | 658 | |
|
659 | 659 | # query should use specified columns |
|
660 | 660 | query = assigns(:query) |
|
661 | 661 | assert_kind_of Query, query |
|
662 | 662 | assert_equal columns.map(&:to_sym), query.columns.map(&:name) |
|
663 | 663 | end |
|
664 | 664 | |
|
665 | 665 | def test_index_with_custom_field_column |
|
666 | 666 | columns = %w(tracker subject cf_2) |
|
667 | 667 | get :index, :set_filter => 1, :c => columns |
|
668 | 668 | assert_response :success |
|
669 | 669 | |
|
670 | 670 | # query should use specified columns |
|
671 | 671 | query = assigns(:query) |
|
672 | 672 | assert_kind_of Query, query |
|
673 | 673 | assert_equal columns, query.column_names.map(&:to_s) |
|
674 | 674 | |
|
675 | 675 | assert_tag :td, |
|
676 | 676 | :attributes => {:class => 'cf_2 string'}, |
|
677 | 677 | :ancestor => {:tag => 'table', :attributes => {:class => /issues/}} |
|
678 | 678 | end |
|
679 | 679 | |
|
680 | 680 | def test_index_with_multi_custom_field_column |
|
681 | 681 | field = CustomField.find(1) |
|
682 | 682 | field.update_attribute :multiple, true |
|
683 | 683 | issue = Issue.find(1) |
|
684 | 684 | issue.custom_field_values = {1 => ['MySQL', 'Oracle']} |
|
685 | 685 | issue.save! |
|
686 | 686 | |
|
687 | 687 | get :index, :set_filter => 1, :c => %w(tracker subject cf_1) |
|
688 | 688 | assert_response :success |
|
689 | 689 | |
|
690 | 690 | assert_tag :td, |
|
691 | 691 | :attributes => {:class => /cf_1/}, |
|
692 | 692 | :content => 'MySQL, Oracle' |
|
693 | 693 | end |
|
694 | 694 | |
|
695 | 695 | def test_index_with_multi_user_custom_field_column |
|
696 | 696 | field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true, |
|
697 | 697 | :tracker_ids => [1], :is_for_all => true) |
|
698 | 698 | issue = Issue.find(1) |
|
699 | 699 | issue.custom_field_values = {field.id => ['2', '3']} |
|
700 | 700 | issue.save! |
|
701 | 701 | |
|
702 | 702 | get :index, :set_filter => 1, :c => ['tracker', 'subject', "cf_#{field.id}"] |
|
703 | 703 | assert_response :success |
|
704 | 704 | |
|
705 | 705 | assert_tag :td, |
|
706 | 706 | :attributes => {:class => /cf_#{field.id}/}, |
|
707 | 707 | :child => {:tag => 'a', :content => 'John Smith'} |
|
708 | 708 | end |
|
709 | 709 | |
|
710 | 710 | def test_index_with_date_column |
|
711 | 711 | Issue.find(1).update_attribute :start_date, '1987-08-24' |
|
712 | 712 | |
|
713 | 713 | with_settings :date_format => '%d/%m/%Y' do |
|
714 | 714 | get :index, :set_filter => 1, :c => %w(start_date) |
|
715 | 715 | assert_tag 'td', :attributes => {:class => /start_date/}, :content => '24/08/1987' |
|
716 | 716 | end |
|
717 | 717 | end |
|
718 | 718 | |
|
719 | 719 | def test_index_with_done_ratio |
|
720 | 720 | Issue.find(1).update_attribute :done_ratio, 40 |
|
721 | 721 | |
|
722 | 722 | get :index, :set_filter => 1, :c => %w(done_ratio) |
|
723 | 723 | assert_tag 'td', :attributes => {:class => /done_ratio/}, |
|
724 | 724 | :child => {:tag => 'table', :attributes => {:class => 'progress'}, |
|
725 | 725 | :descendant => {:tag => 'td', :attributes => {:class => 'closed', :style => 'width: 40%;'}} |
|
726 | 726 | } |
|
727 | 727 | end |
|
728 | 728 | |
|
729 | 729 | def test_index_with_spent_hours_column |
|
730 | 730 | get :index, :set_filter => 1, :c => %w(subject spent_hours) |
|
731 | 731 | |
|
732 | 732 | assert_tag 'tr', :attributes => {:id => 'issue-3'}, |
|
733 | 733 | :child => { |
|
734 | 734 | :tag => 'td', :attributes => {:class => /spent_hours/}, :content => '1.00' |
|
735 | 735 | } |
|
736 | 736 | end |
|
737 | 737 | |
|
738 | 738 | def test_index_should_not_show_spent_hours_column_without_permission |
|
739 | 739 | Role.anonymous.remove_permission! :view_time_entries |
|
740 | 740 | get :index, :set_filter => 1, :c => %w(subject spent_hours) |
|
741 | 741 | |
|
742 | 742 | assert_no_tag 'td', :attributes => {:class => /spent_hours/} |
|
743 | 743 | end |
|
744 | 744 | |
|
745 | 745 | def test_index_with_fixed_version |
|
746 | 746 | get :index, :set_filter => 1, :c => %w(fixed_version) |
|
747 | 747 | assert_tag 'td', :attributes => {:class => /fixed_version/}, |
|
748 | 748 | :child => {:tag => 'a', :content => '1.0', :attributes => {:href => '/versions/2'}} |
|
749 | 749 | end |
|
750 | 750 | |
|
751 | 751 | def test_index_send_html_if_query_is_invalid |
|
752 | 752 | get :index, :f => ['start_date'], :op => {:start_date => '='} |
|
753 | 753 | assert_equal 'text/html', @response.content_type |
|
754 | 754 | assert_template 'index' |
|
755 | 755 | end |
|
756 | 756 | |
|
757 | 757 | def test_index_send_nothing_if_query_is_invalid |
|
758 | 758 | get :index, :f => ['start_date'], :op => {:start_date => '='}, :format => 'csv' |
|
759 | 759 | assert_equal 'text/csv', @response.content_type |
|
760 | 760 | assert @response.body.blank? |
|
761 | 761 | end |
|
762 | 762 | |
|
763 | 763 | def test_show_by_anonymous |
|
764 | 764 | get :show, :id => 1 |
|
765 | 765 | assert_response :success |
|
766 | 766 | assert_template 'show' |
|
767 | 767 | assert_not_nil assigns(:issue) |
|
768 | 768 | assert_equal Issue.find(1), assigns(:issue) |
|
769 | 769 | |
|
770 | 770 | # anonymous role is allowed to add a note |
|
771 | 771 | assert_tag :tag => 'form', |
|
772 | 772 | :descendant => { :tag => 'fieldset', |
|
773 | 773 | :child => { :tag => 'legend', |
|
774 | 774 | :content => /Notes/ } } |
|
775 | 775 | assert_tag :tag => 'title', |
|
776 | 776 | :content => "Bug #1: Can't print recipes - eCookbook - Redmine" |
|
777 | 777 | end |
|
778 | 778 | |
|
779 | 779 | def test_show_by_manager |
|
780 | 780 | @request.session[:user_id] = 2 |
|
781 | 781 | get :show, :id => 1 |
|
782 | 782 | assert_response :success |
|
783 | 783 | |
|
784 | 784 | assert_tag :tag => 'a', |
|
785 | 785 | :content => /Quote/ |
|
786 | 786 | |
|
787 | 787 | assert_tag :tag => 'form', |
|
788 | 788 | :descendant => { :tag => 'fieldset', |
|
789 | 789 | :child => { :tag => 'legend', |
|
790 | 790 | :content => /Change properties/ } }, |
|
791 | 791 | :descendant => { :tag => 'fieldset', |
|
792 | 792 | :child => { :tag => 'legend', |
|
793 | 793 | :content => /Log time/ } }, |
|
794 | 794 | :descendant => { :tag => 'fieldset', |
|
795 | 795 | :child => { :tag => 'legend', |
|
796 | 796 | :content => /Notes/ } } |
|
797 | 797 | end |
|
798 | 798 | |
|
799 | 799 | def test_show_should_display_update_form |
|
800 | 800 | @request.session[:user_id] = 2 |
|
801 | 801 | get :show, :id => 1 |
|
802 | 802 | assert_response :success |
|
803 | 803 | |
|
804 | 804 | assert_tag 'form', :attributes => {:id => 'issue-form'} |
|
805 | 805 | assert_tag 'input', :attributes => {:name => 'issue[is_private]'} |
|
806 | 806 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
807 | 807 | assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'} |
|
808 | 808 | assert_tag 'input', :attributes => {:name => 'issue[subject]'} |
|
809 | 809 | assert_tag 'textarea', :attributes => {:name => 'issue[description]'} |
|
810 | 810 | assert_tag 'select', :attributes => {:name => 'issue[status_id]'} |
|
811 | 811 | assert_tag 'select', :attributes => {:name => 'issue[priority_id]'} |
|
812 | 812 | assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'} |
|
813 | 813 | assert_tag 'select', :attributes => {:name => 'issue[category_id]'} |
|
814 | 814 | assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'} |
|
815 | 815 | assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'} |
|
816 | 816 | assert_tag 'input', :attributes => {:name => 'issue[start_date]'} |
|
817 | 817 | assert_tag 'input', :attributes => {:name => 'issue[due_date]'} |
|
818 | 818 | assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'} |
|
819 | 819 | assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' } |
|
820 | 820 | assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'} |
|
821 | 821 | assert_tag 'textarea', :attributes => {:name => 'notes'} |
|
822 | 822 | end |
|
823 | 823 | |
|
824 | 824 | def test_show_should_display_update_form_with_minimal_permissions |
|
825 | 825 | Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes] |
|
826 | 826 | Workflow.delete_all :role_id => 1 |
|
827 | 827 | |
|
828 | 828 | @request.session[:user_id] = 2 |
|
829 | 829 | get :show, :id => 1 |
|
830 | 830 | assert_response :success |
|
831 | 831 | |
|
832 | 832 | assert_tag 'form', :attributes => {:id => 'issue-form'} |
|
833 | 833 | assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'} |
|
834 | 834 | assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
835 | 835 | assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'} |
|
836 | 836 | assert_no_tag 'input', :attributes => {:name => 'issue[subject]'} |
|
837 | 837 | assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'} |
|
838 | 838 | assert_no_tag 'select', :attributes => {:name => 'issue[status_id]'} |
|
839 | 839 | assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'} |
|
840 | 840 | assert_no_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'} |
|
841 | 841 | assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'} |
|
842 | 842 | assert_no_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'} |
|
843 | 843 | assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'} |
|
844 | 844 | assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'} |
|
845 | 845 | assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'} |
|
846 | 846 | assert_no_tag 'select', :attributes => {:name => 'issue[done_ratio]'} |
|
847 | 847 | assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' } |
|
848 | 848 | assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'} |
|
849 | 849 | assert_tag 'textarea', :attributes => {:name => 'notes'} |
|
850 | 850 | end |
|
851 | 851 | |
|
852 | 852 | def test_show_should_display_update_form_with_workflow_permissions |
|
853 | 853 | Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes] |
|
854 | 854 | |
|
855 | 855 | @request.session[:user_id] = 2 |
|
856 | 856 | get :show, :id => 1 |
|
857 | 857 | assert_response :success |
|
858 | 858 | |
|
859 | 859 | assert_tag 'form', :attributes => {:id => 'issue-form'} |
|
860 | 860 | assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'} |
|
861 | 861 | assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
862 | 862 | assert_no_tag 'select', :attributes => {:name => 'issue[tracker_id]'} |
|
863 | 863 | assert_no_tag 'input', :attributes => {:name => 'issue[subject]'} |
|
864 | 864 | assert_no_tag 'textarea', :attributes => {:name => 'issue[description]'} |
|
865 | 865 | assert_tag 'select', :attributes => {:name => 'issue[status_id]'} |
|
866 | 866 | assert_no_tag 'select', :attributes => {:name => 'issue[priority_id]'} |
|
867 | 867 | assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'} |
|
868 | 868 | assert_no_tag 'select', :attributes => {:name => 'issue[category_id]'} |
|
869 | 869 | assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'} |
|
870 | 870 | assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'} |
|
871 | 871 | assert_no_tag 'input', :attributes => {:name => 'issue[start_date]'} |
|
872 | 872 | assert_no_tag 'input', :attributes => {:name => 'issue[due_date]'} |
|
873 | 873 | assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'} |
|
874 | 874 | assert_no_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]' } |
|
875 | 875 | assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'} |
|
876 | 876 | assert_tag 'textarea', :attributes => {:name => 'notes'} |
|
877 | 877 | end |
|
878 | 878 | |
|
879 | 879 | def test_show_should_not_display_update_form_without_permissions |
|
880 | 880 | Role.find(1).update_attribute :permissions, [:view_issues] |
|
881 | 881 | |
|
882 | 882 | @request.session[:user_id] = 2 |
|
883 | 883 | get :show, :id => 1 |
|
884 | 884 | assert_response :success |
|
885 | 885 | |
|
886 | 886 | assert_no_tag 'form', :attributes => {:id => 'issue-form'} |
|
887 | 887 | end |
|
888 | 888 | |
|
889 | 889 | def test_update_form_should_not_display_inactive_enumerations |
|
890 | 890 | @request.session[:user_id] = 2 |
|
891 | 891 | get :show, :id => 1 |
|
892 | 892 | assert_response :success |
|
893 | 893 | |
|
894 | 894 | assert ! IssuePriority.find(15).active? |
|
895 | 895 | assert_no_tag :option, :attributes => {:value => '15'}, |
|
896 | 896 | :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} } |
|
897 | 897 | end |
|
898 | 898 | |
|
899 | 899 | def test_update_form_should_allow_attachment_upload |
|
900 | 900 | @request.session[:user_id] = 2 |
|
901 | 901 | get :show, :id => 1 |
|
902 | 902 | |
|
903 | 903 | assert_tag :tag => 'form', |
|
904 | 904 | :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'}, |
|
905 | 905 | :descendant => { |
|
906 | 906 | :tag => 'input', |
|
907 | 907 | :attributes => {:type => 'file', :name => 'attachments[1][file]'} |
|
908 | 908 | } |
|
909 | 909 | end |
|
910 | 910 | |
|
911 | 911 | def test_show_should_deny_anonymous_access_without_permission |
|
912 | 912 | Role.anonymous.remove_permission!(:view_issues) |
|
913 | 913 | get :show, :id => 1 |
|
914 | 914 | assert_response :redirect |
|
915 | 915 | end |
|
916 | 916 | |
|
917 | 917 | def test_show_should_deny_anonymous_access_to_private_issue |
|
918 | 918 | Issue.update_all(["is_private = ?", true], "id = 1") |
|
919 | 919 | get :show, :id => 1 |
|
920 | 920 | assert_response :redirect |
|
921 | 921 | end |
|
922 | 922 | |
|
923 | 923 | def test_show_should_deny_non_member_access_without_permission |
|
924 | 924 | Role.non_member.remove_permission!(:view_issues) |
|
925 | 925 | @request.session[:user_id] = 9 |
|
926 | 926 | get :show, :id => 1 |
|
927 | 927 | assert_response 403 |
|
928 | 928 | end |
|
929 | 929 | |
|
930 | 930 | def test_show_should_deny_non_member_access_to_private_issue |
|
931 | 931 | Issue.update_all(["is_private = ?", true], "id = 1") |
|
932 | 932 | @request.session[:user_id] = 9 |
|
933 | 933 | get :show, :id => 1 |
|
934 | 934 | assert_response 403 |
|
935 | 935 | end |
|
936 | 936 | |
|
937 | 937 | def test_show_should_deny_member_access_without_permission |
|
938 | 938 | Role.find(1).remove_permission!(:view_issues) |
|
939 | 939 | @request.session[:user_id] = 2 |
|
940 | 940 | get :show, :id => 1 |
|
941 | 941 | assert_response 403 |
|
942 | 942 | end |
|
943 | 943 | |
|
944 | 944 | def test_show_should_deny_member_access_to_private_issue_without_permission |
|
945 | 945 | Issue.update_all(["is_private = ?", true], "id = 1") |
|
946 | 946 | @request.session[:user_id] = 3 |
|
947 | 947 | get :show, :id => 1 |
|
948 | 948 | assert_response 403 |
|
949 | 949 | end |
|
950 | 950 | |
|
951 | 951 | def test_show_should_allow_author_access_to_private_issue |
|
952 | 952 | Issue.update_all(["is_private = ?, author_id = 3", true], "id = 1") |
|
953 | 953 | @request.session[:user_id] = 3 |
|
954 | 954 | get :show, :id => 1 |
|
955 | 955 | assert_response :success |
|
956 | 956 | end |
|
957 | 957 | |
|
958 | 958 | def test_show_should_allow_assignee_access_to_private_issue |
|
959 | 959 | Issue.update_all(["is_private = ?, assigned_to_id = 3", true], "id = 1") |
|
960 | 960 | @request.session[:user_id] = 3 |
|
961 | 961 | get :show, :id => 1 |
|
962 | 962 | assert_response :success |
|
963 | 963 | end |
|
964 | 964 | |
|
965 | 965 | def test_show_should_allow_member_access_to_private_issue_with_permission |
|
966 | 966 | Issue.update_all(["is_private = ?", true], "id = 1") |
|
967 | 967 | User.find(3).roles_for_project(Project.find(1)).first.update_attribute :issues_visibility, 'all' |
|
968 | 968 | @request.session[:user_id] = 3 |
|
969 | 969 | get :show, :id => 1 |
|
970 | 970 | assert_response :success |
|
971 | 971 | end |
|
972 | 972 | |
|
973 | 973 | def test_show_should_not_disclose_relations_to_invisible_issues |
|
974 | 974 | Setting.cross_project_issue_relations = '1' |
|
975 | 975 | IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates') |
|
976 | 976 | # Relation to a private project issue |
|
977 | 977 | IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates') |
|
978 | 978 | |
|
979 | 979 | get :show, :id => 1 |
|
980 | 980 | assert_response :success |
|
981 | 981 | |
|
982 | 982 | assert_tag :div, :attributes => { :id => 'relations' }, |
|
983 | 983 | :descendant => { :tag => 'a', :content => /#2$/ } |
|
984 | 984 | assert_no_tag :div, :attributes => { :id => 'relations' }, |
|
985 | 985 | :descendant => { :tag => 'a', :content => /#4$/ } |
|
986 | 986 | end |
|
987 | 987 | |
|
988 | 988 | def test_show_should_list_subtasks |
|
989 | 989 | Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue') |
|
990 | 990 | |
|
991 | 991 | get :show, :id => 1 |
|
992 | 992 | assert_response :success |
|
993 | 993 | assert_tag 'div', :attributes => {:id => 'issue_tree'}, |
|
994 | 994 | :descendant => {:tag => 'td', :content => /Child Issue/, :attributes => {:class => /subject/}} |
|
995 | 995 | end |
|
996 | 996 | |
|
997 | 997 | def test_show_should_list_parents |
|
998 | 998 | issue = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :parent_issue_id => 1, :subject => 'Child Issue') |
|
999 | 999 | |
|
1000 | 1000 | get :show, :id => issue.id |
|
1001 | 1001 | assert_response :success |
|
1002 | 1002 | assert_tag 'div', :attributes => {:class => 'subject'}, |
|
1003 | 1003 | :descendant => {:tag => 'h3', :content => 'Child Issue'} |
|
1004 | 1004 | assert_tag 'div', :attributes => {:class => 'subject'}, |
|
1005 | 1005 | :descendant => {:tag => 'a', :attributes => {:href => '/issues/1'}} |
|
1006 | 1006 | end |
|
1007 | 1007 | |
|
1008 | 1008 | def test_show_should_not_display_prev_next_links_without_query_in_session |
|
1009 | 1009 | get :show, :id => 1 |
|
1010 | 1010 | assert_response :success |
|
1011 | 1011 | assert_nil assigns(:prev_issue_id) |
|
1012 | 1012 | assert_nil assigns(:next_issue_id) |
|
1013 | 1013 | |
|
1014 | 1014 | assert_no_tag 'div', :attributes => {:class => /next-prev-links/} |
|
1015 | 1015 | end |
|
1016 | 1016 | |
|
1017 | 1017 | def test_show_should_display_prev_next_links_with_query_in_session |
|
1018 | 1018 | @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil} |
|
1019 | 1019 | @request.session['issues_index_sort'] = 'id' |
|
1020 | 1020 | |
|
1021 | 1021 | with_settings :display_subprojects_issues => '0' do |
|
1022 | 1022 | get :show, :id => 3 |
|
1023 | 1023 | end |
|
1024 | 1024 | |
|
1025 | 1025 | assert_response :success |
|
1026 | 1026 | # Previous and next issues for all projects |
|
1027 | 1027 | assert_equal 2, assigns(:prev_issue_id) |
|
1028 | 1028 | assert_equal 5, assigns(:next_issue_id) |
|
1029 | 1029 | |
|
1030 | 1030 | assert_tag 'div', :attributes => {:class => /next-prev-links/} |
|
1031 | 1031 | assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/ |
|
1032 | 1032 | assert_tag 'a', :attributes => {:href => '/issues/5'}, :content => /Next/ |
|
1033 | 1033 | |
|
1034 | 1034 | count = Issue.open.visible.count |
|
1035 | 1035 | assert_tag 'span', :attributes => {:class => 'position'}, :content => "3 of #{count}" |
|
1036 | 1036 | end |
|
1037 | 1037 | |
|
1038 | 1038 | def test_show_should_display_prev_next_links_with_saved_query_in_session |
|
1039 | 1039 | query = Query.create!(:name => 'test', :is_public => true, :user_id => 1, |
|
1040 | 1040 | :filters => {'status_id' => {:values => ['5'], :operator => '='}}, |
|
1041 | 1041 | :sort_criteria => [['id', 'asc']]) |
|
1042 | 1042 | @request.session[:query] = {:id => query.id, :project_id => nil} |
|
1043 | 1043 | |
|
1044 | 1044 | get :show, :id => 11 |
|
1045 | 1045 | |
|
1046 | 1046 | assert_response :success |
|
1047 | 1047 | assert_equal query, assigns(:query) |
|
1048 | 1048 | # Previous and next issues for all projects |
|
1049 | 1049 | assert_equal 8, assigns(:prev_issue_id) |
|
1050 | 1050 | assert_equal 12, assigns(:next_issue_id) |
|
1051 | 1051 | |
|
1052 | 1052 | assert_tag 'a', :attributes => {:href => '/issues/8'}, :content => /Previous/ |
|
1053 | 1053 | assert_tag 'a', :attributes => {:href => '/issues/12'}, :content => /Next/ |
|
1054 | 1054 | end |
|
1055 | 1055 | |
|
1056 | 1056 | def test_show_should_display_prev_next_links_with_query_and_sort_on_association |
|
1057 | 1057 | @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil} |
|
1058 | 1058 | |
|
1059 | 1059 | %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort| |
|
1060 | 1060 | @request.session['issues_index_sort'] = assoc_sort |
|
1061 | 1061 | |
|
1062 | 1062 | get :show, :id => 3 |
|
1063 | 1063 | assert_response :success, "Wrong response status for #{assoc_sort} sort" |
|
1064 | 1064 | |
|
1065 | 1065 | assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Previous/ |
|
1066 | 1066 | assert_tag 'div', :attributes => {:class => /next-prev-links/}, :content => /Next/ |
|
1067 | 1067 | end |
|
1068 | 1068 | end |
|
1069 | 1069 | |
|
1070 | 1070 | def test_show_should_display_prev_next_links_with_project_query_in_session |
|
1071 | 1071 | @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1} |
|
1072 | 1072 | @request.session['issues_index_sort'] = 'id' |
|
1073 | 1073 | |
|
1074 | 1074 | with_settings :display_subprojects_issues => '0' do |
|
1075 | 1075 | get :show, :id => 3 |
|
1076 | 1076 | end |
|
1077 | 1077 | |
|
1078 | 1078 | assert_response :success |
|
1079 | 1079 | # Previous and next issues inside project |
|
1080 | 1080 | assert_equal 2, assigns(:prev_issue_id) |
|
1081 | 1081 | assert_equal 7, assigns(:next_issue_id) |
|
1082 | 1082 | |
|
1083 | 1083 | assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Previous/ |
|
1084 | 1084 | assert_tag 'a', :attributes => {:href => '/issues/7'}, :content => /Next/ |
|
1085 | 1085 | end |
|
1086 | 1086 | |
|
1087 | 1087 | def test_show_should_not_display_prev_link_for_first_issue |
|
1088 | 1088 | @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => 1} |
|
1089 | 1089 | @request.session['issues_index_sort'] = 'id' |
|
1090 | 1090 | |
|
1091 | 1091 | with_settings :display_subprojects_issues => '0' do |
|
1092 | 1092 | get :show, :id => 1 |
|
1093 | 1093 | end |
|
1094 | 1094 | |
|
1095 | 1095 | assert_response :success |
|
1096 | 1096 | assert_nil assigns(:prev_issue_id) |
|
1097 | 1097 | assert_equal 2, assigns(:next_issue_id) |
|
1098 | 1098 | |
|
1099 | 1099 | assert_no_tag 'a', :content => /Previous/ |
|
1100 | 1100 | assert_tag 'a', :attributes => {:href => '/issues/2'}, :content => /Next/ |
|
1101 | 1101 | end |
|
1102 | 1102 | |
|
1103 | 1103 | def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results |
|
1104 | 1104 | @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'c'}}, :project_id => 1} |
|
1105 | 1105 | @request.session['issues_index_sort'] = 'id' |
|
1106 | 1106 | |
|
1107 | 1107 | get :show, :id => 1 |
|
1108 | 1108 | |
|
1109 | 1109 | assert_response :success |
|
1110 | 1110 | assert_nil assigns(:prev_issue_id) |
|
1111 | 1111 | assert_nil assigns(:next_issue_id) |
|
1112 | 1112 | |
|
1113 | 1113 | assert_no_tag 'a', :content => /Previous/ |
|
1114 | 1114 | assert_no_tag 'a', :content => /Next/ |
|
1115 | 1115 | end |
|
1116 | 1116 | |
|
1117 | 1117 | def test_show_should_display_visible_changesets_from_other_projects |
|
1118 | 1118 | project = Project.find(2) |
|
1119 | 1119 | issue = project.issues.first |
|
1120 | 1120 | issue.changeset_ids = [102] |
|
1121 | 1121 | issue.save! |
|
1122 | 1122 | project.disable_module! :repository |
|
1123 | 1123 | |
|
1124 | 1124 | @request.session[:user_id] = 2 |
|
1125 | 1125 | get :show, :id => issue.id |
|
1126 | 1126 | assert_tag 'a', :attributes => {:href => "/projects/ecookbook/repository/revisions/3"} |
|
1127 | 1127 | end |
|
1128 | 1128 | |
|
1129 | 1129 | def test_show_with_multi_custom_field |
|
1130 | 1130 | field = CustomField.find(1) |
|
1131 | 1131 | field.update_attribute :multiple, true |
|
1132 | 1132 | issue = Issue.find(1) |
|
1133 | 1133 | issue.custom_field_values = {1 => ['MySQL', 'Oracle']} |
|
1134 | 1134 | issue.save! |
|
1135 | 1135 | |
|
1136 | 1136 | get :show, :id => 1 |
|
1137 | 1137 | assert_response :success |
|
1138 | 1138 | |
|
1139 | 1139 | assert_tag :td, :content => 'MySQL, Oracle' |
|
1140 | 1140 | end |
|
1141 | 1141 | |
|
1142 | 1142 | def test_show_with_multi_user_custom_field |
|
1143 | 1143 | field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true, |
|
1144 | 1144 | :tracker_ids => [1], :is_for_all => true) |
|
1145 | 1145 | issue = Issue.find(1) |
|
1146 | 1146 | issue.custom_field_values = {field.id => ['2', '3']} |
|
1147 | 1147 | issue.save! |
|
1148 | 1148 | |
|
1149 | 1149 | get :show, :id => 1 |
|
1150 | 1150 | assert_response :success |
|
1151 | 1151 | |
|
1152 | 1152 | # TODO: should display links |
|
1153 | 1153 | assert_tag :td, :content => 'Dave Lopper, John Smith' |
|
1154 | 1154 | end |
|
1155 | 1155 | |
|
1156 | 1156 | def test_show_atom |
|
1157 | 1157 | get :show, :id => 2, :format => 'atom' |
|
1158 | 1158 | assert_response :success |
|
1159 | 1159 | assert_template 'journals/index' |
|
1160 | 1160 | # Inline image |
|
1161 | 1161 | assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10')) |
|
1162 | 1162 | end |
|
1163 | 1163 | |
|
1164 | 1164 | def test_show_export_to_pdf |
|
1165 | 1165 | get :show, :id => 3, :format => 'pdf' |
|
1166 | 1166 | assert_response :success |
|
1167 | 1167 | assert_equal 'application/pdf', @response.content_type |
|
1168 | 1168 | assert @response.body.starts_with?('%PDF') |
|
1169 | 1169 | assert_not_nil assigns(:issue) |
|
1170 | 1170 | end |
|
1171 | 1171 | |
|
1172 | 1172 | def test_show_export_to_pdf_with_ancestors |
|
1173 | 1173 | issue = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1) |
|
1174 | 1174 | |
|
1175 | 1175 | get :show, :id => issue.id, :format => 'pdf' |
|
1176 | 1176 | assert_response :success |
|
1177 | 1177 | assert_equal 'application/pdf', @response.content_type |
|
1178 | 1178 | assert @response.body.starts_with?('%PDF') |
|
1179 | 1179 | end |
|
1180 | 1180 | |
|
1181 | 1181 | def test_show_export_to_pdf_with_descendants |
|
1182 | 1182 | c1 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1) |
|
1183 | 1183 | c2 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => 1) |
|
1184 | 1184 | c3 = Issue.generate!(:project_id => 1, :author_id => 2, :tracker_id => 1, :subject => 'child', :parent_issue_id => c1.id) |
|
1185 | 1185 | |
|
1186 | 1186 | get :show, :id => 1, :format => 'pdf' |
|
1187 | 1187 | assert_response :success |
|
1188 | 1188 | assert_equal 'application/pdf', @response.content_type |
|
1189 | 1189 | assert @response.body.starts_with?('%PDF') |
|
1190 | 1190 | end |
|
1191 | 1191 | |
|
1192 | 1192 | def test_show_export_to_pdf_with_journals |
|
1193 | 1193 | get :show, :id => 1, :format => 'pdf' |
|
1194 | 1194 | assert_response :success |
|
1195 | 1195 | assert_equal 'application/pdf', @response.content_type |
|
1196 | 1196 | assert @response.body.starts_with?('%PDF') |
|
1197 | 1197 | end |
|
1198 | 1198 | |
|
1199 | 1199 | def test_show_export_to_pdf_with_changesets |
|
1200 | 1200 | Issue.find(3).changesets = Changeset.find_all_by_id(100, 101, 102) |
|
1201 | 1201 | |
|
1202 | 1202 | get :show, :id => 3, :format => 'pdf' |
|
1203 | 1203 | assert_response :success |
|
1204 | 1204 | assert_equal 'application/pdf', @response.content_type |
|
1205 | 1205 | assert @response.body.starts_with?('%PDF') |
|
1206 | 1206 | end |
|
1207 | 1207 | |
|
1208 | 1208 | def test_get_new |
|
1209 | 1209 | @request.session[:user_id] = 2 |
|
1210 | 1210 | get :new, :project_id => 1, :tracker_id => 1 |
|
1211 | 1211 | assert_response :success |
|
1212 | 1212 | assert_template 'new' |
|
1213 | 1213 | |
|
1214 | 1214 | assert_tag 'input', :attributes => {:name => 'issue[is_private]'} |
|
1215 | 1215 | assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
1216 | 1216 | assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'} |
|
1217 | 1217 | assert_tag 'input', :attributes => {:name => 'issue[subject]'} |
|
1218 | 1218 | assert_tag 'textarea', :attributes => {:name => 'issue[description]'} |
|
1219 | 1219 | assert_tag 'select', :attributes => {:name => 'issue[status_id]'} |
|
1220 | 1220 | assert_tag 'select', :attributes => {:name => 'issue[priority_id]'} |
|
1221 | 1221 | assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'} |
|
1222 | 1222 | assert_tag 'select', :attributes => {:name => 'issue[category_id]'} |
|
1223 | 1223 | assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'} |
|
1224 | 1224 | assert_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'} |
|
1225 | 1225 | assert_tag 'input', :attributes => {:name => 'issue[start_date]'} |
|
1226 | 1226 | assert_tag 'input', :attributes => {:name => 'issue[due_date]'} |
|
1227 | 1227 | assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'} |
|
1228 | 1228 | assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' } |
|
1229 | 1229 | assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'} |
|
1230 | 1230 | |
|
1231 | 1231 | # Be sure we don't display inactive IssuePriorities |
|
1232 | 1232 | assert ! IssuePriority.find(15).active? |
|
1233 | 1233 | assert_no_tag :option, :attributes => {:value => '15'}, |
|
1234 | 1234 | :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} } |
|
1235 | 1235 | end |
|
1236 | 1236 | |
|
1237 | 1237 | def test_get_new_with_minimal_permissions |
|
1238 | 1238 | Role.find(1).update_attribute :permissions, [:add_issues] |
|
1239 | 1239 | Workflow.delete_all :role_id => 1 |
|
1240 | 1240 | |
|
1241 | 1241 | @request.session[:user_id] = 2 |
|
1242 | 1242 | get :new, :project_id => 1, :tracker_id => 1 |
|
1243 | 1243 | assert_response :success |
|
1244 | 1244 | assert_template 'new' |
|
1245 | 1245 | |
|
1246 | 1246 | assert_no_tag 'input', :attributes => {:name => 'issue[is_private]'} |
|
1247 | 1247 | assert_no_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
1248 | 1248 | assert_tag 'select', :attributes => {:name => 'issue[tracker_id]'} |
|
1249 | 1249 | assert_tag 'input', :attributes => {:name => 'issue[subject]'} |
|
1250 | 1250 | assert_tag 'textarea', :attributes => {:name => 'issue[description]'} |
|
1251 | 1251 | assert_tag 'select', :attributes => {:name => 'issue[status_id]'} |
|
1252 | 1252 | assert_tag 'select', :attributes => {:name => 'issue[priority_id]'} |
|
1253 | 1253 | assert_tag 'select', :attributes => {:name => 'issue[assigned_to_id]'} |
|
1254 | 1254 | assert_tag 'select', :attributes => {:name => 'issue[category_id]'} |
|
1255 | 1255 | assert_tag 'select', :attributes => {:name => 'issue[fixed_version_id]'} |
|
1256 | 1256 | assert_no_tag 'input', :attributes => {:name => 'issue[parent_issue_id]'} |
|
1257 | 1257 | assert_tag 'input', :attributes => {:name => 'issue[start_date]'} |
|
1258 | 1258 | assert_tag 'input', :attributes => {:name => 'issue[due_date]'} |
|
1259 | 1259 | assert_tag 'select', :attributes => {:name => 'issue[done_ratio]'} |
|
1260 | 1260 | assert_tag 'input', :attributes => { :name => 'issue[custom_field_values][2]', :value => 'Default string' } |
|
1261 | 1261 | assert_no_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]'} |
|
1262 | 1262 | end |
|
1263 | 1263 | |
|
1264 | 1264 | def test_get_new_with_list_custom_field |
|
1265 | 1265 | @request.session[:user_id] = 2 |
|
1266 | 1266 | get :new, :project_id => 1, :tracker_id => 1 |
|
1267 | 1267 | assert_response :success |
|
1268 | 1268 | assert_template 'new' |
|
1269 | 1269 | |
|
1270 | 1270 | assert_tag 'select', |
|
1271 | :attributes => {:name => 'issue[custom_field_values][1]'}, | |
|
1271 | :attributes => {:name => 'issue[custom_field_values][1]', :class => 'list_cf'}, | |
|
1272 | 1272 | :children => {:count => 4}, |
|
1273 | 1273 | :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'} |
|
1274 | 1274 | end |
|
1275 | 1275 | |
|
1276 | 1276 | def test_get_new_with_multi_custom_field |
|
1277 | 1277 | field = IssueCustomField.find(1) |
|
1278 | 1278 | field.update_attribute :multiple, true |
|
1279 | 1279 | |
|
1280 | 1280 | @request.session[:user_id] = 2 |
|
1281 | 1281 | get :new, :project_id => 1, :tracker_id => 1 |
|
1282 | 1282 | assert_response :success |
|
1283 | 1283 | assert_template 'new' |
|
1284 | 1284 | |
|
1285 | 1285 | assert_tag 'select', |
|
1286 | 1286 | :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'}, |
|
1287 | 1287 | :children => {:count => 3}, |
|
1288 | 1288 | :child => {:tag => 'option', :attributes => {:value => 'MySQL'}, :content => 'MySQL'} |
|
1289 | 1289 | assert_tag 'input', |
|
1290 | 1290 | :attributes => {:name => 'issue[custom_field_values][1][]', :value => ''} |
|
1291 | 1291 | end |
|
1292 | 1292 | |
|
1293 | 1293 | def test_get_new_with_multi_user_custom_field |
|
1294 | 1294 | field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true, |
|
1295 | 1295 | :tracker_ids => [1], :is_for_all => true) |
|
1296 | 1296 | |
|
1297 | 1297 | @request.session[:user_id] = 2 |
|
1298 | 1298 | get :new, :project_id => 1, :tracker_id => 1 |
|
1299 | 1299 | assert_response :success |
|
1300 | 1300 | assert_template 'new' |
|
1301 | 1301 | |
|
1302 | 1302 | assert_tag 'select', |
|
1303 | 1303 | :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :multiple => 'multiple'}, |
|
1304 | 1304 | :children => {:count => Project.find(1).users.count}, |
|
1305 | 1305 | :child => {:tag => 'option', :attributes => {:value => '2'}, :content => 'John Smith'} |
|
1306 | 1306 | assert_tag 'input', |
|
1307 | 1307 | :attributes => {:name => "issue[custom_field_values][#{field.id}][]", :value => ''} |
|
1308 | 1308 | end |
|
1309 | 1309 | |
|
1310 | 1310 | def test_get_new_without_default_start_date_is_creation_date |
|
1311 | 1311 | Setting.default_issue_start_date_to_creation_date = 0 |
|
1312 | 1312 | |
|
1313 | 1313 | @request.session[:user_id] = 2 |
|
1314 | 1314 | get :new, :project_id => 1, :tracker_id => 1 |
|
1315 | 1315 | assert_response :success |
|
1316 | 1316 | assert_template 'new' |
|
1317 | 1317 | |
|
1318 | 1318 | assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]', |
|
1319 | 1319 | :value => nil } |
|
1320 | 1320 | end |
|
1321 | 1321 | |
|
1322 | 1322 | def test_get_new_with_default_start_date_is_creation_date |
|
1323 | 1323 | Setting.default_issue_start_date_to_creation_date = 1 |
|
1324 | 1324 | |
|
1325 | 1325 | @request.session[:user_id] = 2 |
|
1326 | 1326 | get :new, :project_id => 1, :tracker_id => 1 |
|
1327 | 1327 | assert_response :success |
|
1328 | 1328 | assert_template 'new' |
|
1329 | 1329 | |
|
1330 | 1330 | assert_tag :tag => 'input', :attributes => { :name => 'issue[start_date]', |
|
1331 | 1331 | :value => Date.today.to_s } |
|
1332 | 1332 | end |
|
1333 | 1333 | |
|
1334 | 1334 | def test_get_new_form_should_allow_attachment_upload |
|
1335 | 1335 | @request.session[:user_id] = 2 |
|
1336 | 1336 | get :new, :project_id => 1, :tracker_id => 1 |
|
1337 | 1337 | |
|
1338 | 1338 | assert_tag :tag => 'form', |
|
1339 | 1339 | :attributes => {:id => 'issue-form', :method => 'post', :enctype => 'multipart/form-data'}, |
|
1340 | 1340 | :descendant => { |
|
1341 | 1341 | :tag => 'input', |
|
1342 | 1342 | :attributes => {:type => 'file', :name => 'attachments[1][file]'} |
|
1343 | 1343 | } |
|
1344 | 1344 | end |
|
1345 | 1345 | |
|
1346 | 1346 | def test_get_new_should_prefill_the_form_from_params |
|
1347 | 1347 | @request.session[:user_id] = 2 |
|
1348 | 1348 | get :new, :project_id => 1, |
|
1349 | 1349 | :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}} |
|
1350 | 1350 | |
|
1351 | 1351 | issue = assigns(:issue) |
|
1352 | 1352 | assert_equal 3, issue.tracker_id |
|
1353 | 1353 | assert_equal 'Prefilled', issue.description |
|
1354 | 1354 | assert_equal 'Custom field value', issue.custom_field_value(2) |
|
1355 | 1355 | |
|
1356 | 1356 | assert_tag 'select', |
|
1357 | 1357 | :attributes => {:name => 'issue[tracker_id]'}, |
|
1358 | 1358 | :child => {:tag => 'option', :attributes => {:value => '3', :selected => 'selected'}} |
|
1359 | 1359 | assert_tag 'textarea', |
|
1360 | 1360 | :attributes => {:name => 'issue[description]'}, :content => "\nPrefilled" |
|
1361 | 1361 | assert_tag 'input', |
|
1362 | 1362 | :attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'} |
|
1363 | 1363 | end |
|
1364 | 1364 | |
|
1365 | 1365 | def test_get_new_without_tracker_id |
|
1366 | 1366 | @request.session[:user_id] = 2 |
|
1367 | 1367 | get :new, :project_id => 1 |
|
1368 | 1368 | assert_response :success |
|
1369 | 1369 | assert_template 'new' |
|
1370 | 1370 | |
|
1371 | 1371 | issue = assigns(:issue) |
|
1372 | 1372 | assert_not_nil issue |
|
1373 | 1373 | assert_equal Project.find(1).trackers.first, issue.tracker |
|
1374 | 1374 | end |
|
1375 | 1375 | |
|
1376 | 1376 | def test_get_new_with_no_default_status_should_display_an_error |
|
1377 | 1377 | @request.session[:user_id] = 2 |
|
1378 | 1378 | IssueStatus.delete_all |
|
1379 | 1379 | |
|
1380 | 1380 | get :new, :project_id => 1 |
|
1381 | 1381 | assert_response 500 |
|
1382 | 1382 | assert_error_tag :content => /No default issue/ |
|
1383 | 1383 | end |
|
1384 | 1384 | |
|
1385 | 1385 | def test_get_new_with_no_tracker_should_display_an_error |
|
1386 | 1386 | @request.session[:user_id] = 2 |
|
1387 | 1387 | Tracker.delete_all |
|
1388 | 1388 | |
|
1389 | 1389 | get :new, :project_id => 1 |
|
1390 | 1390 | assert_response 500 |
|
1391 | 1391 | assert_error_tag :content => /No tracker/ |
|
1392 | 1392 | end |
|
1393 | 1393 | |
|
1394 | 1394 | def test_update_new_form |
|
1395 | 1395 | @request.session[:user_id] = 2 |
|
1396 | 1396 | xhr :post, :new, :project_id => 1, |
|
1397 | 1397 | :issue => {:tracker_id => 2, |
|
1398 | 1398 | :subject => 'This is the test_new issue', |
|
1399 | 1399 | :description => 'This is the description', |
|
1400 | 1400 | :priority_id => 5} |
|
1401 | 1401 | assert_response :success |
|
1402 | 1402 | assert_template 'attributes' |
|
1403 | 1403 | |
|
1404 | 1404 | issue = assigns(:issue) |
|
1405 | 1405 | assert_kind_of Issue, issue |
|
1406 | 1406 | assert_equal 1, issue.project_id |
|
1407 | 1407 | assert_equal 2, issue.tracker_id |
|
1408 | 1408 | assert_equal 'This is the test_new issue', issue.subject |
|
1409 | 1409 | end |
|
1410 | 1410 | |
|
1411 | 1411 | def test_update_new_form_should_propose_transitions_based_on_initial_status |
|
1412 | 1412 | @request.session[:user_id] = 2 |
|
1413 | 1413 | Workflow.delete_all |
|
1414 | 1414 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2) |
|
1415 | 1415 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5) |
|
1416 | 1416 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4) |
|
1417 | 1417 | |
|
1418 | 1418 | xhr :post, :new, :project_id => 1, |
|
1419 | 1419 | :issue => {:tracker_id => 1, |
|
1420 | 1420 | :status_id => 5, |
|
1421 | 1421 | :subject => 'This is an issue'} |
|
1422 | 1422 | |
|
1423 | 1423 | assert_equal 5, assigns(:issue).status_id |
|
1424 | 1424 | assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort |
|
1425 | 1425 | end |
|
1426 | 1426 | |
|
1427 | 1427 | def test_post_create |
|
1428 | 1428 | @request.session[:user_id] = 2 |
|
1429 | 1429 | assert_difference 'Issue.count' do |
|
1430 | 1430 | post :create, :project_id => 1, |
|
1431 | 1431 | :issue => {:tracker_id => 3, |
|
1432 | 1432 | :status_id => 2, |
|
1433 | 1433 | :subject => 'This is the test_new issue', |
|
1434 | 1434 | :description => 'This is the description', |
|
1435 | 1435 | :priority_id => 5, |
|
1436 | 1436 | :start_date => '2010-11-07', |
|
1437 | 1437 | :estimated_hours => '', |
|
1438 | 1438 | :custom_field_values => {'2' => 'Value for field 2'}} |
|
1439 | 1439 | end |
|
1440 | 1440 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1441 | 1441 | |
|
1442 | 1442 | issue = Issue.find_by_subject('This is the test_new issue') |
|
1443 | 1443 | assert_not_nil issue |
|
1444 | 1444 | assert_equal 2, issue.author_id |
|
1445 | 1445 | assert_equal 3, issue.tracker_id |
|
1446 | 1446 | assert_equal 2, issue.status_id |
|
1447 | 1447 | assert_equal Date.parse('2010-11-07'), issue.start_date |
|
1448 | 1448 | assert_nil issue.estimated_hours |
|
1449 | 1449 | v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2}) |
|
1450 | 1450 | assert_not_nil v |
|
1451 | 1451 | assert_equal 'Value for field 2', v.value |
|
1452 | 1452 | end |
|
1453 | 1453 | |
|
1454 | 1454 | def test_post_new_with_group_assignment |
|
1455 | 1455 | group = Group.find(11) |
|
1456 | 1456 | project = Project.find(1) |
|
1457 | 1457 | project.members << Member.new(:principal => group, :roles => [Role.givable.first]) |
|
1458 | 1458 | |
|
1459 | 1459 | with_settings :issue_group_assignment => '1' do |
|
1460 | 1460 | @request.session[:user_id] = 2 |
|
1461 | 1461 | assert_difference 'Issue.count' do |
|
1462 | 1462 | post :create, :project_id => project.id, |
|
1463 | 1463 | :issue => {:tracker_id => 3, |
|
1464 | 1464 | :status_id => 1, |
|
1465 | 1465 | :subject => 'This is the test_new_with_group_assignment issue', |
|
1466 | 1466 | :assigned_to_id => group.id} |
|
1467 | 1467 | end |
|
1468 | 1468 | end |
|
1469 | 1469 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1470 | 1470 | |
|
1471 | 1471 | issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue') |
|
1472 | 1472 | assert_not_nil issue |
|
1473 | 1473 | assert_equal group, issue.assigned_to |
|
1474 | 1474 | end |
|
1475 | 1475 | |
|
1476 | 1476 | def test_post_create_without_start_date_and_default_start_date_is_not_creation_date |
|
1477 | 1477 | Setting.default_issue_start_date_to_creation_date = 0 |
|
1478 | 1478 | |
|
1479 | 1479 | @request.session[:user_id] = 2 |
|
1480 | 1480 | assert_difference 'Issue.count' do |
|
1481 | 1481 | post :create, :project_id => 1, |
|
1482 | 1482 | :issue => {:tracker_id => 3, |
|
1483 | 1483 | :status_id => 2, |
|
1484 | 1484 | :subject => 'This is the test_new issue', |
|
1485 | 1485 | :description => 'This is the description', |
|
1486 | 1486 | :priority_id => 5, |
|
1487 | 1487 | :estimated_hours => '', |
|
1488 | 1488 | :custom_field_values => {'2' => 'Value for field 2'}} |
|
1489 | 1489 | end |
|
1490 | 1490 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1491 | 1491 | |
|
1492 | 1492 | issue = Issue.find_by_subject('This is the test_new issue') |
|
1493 | 1493 | assert_not_nil issue |
|
1494 | 1494 | assert_nil issue.start_date |
|
1495 | 1495 | end |
|
1496 | 1496 | |
|
1497 | 1497 | def test_post_create_without_start_date_and_default_start_date_is_creation_date |
|
1498 | 1498 | Setting.default_issue_start_date_to_creation_date = 1 |
|
1499 | 1499 | |
|
1500 | 1500 | @request.session[:user_id] = 2 |
|
1501 | 1501 | assert_difference 'Issue.count' do |
|
1502 | 1502 | post :create, :project_id => 1, |
|
1503 | 1503 | :issue => {:tracker_id => 3, |
|
1504 | 1504 | :status_id => 2, |
|
1505 | 1505 | :subject => 'This is the test_new issue', |
|
1506 | 1506 | :description => 'This is the description', |
|
1507 | 1507 | :priority_id => 5, |
|
1508 | 1508 | :estimated_hours => '', |
|
1509 | 1509 | :custom_field_values => {'2' => 'Value for field 2'}} |
|
1510 | 1510 | end |
|
1511 | 1511 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1512 | 1512 | |
|
1513 | 1513 | issue = Issue.find_by_subject('This is the test_new issue') |
|
1514 | 1514 | assert_not_nil issue |
|
1515 | 1515 | assert_equal Date.today, issue.start_date |
|
1516 | 1516 | end |
|
1517 | 1517 | |
|
1518 | 1518 | def test_post_create_and_continue |
|
1519 | 1519 | @request.session[:user_id] = 2 |
|
1520 | 1520 | assert_difference 'Issue.count' do |
|
1521 | 1521 | post :create, :project_id => 1, |
|
1522 | 1522 | :issue => {:tracker_id => 3, :subject => 'This is first issue', :priority_id => 5}, |
|
1523 | 1523 | :continue => '' |
|
1524 | 1524 | end |
|
1525 | 1525 | |
|
1526 | 1526 | issue = Issue.first(:order => 'id DESC') |
|
1527 | 1527 | assert_redirected_to :controller => 'issues', :action => 'new', :project_id => 'ecookbook', :issue => {:tracker_id => 3} |
|
1528 | 1528 | assert_not_nil flash[:notice], "flash was not set" |
|
1529 | 1529 | assert flash[:notice].include?("<a href='/issues/#{issue.id}'>##{issue.id}</a>"), "issue link not found in flash: #{flash[:notice]}" |
|
1530 | 1530 | end |
|
1531 | 1531 | |
|
1532 | 1532 | def test_post_create_without_custom_fields_param |
|
1533 | 1533 | @request.session[:user_id] = 2 |
|
1534 | 1534 | assert_difference 'Issue.count' do |
|
1535 | 1535 | post :create, :project_id => 1, |
|
1536 | 1536 | :issue => {:tracker_id => 1, |
|
1537 | 1537 | :subject => 'This is the test_new issue', |
|
1538 | 1538 | :description => 'This is the description', |
|
1539 | 1539 | :priority_id => 5} |
|
1540 | 1540 | end |
|
1541 | 1541 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1542 | 1542 | end |
|
1543 | 1543 | |
|
1544 | 1544 | def test_post_create_with_multi_custom_field |
|
1545 | 1545 | field = IssueCustomField.find_by_name('Database') |
|
1546 | 1546 | field.update_attribute(:multiple, true) |
|
1547 | 1547 | |
|
1548 | 1548 | @request.session[:user_id] = 2 |
|
1549 | 1549 | assert_difference 'Issue.count' do |
|
1550 | 1550 | post :create, :project_id => 1, |
|
1551 | 1551 | :issue => {:tracker_id => 1, |
|
1552 | 1552 | :subject => 'This is the test_new issue', |
|
1553 | 1553 | :description => 'This is the description', |
|
1554 | 1554 | :priority_id => 5, |
|
1555 | 1555 | :custom_field_values => {'1' => ['', 'MySQL', 'Oracle']}} |
|
1556 | 1556 | end |
|
1557 | 1557 | assert_response 302 |
|
1558 | 1558 | issue = Issue.first(:order => 'id DESC') |
|
1559 | 1559 | assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort |
|
1560 | 1560 | end |
|
1561 | 1561 | |
|
1562 | 1562 | def test_post_create_with_empty_multi_custom_field |
|
1563 | 1563 | field = IssueCustomField.find_by_name('Database') |
|
1564 | 1564 | field.update_attribute(:multiple, true) |
|
1565 | 1565 | |
|
1566 | 1566 | @request.session[:user_id] = 2 |
|
1567 | 1567 | assert_difference 'Issue.count' do |
|
1568 | 1568 | post :create, :project_id => 1, |
|
1569 | 1569 | :issue => {:tracker_id => 1, |
|
1570 | 1570 | :subject => 'This is the test_new issue', |
|
1571 | 1571 | :description => 'This is the description', |
|
1572 | 1572 | :priority_id => 5, |
|
1573 | 1573 | :custom_field_values => {'1' => ['']}} |
|
1574 | 1574 | end |
|
1575 | 1575 | assert_response 302 |
|
1576 | 1576 | issue = Issue.first(:order => 'id DESC') |
|
1577 | 1577 | assert_equal [''], issue.custom_field_value(1).sort |
|
1578 | 1578 | end |
|
1579 | 1579 | |
|
1580 | 1580 | def test_post_create_with_multi_user_custom_field |
|
1581 | 1581 | field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true, |
|
1582 | 1582 | :tracker_ids => [1], :is_for_all => true) |
|
1583 | 1583 | |
|
1584 | 1584 | @request.session[:user_id] = 2 |
|
1585 | 1585 | assert_difference 'Issue.count' do |
|
1586 | 1586 | post :create, :project_id => 1, |
|
1587 | 1587 | :issue => {:tracker_id => 1, |
|
1588 | 1588 | :subject => 'This is the test_new issue', |
|
1589 | 1589 | :description => 'This is the description', |
|
1590 | 1590 | :priority_id => 5, |
|
1591 | 1591 | :custom_field_values => {field.id.to_s => ['', '2', '3']}} |
|
1592 | 1592 | end |
|
1593 | 1593 | assert_response 302 |
|
1594 | 1594 | issue = Issue.first(:order => 'id DESC') |
|
1595 | 1595 | assert_equal ['2', '3'], issue.custom_field_value(field).sort |
|
1596 | 1596 | end |
|
1597 | 1597 | |
|
1598 | 1598 | def test_post_create_with_required_custom_field_and_without_custom_fields_param |
|
1599 | 1599 | field = IssueCustomField.find_by_name('Database') |
|
1600 | 1600 | field.update_attribute(:is_required, true) |
|
1601 | 1601 | |
|
1602 | 1602 | @request.session[:user_id] = 2 |
|
1603 | 1603 | assert_no_difference 'Issue.count' do |
|
1604 | 1604 | post :create, :project_id => 1, |
|
1605 | 1605 | :issue => {:tracker_id => 1, |
|
1606 | 1606 | :subject => 'This is the test_new issue', |
|
1607 | 1607 | :description => 'This is the description', |
|
1608 | 1608 | :priority_id => 5} |
|
1609 | 1609 | end |
|
1610 | 1610 | assert_response :success |
|
1611 | 1611 | assert_template 'new' |
|
1612 | 1612 | issue = assigns(:issue) |
|
1613 | 1613 | assert_not_nil issue |
|
1614 | 1614 | assert_error_tag :content => /Database can't be blank/ |
|
1615 | 1615 | end |
|
1616 | 1616 | |
|
1617 | 1617 | def test_post_create_with_watchers |
|
1618 | 1618 | @request.session[:user_id] = 2 |
|
1619 | 1619 | ActionMailer::Base.deliveries.clear |
|
1620 | 1620 | |
|
1621 | 1621 | assert_difference 'Watcher.count', 2 do |
|
1622 | 1622 | post :create, :project_id => 1, |
|
1623 | 1623 | :issue => {:tracker_id => 1, |
|
1624 | 1624 | :subject => 'This is a new issue with watchers', |
|
1625 | 1625 | :description => 'This is the description', |
|
1626 | 1626 | :priority_id => 5, |
|
1627 | 1627 | :watcher_user_ids => ['2', '3']} |
|
1628 | 1628 | end |
|
1629 | 1629 | issue = Issue.find_by_subject('This is a new issue with watchers') |
|
1630 | 1630 | assert_not_nil issue |
|
1631 | 1631 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue |
|
1632 | 1632 | |
|
1633 | 1633 | # Watchers added |
|
1634 | 1634 | assert_equal [2, 3], issue.watcher_user_ids.sort |
|
1635 | 1635 | assert issue.watched_by?(User.find(3)) |
|
1636 | 1636 | # Watchers notified |
|
1637 | 1637 | mail = ActionMailer::Base.deliveries.last |
|
1638 | 1638 | assert_not_nil mail |
|
1639 | 1639 | assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail) |
|
1640 | 1640 | end |
|
1641 | 1641 | |
|
1642 | 1642 | def test_post_create_subissue |
|
1643 | 1643 | @request.session[:user_id] = 2 |
|
1644 | 1644 | |
|
1645 | 1645 | assert_difference 'Issue.count' do |
|
1646 | 1646 | post :create, :project_id => 1, |
|
1647 | 1647 | :issue => {:tracker_id => 1, |
|
1648 | 1648 | :subject => 'This is a child issue', |
|
1649 | 1649 | :parent_issue_id => 2} |
|
1650 | 1650 | end |
|
1651 | 1651 | issue = Issue.find_by_subject('This is a child issue') |
|
1652 | 1652 | assert_not_nil issue |
|
1653 | 1653 | assert_equal Issue.find(2), issue.parent |
|
1654 | 1654 | end |
|
1655 | 1655 | |
|
1656 | 1656 | def test_post_create_subissue_with_non_numeric_parent_id |
|
1657 | 1657 | @request.session[:user_id] = 2 |
|
1658 | 1658 | |
|
1659 | 1659 | assert_difference 'Issue.count' do |
|
1660 | 1660 | post :create, :project_id => 1, |
|
1661 | 1661 | :issue => {:tracker_id => 1, |
|
1662 | 1662 | :subject => 'This is a child issue', |
|
1663 | 1663 | :parent_issue_id => 'ABC'} |
|
1664 | 1664 | end |
|
1665 | 1665 | issue = Issue.find_by_subject('This is a child issue') |
|
1666 | 1666 | assert_not_nil issue |
|
1667 | 1667 | assert_nil issue.parent |
|
1668 | 1668 | end |
|
1669 | 1669 | |
|
1670 | 1670 | def test_post_create_private |
|
1671 | 1671 | @request.session[:user_id] = 2 |
|
1672 | 1672 | |
|
1673 | 1673 | assert_difference 'Issue.count' do |
|
1674 | 1674 | post :create, :project_id => 1, |
|
1675 | 1675 | :issue => {:tracker_id => 1, |
|
1676 | 1676 | :subject => 'This is a private issue', |
|
1677 | 1677 | :is_private => '1'} |
|
1678 | 1678 | end |
|
1679 | 1679 | issue = Issue.first(:order => 'id DESC') |
|
1680 | 1680 | assert issue.is_private? |
|
1681 | 1681 | end |
|
1682 | 1682 | |
|
1683 | 1683 | def test_post_create_private_with_set_own_issues_private_permission |
|
1684 | 1684 | role = Role.find(1) |
|
1685 | 1685 | role.remove_permission! :set_issues_private |
|
1686 | 1686 | role.add_permission! :set_own_issues_private |
|
1687 | 1687 | |
|
1688 | 1688 | @request.session[:user_id] = 2 |
|
1689 | 1689 | |
|
1690 | 1690 | assert_difference 'Issue.count' do |
|
1691 | 1691 | post :create, :project_id => 1, |
|
1692 | 1692 | :issue => {:tracker_id => 1, |
|
1693 | 1693 | :subject => 'This is a private issue', |
|
1694 | 1694 | :is_private => '1'} |
|
1695 | 1695 | end |
|
1696 | 1696 | issue = Issue.first(:order => 'id DESC') |
|
1697 | 1697 | assert issue.is_private? |
|
1698 | 1698 | end |
|
1699 | 1699 | |
|
1700 | 1700 | def test_post_create_should_send_a_notification |
|
1701 | 1701 | ActionMailer::Base.deliveries.clear |
|
1702 | 1702 | @request.session[:user_id] = 2 |
|
1703 | 1703 | assert_difference 'Issue.count' do |
|
1704 | 1704 | post :create, :project_id => 1, |
|
1705 | 1705 | :issue => {:tracker_id => 3, |
|
1706 | 1706 | :subject => 'This is the test_new issue', |
|
1707 | 1707 | :description => 'This is the description', |
|
1708 | 1708 | :priority_id => 5, |
|
1709 | 1709 | :estimated_hours => '', |
|
1710 | 1710 | :custom_field_values => {'2' => 'Value for field 2'}} |
|
1711 | 1711 | end |
|
1712 | 1712 | assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id |
|
1713 | 1713 | |
|
1714 | 1714 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
1715 | 1715 | end |
|
1716 | 1716 | |
|
1717 | 1717 | def test_post_create_should_preserve_fields_values_on_validation_failure |
|
1718 | 1718 | @request.session[:user_id] = 2 |
|
1719 | 1719 | post :create, :project_id => 1, |
|
1720 | 1720 | :issue => {:tracker_id => 1, |
|
1721 | 1721 | # empty subject |
|
1722 | 1722 | :subject => '', |
|
1723 | 1723 | :description => 'This is a description', |
|
1724 | 1724 | :priority_id => 6, |
|
1725 | 1725 | :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}} |
|
1726 | 1726 | assert_response :success |
|
1727 | 1727 | assert_template 'new' |
|
1728 | 1728 | |
|
1729 | 1729 | assert_tag :textarea, :attributes => { :name => 'issue[description]' }, |
|
1730 | 1730 | :content => "\nThis is a description" |
|
1731 | 1731 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, |
|
1732 | 1732 | :child => { :tag => 'option', :attributes => { :selected => 'selected', |
|
1733 | 1733 | :value => '6' }, |
|
1734 | 1734 | :content => 'High' } |
|
1735 | 1735 | # Custom fields |
|
1736 | 1736 | assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' }, |
|
1737 | 1737 | :child => { :tag => 'option', :attributes => { :selected => 'selected', |
|
1738 | 1738 | :value => 'Oracle' }, |
|
1739 | 1739 | :content => 'Oracle' } |
|
1740 | 1740 | assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]', |
|
1741 | 1741 | :value => 'Value for field 2'} |
|
1742 | 1742 | end |
|
1743 | 1743 | |
|
1744 | 1744 | def test_post_create_with_failure_should_preserve_watchers |
|
1745 | 1745 | assert !User.find(8).member_of?(Project.find(1)) |
|
1746 | 1746 | |
|
1747 | 1747 | @request.session[:user_id] = 2 |
|
1748 | 1748 | post :create, :project_id => 1, |
|
1749 | 1749 | :issue => {:tracker_id => 1, |
|
1750 | 1750 | :watcher_user_ids => ['3', '8']} |
|
1751 | 1751 | assert_response :success |
|
1752 | 1752 | assert_template 'new' |
|
1753 | 1753 | |
|
1754 | 1754 | assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '2', :checked => nil} |
|
1755 | 1755 | assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '3', :checked => 'checked'} |
|
1756 | 1756 | assert_tag 'input', :attributes => {:name => 'issue[watcher_user_ids][]', :value => '8', :checked => 'checked'} |
|
1757 | 1757 | end |
|
1758 | 1758 | |
|
1759 | 1759 | def test_post_create_should_ignore_non_safe_attributes |
|
1760 | 1760 | @request.session[:user_id] = 2 |
|
1761 | 1761 | assert_nothing_raised do |
|
1762 | 1762 | post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" } |
|
1763 | 1763 | end |
|
1764 | 1764 | end |
|
1765 | 1765 | |
|
1766 | 1766 | def test_post_create_with_attachment |
|
1767 | 1767 | set_tmp_attachments_directory |
|
1768 | 1768 | @request.session[:user_id] = 2 |
|
1769 | 1769 | |
|
1770 | 1770 | assert_difference 'Issue.count' do |
|
1771 | 1771 | assert_difference 'Attachment.count' do |
|
1772 | 1772 | post :create, :project_id => 1, |
|
1773 | 1773 | :issue => { :tracker_id => '1', :subject => 'With attachment' }, |
|
1774 | 1774 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
1775 | 1775 | end |
|
1776 | 1776 | end |
|
1777 | 1777 | |
|
1778 | 1778 | issue = Issue.first(:order => 'id DESC') |
|
1779 | 1779 | attachment = Attachment.first(:order => 'id DESC') |
|
1780 | 1780 | |
|
1781 | 1781 | assert_equal issue, attachment.container |
|
1782 | 1782 | assert_equal 2, attachment.author_id |
|
1783 | 1783 | assert_equal 'testfile.txt', attachment.filename |
|
1784 | 1784 | assert_equal 'text/plain', attachment.content_type |
|
1785 | 1785 | assert_equal 'test file', attachment.description |
|
1786 | 1786 | assert_equal 59, attachment.filesize |
|
1787 | 1787 | assert File.exists?(attachment.diskfile) |
|
1788 | 1788 | assert_equal 59, File.size(attachment.diskfile) |
|
1789 | 1789 | end |
|
1790 | 1790 | |
|
1791 | 1791 | def test_post_create_with_failure_should_save_attachments |
|
1792 | 1792 | set_tmp_attachments_directory |
|
1793 | 1793 | @request.session[:user_id] = 2 |
|
1794 | 1794 | |
|
1795 | 1795 | assert_no_difference 'Issue.count' do |
|
1796 | 1796 | assert_difference 'Attachment.count' do |
|
1797 | 1797 | post :create, :project_id => 1, |
|
1798 | 1798 | :issue => { :tracker_id => '1', :subject => '' }, |
|
1799 | 1799 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
1800 | 1800 | assert_response :success |
|
1801 | 1801 | assert_template 'new' |
|
1802 | 1802 | end |
|
1803 | 1803 | end |
|
1804 | 1804 | |
|
1805 | 1805 | attachment = Attachment.first(:order => 'id DESC') |
|
1806 | 1806 | assert_equal 'testfile.txt', attachment.filename |
|
1807 | 1807 | assert File.exists?(attachment.diskfile) |
|
1808 | 1808 | assert_nil attachment.container |
|
1809 | 1809 | |
|
1810 | 1810 | assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} |
|
1811 | 1811 | assert_tag 'span', :content => /testfile.txt/ |
|
1812 | 1812 | end |
|
1813 | 1813 | |
|
1814 | 1814 | def test_post_create_with_failure_should_keep_saved_attachments |
|
1815 | 1815 | set_tmp_attachments_directory |
|
1816 | 1816 | attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) |
|
1817 | 1817 | @request.session[:user_id] = 2 |
|
1818 | 1818 | |
|
1819 | 1819 | assert_no_difference 'Issue.count' do |
|
1820 | 1820 | assert_no_difference 'Attachment.count' do |
|
1821 | 1821 | post :create, :project_id => 1, |
|
1822 | 1822 | :issue => { :tracker_id => '1', :subject => '' }, |
|
1823 | 1823 | :attachments => {'p0' => {'token' => attachment.token}} |
|
1824 | 1824 | assert_response :success |
|
1825 | 1825 | assert_template 'new' |
|
1826 | 1826 | end |
|
1827 | 1827 | end |
|
1828 | 1828 | |
|
1829 | 1829 | assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} |
|
1830 | 1830 | assert_tag 'span', :content => /testfile.txt/ |
|
1831 | 1831 | end |
|
1832 | 1832 | |
|
1833 | 1833 | def test_post_create_should_attach_saved_attachments |
|
1834 | 1834 | set_tmp_attachments_directory |
|
1835 | 1835 | attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) |
|
1836 | 1836 | @request.session[:user_id] = 2 |
|
1837 | 1837 | |
|
1838 | 1838 | assert_difference 'Issue.count' do |
|
1839 | 1839 | assert_no_difference 'Attachment.count' do |
|
1840 | 1840 | post :create, :project_id => 1, |
|
1841 | 1841 | :issue => { :tracker_id => '1', :subject => 'Saved attachments' }, |
|
1842 | 1842 | :attachments => {'p0' => {'token' => attachment.token}} |
|
1843 | 1843 | assert_response 302 |
|
1844 | 1844 | end |
|
1845 | 1845 | end |
|
1846 | 1846 | |
|
1847 | 1847 | issue = Issue.first(:order => 'id DESC') |
|
1848 | 1848 | assert_equal 1, issue.attachments.count |
|
1849 | 1849 | |
|
1850 | 1850 | attachment.reload |
|
1851 | 1851 | assert_equal issue, attachment.container |
|
1852 | 1852 | end |
|
1853 | 1853 | |
|
1854 | 1854 | context "without workflow privilege" do |
|
1855 | 1855 | setup do |
|
1856 | 1856 | Workflow.delete_all(["role_id = ?", Role.anonymous.id]) |
|
1857 | 1857 | Role.anonymous.add_permission! :add_issues, :add_issue_notes |
|
1858 | 1858 | end |
|
1859 | 1859 | |
|
1860 | 1860 | context "#new" do |
|
1861 | 1861 | should "propose default status only" do |
|
1862 | 1862 | get :new, :project_id => 1 |
|
1863 | 1863 | assert_response :success |
|
1864 | 1864 | assert_template 'new' |
|
1865 | 1865 | assert_tag :tag => 'select', |
|
1866 | 1866 | :attributes => {:name => 'issue[status_id]'}, |
|
1867 | 1867 | :children => {:count => 1}, |
|
1868 | 1868 | :child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}} |
|
1869 | 1869 | end |
|
1870 | 1870 | |
|
1871 | 1871 | should "accept default status" do |
|
1872 | 1872 | assert_difference 'Issue.count' do |
|
1873 | 1873 | post :create, :project_id => 1, |
|
1874 | 1874 | :issue => {:tracker_id => 1, |
|
1875 | 1875 | :subject => 'This is an issue', |
|
1876 | 1876 | :status_id => 1} |
|
1877 | 1877 | end |
|
1878 | 1878 | issue = Issue.last(:order => 'id') |
|
1879 | 1879 | assert_equal IssueStatus.default, issue.status |
|
1880 | 1880 | end |
|
1881 | 1881 | |
|
1882 | 1882 | should "ignore unauthorized status" do |
|
1883 | 1883 | assert_difference 'Issue.count' do |
|
1884 | 1884 | post :create, :project_id => 1, |
|
1885 | 1885 | :issue => {:tracker_id => 1, |
|
1886 | 1886 | :subject => 'This is an issue', |
|
1887 | 1887 | :status_id => 3} |
|
1888 | 1888 | end |
|
1889 | 1889 | issue = Issue.last(:order => 'id') |
|
1890 | 1890 | assert_equal IssueStatus.default, issue.status |
|
1891 | 1891 | end |
|
1892 | 1892 | end |
|
1893 | 1893 | |
|
1894 | 1894 | context "#update" do |
|
1895 | 1895 | should "ignore status change" do |
|
1896 | 1896 | assert_difference 'Journal.count' do |
|
1897 | 1897 | put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3} |
|
1898 | 1898 | end |
|
1899 | 1899 | assert_equal 1, Issue.find(1).status_id |
|
1900 | 1900 | end |
|
1901 | 1901 | |
|
1902 | 1902 | should "ignore attributes changes" do |
|
1903 | 1903 | assert_difference 'Journal.count' do |
|
1904 | 1904 | put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2} |
|
1905 | 1905 | end |
|
1906 | 1906 | issue = Issue.find(1) |
|
1907 | 1907 | assert_equal "Can't print recipes", issue.subject |
|
1908 | 1908 | assert_nil issue.assigned_to |
|
1909 | 1909 | end |
|
1910 | 1910 | end |
|
1911 | 1911 | end |
|
1912 | 1912 | |
|
1913 | 1913 | context "with workflow privilege" do |
|
1914 | 1914 | setup do |
|
1915 | 1915 | Workflow.delete_all(["role_id = ?", Role.anonymous.id]) |
|
1916 | 1916 | Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3) |
|
1917 | 1917 | Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4) |
|
1918 | 1918 | Role.anonymous.add_permission! :add_issues, :add_issue_notes |
|
1919 | 1919 | end |
|
1920 | 1920 | |
|
1921 | 1921 | context "#update" do |
|
1922 | 1922 | should "accept authorized status" do |
|
1923 | 1923 | assert_difference 'Journal.count' do |
|
1924 | 1924 | put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3} |
|
1925 | 1925 | end |
|
1926 | 1926 | assert_equal 3, Issue.find(1).status_id |
|
1927 | 1927 | end |
|
1928 | 1928 | |
|
1929 | 1929 | should "ignore unauthorized status" do |
|
1930 | 1930 | assert_difference 'Journal.count' do |
|
1931 | 1931 | put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2} |
|
1932 | 1932 | end |
|
1933 | 1933 | assert_equal 1, Issue.find(1).status_id |
|
1934 | 1934 | end |
|
1935 | 1935 | |
|
1936 | 1936 | should "accept authorized attributes changes" do |
|
1937 | 1937 | assert_difference 'Journal.count' do |
|
1938 | 1938 | put :update, :id => 1, :notes => 'just trying', :issue => {:assigned_to_id => 2} |
|
1939 | 1939 | end |
|
1940 | 1940 | issue = Issue.find(1) |
|
1941 | 1941 | assert_equal 2, issue.assigned_to_id |
|
1942 | 1942 | end |
|
1943 | 1943 | |
|
1944 | 1944 | should "ignore unauthorized attributes changes" do |
|
1945 | 1945 | assert_difference 'Journal.count' do |
|
1946 | 1946 | put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed'} |
|
1947 | 1947 | end |
|
1948 | 1948 | issue = Issue.find(1) |
|
1949 | 1949 | assert_equal "Can't print recipes", issue.subject |
|
1950 | 1950 | end |
|
1951 | 1951 | end |
|
1952 | 1952 | |
|
1953 | 1953 | context "and :edit_issues permission" do |
|
1954 | 1954 | setup do |
|
1955 | 1955 | Role.anonymous.add_permission! :add_issues, :edit_issues |
|
1956 | 1956 | end |
|
1957 | 1957 | |
|
1958 | 1958 | should "accept authorized status" do |
|
1959 | 1959 | assert_difference 'Journal.count' do |
|
1960 | 1960 | put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 3} |
|
1961 | 1961 | end |
|
1962 | 1962 | assert_equal 3, Issue.find(1).status_id |
|
1963 | 1963 | end |
|
1964 | 1964 | |
|
1965 | 1965 | should "ignore unauthorized status" do |
|
1966 | 1966 | assert_difference 'Journal.count' do |
|
1967 | 1967 | put :update, :id => 1, :notes => 'just trying', :issue => {:status_id => 2} |
|
1968 | 1968 | end |
|
1969 | 1969 | assert_equal 1, Issue.find(1).status_id |
|
1970 | 1970 | end |
|
1971 | 1971 | |
|
1972 | 1972 | should "accept authorized attributes changes" do |
|
1973 | 1973 | assert_difference 'Journal.count' do |
|
1974 | 1974 | put :update, :id => 1, :notes => 'just trying', :issue => {:subject => 'changed', :assigned_to_id => 2} |
|
1975 | 1975 | end |
|
1976 | 1976 | issue = Issue.find(1) |
|
1977 | 1977 | assert_equal "changed", issue.subject |
|
1978 | 1978 | assert_equal 2, issue.assigned_to_id |
|
1979 | 1979 | end |
|
1980 | 1980 | end |
|
1981 | 1981 | end |
|
1982 | 1982 | |
|
1983 | 1983 | def test_new_as_copy |
|
1984 | 1984 | @request.session[:user_id] = 2 |
|
1985 | 1985 | get :new, :project_id => 1, :copy_from => 1 |
|
1986 | 1986 | |
|
1987 | 1987 | assert_response :success |
|
1988 | 1988 | assert_template 'new' |
|
1989 | 1989 | |
|
1990 | 1990 | assert_not_nil assigns(:issue) |
|
1991 | 1991 | orig = Issue.find(1) |
|
1992 | 1992 | assert_equal 1, assigns(:issue).project_id |
|
1993 | 1993 | assert_equal orig.subject, assigns(:issue).subject |
|
1994 | 1994 | assert assigns(:issue).copy? |
|
1995 | 1995 | |
|
1996 | 1996 | assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'} |
|
1997 | 1997 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
1998 | 1998 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'}, |
|
1999 | 1999 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}, :content => 'eCookbook'} |
|
2000 | 2000 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'}, |
|
2001 | 2001 | :child => {:tag => 'option', :attributes => {:value => '2', :selected => nil}, :content => 'OnlineStore'} |
|
2002 | 2002 | assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'} |
|
2003 | 2003 | end |
|
2004 | 2004 | |
|
2005 | 2005 | def test_new_as_copy_with_attachments_should_show_copy_attachments_checkbox |
|
2006 | 2006 | @request.session[:user_id] = 2 |
|
2007 | 2007 | issue = Issue.find(3) |
|
2008 | 2008 | assert issue.attachments.count > 0 |
|
2009 | 2009 | get :new, :project_id => 1, :copy_from => 3 |
|
2010 | 2010 | |
|
2011 | 2011 | assert_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'} |
|
2012 | 2012 | end |
|
2013 | 2013 | |
|
2014 | 2014 | def test_new_as_copy_without_attachments_should_not_show_copy_attachments_checkbox |
|
2015 | 2015 | @request.session[:user_id] = 2 |
|
2016 | 2016 | issue = Issue.find(3) |
|
2017 | 2017 | issue.attachments.delete_all |
|
2018 | 2018 | get :new, :project_id => 1, :copy_from => 3 |
|
2019 | 2019 | |
|
2020 | 2020 | assert_no_tag 'input', :attributes => {:name => 'copy_attachments', :type => 'checkbox', :checked => 'checked', :value => '1'} |
|
2021 | 2021 | end |
|
2022 | 2022 | |
|
2023 | 2023 | def test_new_as_copy_with_invalid_issue_should_respond_with_404 |
|
2024 | 2024 | @request.session[:user_id] = 2 |
|
2025 | 2025 | get :new, :project_id => 1, :copy_from => 99999 |
|
2026 | 2026 | assert_response 404 |
|
2027 | 2027 | end |
|
2028 | 2028 | |
|
2029 | 2029 | def test_create_as_copy_on_different_project |
|
2030 | 2030 | @request.session[:user_id] = 2 |
|
2031 | 2031 | assert_difference 'Issue.count' do |
|
2032 | 2032 | post :create, :project_id => 1, :copy_from => 1, |
|
2033 | 2033 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'} |
|
2034 | 2034 | |
|
2035 | 2035 | assert_not_nil assigns(:issue) |
|
2036 | 2036 | assert assigns(:issue).copy? |
|
2037 | 2037 | end |
|
2038 | 2038 | issue = Issue.first(:order => 'id DESC') |
|
2039 | 2039 | assert_redirected_to "/issues/#{issue.id}" |
|
2040 | 2040 | |
|
2041 | 2041 | assert_equal 2, issue.project_id |
|
2042 | 2042 | assert_equal 3, issue.tracker_id |
|
2043 | 2043 | assert_equal 'Copy', issue.subject |
|
2044 | 2044 | end |
|
2045 | 2045 | |
|
2046 | 2046 | def test_create_as_copy_should_copy_attachments |
|
2047 | 2047 | @request.session[:user_id] = 2 |
|
2048 | 2048 | issue = Issue.find(3) |
|
2049 | 2049 | count = issue.attachments.count |
|
2050 | 2050 | assert count > 0 |
|
2051 | 2051 | |
|
2052 | 2052 | assert_difference 'Issue.count' do |
|
2053 | 2053 | assert_difference 'Attachment.count', count do |
|
2054 | 2054 | assert_no_difference 'Journal.count' do |
|
2055 | 2055 | post :create, :project_id => 1, :copy_from => 3, |
|
2056 | 2056 | :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}, |
|
2057 | 2057 | :copy_attachments => '1' |
|
2058 | 2058 | end |
|
2059 | 2059 | end |
|
2060 | 2060 | end |
|
2061 | 2061 | copy = Issue.first(:order => 'id DESC') |
|
2062 | 2062 | assert_equal count, copy.attachments.count |
|
2063 | 2063 | assert_equal issue.attachments.map(&:filename).sort, copy.attachments.map(&:filename).sort |
|
2064 | 2064 | end |
|
2065 | 2065 | |
|
2066 | 2066 | def test_create_as_copy_without_copy_attachments_option_should_not_copy_attachments |
|
2067 | 2067 | @request.session[:user_id] = 2 |
|
2068 | 2068 | issue = Issue.find(3) |
|
2069 | 2069 | count = issue.attachments.count |
|
2070 | 2070 | assert count > 0 |
|
2071 | 2071 | |
|
2072 | 2072 | assert_difference 'Issue.count' do |
|
2073 | 2073 | assert_no_difference 'Attachment.count' do |
|
2074 | 2074 | assert_no_difference 'Journal.count' do |
|
2075 | 2075 | post :create, :project_id => 1, :copy_from => 3, |
|
2076 | 2076 | :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'} |
|
2077 | 2077 | end |
|
2078 | 2078 | end |
|
2079 | 2079 | end |
|
2080 | 2080 | copy = Issue.first(:order => 'id DESC') |
|
2081 | 2081 | assert_equal 0, copy.attachments.count |
|
2082 | 2082 | end |
|
2083 | 2083 | |
|
2084 | 2084 | def test_create_as_copy_with_attachments_should_add_new_files |
|
2085 | 2085 | @request.session[:user_id] = 2 |
|
2086 | 2086 | issue = Issue.find(3) |
|
2087 | 2087 | count = issue.attachments.count |
|
2088 | 2088 | assert count > 0 |
|
2089 | 2089 | |
|
2090 | 2090 | assert_difference 'Issue.count' do |
|
2091 | 2091 | assert_difference 'Attachment.count', count + 1 do |
|
2092 | 2092 | assert_no_difference 'Journal.count' do |
|
2093 | 2093 | post :create, :project_id => 1, :copy_from => 3, |
|
2094 | 2094 | :issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}, |
|
2095 | 2095 | :copy_attachments => '1', |
|
2096 | 2096 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
2097 | 2097 | end |
|
2098 | 2098 | end |
|
2099 | 2099 | end |
|
2100 | 2100 | copy = Issue.first(:order => 'id DESC') |
|
2101 | 2101 | assert_equal count + 1, copy.attachments.count |
|
2102 | 2102 | end |
|
2103 | 2103 | |
|
2104 | 2104 | def test_create_as_copy_with_failure |
|
2105 | 2105 | @request.session[:user_id] = 2 |
|
2106 | 2106 | post :create, :project_id => 1, :copy_from => 1, |
|
2107 | 2107 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''} |
|
2108 | 2108 | |
|
2109 | 2109 | assert_response :success |
|
2110 | 2110 | assert_template 'new' |
|
2111 | 2111 | |
|
2112 | 2112 | assert_not_nil assigns(:issue) |
|
2113 | 2113 | assert assigns(:issue).copy? |
|
2114 | 2114 | |
|
2115 | 2115 | assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'} |
|
2116 | 2116 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'} |
|
2117 | 2117 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'}, |
|
2118 | 2118 | :child => {:tag => 'option', :attributes => {:value => '1', :selected => nil}, :content => 'eCookbook'} |
|
2119 | 2119 | assert_tag 'select', :attributes => {:name => 'issue[project_id]'}, |
|
2120 | 2120 | :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}, :content => 'OnlineStore'} |
|
2121 | 2121 | assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'} |
|
2122 | 2122 | end |
|
2123 | 2123 | |
|
2124 | 2124 | def test_create_as_copy_on_project_without_permission_should_ignore_target_project |
|
2125 | 2125 | @request.session[:user_id] = 2 |
|
2126 | 2126 | assert !User.find(2).member_of?(Project.find(4)) |
|
2127 | 2127 | |
|
2128 | 2128 | assert_difference 'Issue.count' do |
|
2129 | 2129 | post :create, :project_id => 1, :copy_from => 1, |
|
2130 | 2130 | :issue => {:project_id => '4', :tracker_id => '3', :status_id => '1', :subject => 'Copy'} |
|
2131 | 2131 | end |
|
2132 | 2132 | issue = Issue.first(:order => 'id DESC') |
|
2133 | 2133 | assert_equal 1, issue.project_id |
|
2134 | 2134 | end |
|
2135 | 2135 | |
|
2136 | 2136 | def test_get_edit |
|
2137 | 2137 | @request.session[:user_id] = 2 |
|
2138 | 2138 | get :edit, :id => 1 |
|
2139 | 2139 | assert_response :success |
|
2140 | 2140 | assert_template 'edit' |
|
2141 | 2141 | assert_not_nil assigns(:issue) |
|
2142 | 2142 | assert_equal Issue.find(1), assigns(:issue) |
|
2143 | 2143 | |
|
2144 | 2144 | # Be sure we don't display inactive IssuePriorities |
|
2145 | 2145 | assert ! IssuePriority.find(15).active? |
|
2146 | 2146 | assert_no_tag :option, :attributes => {:value => '15'}, |
|
2147 | 2147 | :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} } |
|
2148 | 2148 | end |
|
2149 | 2149 | |
|
2150 | 2150 | def test_get_edit_should_display_the_time_entry_form_with_log_time_permission |
|
2151 | 2151 | @request.session[:user_id] = 2 |
|
2152 | 2152 | Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time] |
|
2153 | 2153 | |
|
2154 | 2154 | get :edit, :id => 1 |
|
2155 | 2155 | assert_tag 'input', :attributes => {:name => 'time_entry[hours]'} |
|
2156 | 2156 | end |
|
2157 | 2157 | |
|
2158 | 2158 | def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission |
|
2159 | 2159 | @request.session[:user_id] = 2 |
|
2160 | 2160 | Role.find_by_name('Manager').remove_permission! :log_time |
|
2161 | 2161 | |
|
2162 | 2162 | get :edit, :id => 1 |
|
2163 | 2163 | assert_no_tag 'input', :attributes => {:name => 'time_entry[hours]'} |
|
2164 | 2164 | end |
|
2165 | 2165 | |
|
2166 | 2166 | def test_get_edit_with_params |
|
2167 | 2167 | @request.session[:user_id] = 2 |
|
2168 | 2168 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }, |
|
2169 | 2169 | :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => TimeEntryActivity.first.id } |
|
2170 | 2170 | assert_response :success |
|
2171 | 2171 | assert_template 'edit' |
|
2172 | 2172 | |
|
2173 | 2173 | issue = assigns(:issue) |
|
2174 | 2174 | assert_not_nil issue |
|
2175 | 2175 | |
|
2176 | 2176 | assert_equal 5, issue.status_id |
|
2177 | 2177 | assert_tag :select, :attributes => { :name => 'issue[status_id]' }, |
|
2178 | 2178 | :child => { :tag => 'option', |
|
2179 | 2179 | :content => 'Closed', |
|
2180 | 2180 | :attributes => { :selected => 'selected' } } |
|
2181 | 2181 | |
|
2182 | 2182 | assert_equal 7, issue.priority_id |
|
2183 | 2183 | assert_tag :select, :attributes => { :name => 'issue[priority_id]' }, |
|
2184 | 2184 | :child => { :tag => 'option', |
|
2185 | 2185 | :content => 'Urgent', |
|
2186 | 2186 | :attributes => { :selected => 'selected' } } |
|
2187 | 2187 | |
|
2188 | 2188 | assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => '2.5' } |
|
2189 | 2189 | assert_tag :select, :attributes => { :name => 'time_entry[activity_id]' }, |
|
2190 | 2190 | :child => { :tag => 'option', |
|
2191 | 2191 | :attributes => { :selected => 'selected', :value => TimeEntryActivity.first.id } } |
|
2192 | 2192 | assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => 'test_get_edit_with_params' } |
|
2193 | 2193 | end |
|
2194 | 2194 | |
|
2195 | 2195 | def test_get_edit_with_multi_custom_field |
|
2196 | 2196 | field = CustomField.find(1) |
|
2197 | 2197 | field.update_attribute :multiple, true |
|
2198 | 2198 | issue = Issue.find(1) |
|
2199 | 2199 | issue.custom_field_values = {1 => ['MySQL', 'Oracle']} |
|
2200 | 2200 | issue.save! |
|
2201 | 2201 | |
|
2202 | 2202 | @request.session[:user_id] = 2 |
|
2203 | 2203 | get :edit, :id => 1 |
|
2204 | 2204 | assert_response :success |
|
2205 | 2205 | assert_template 'edit' |
|
2206 | 2206 | |
|
2207 | 2207 | assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]', :multiple => 'multiple'} |
|
2208 | 2208 | assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'}, |
|
2209 | 2209 | :child => {:tag => 'option', :attributes => {:value => 'MySQL', :selected => 'selected'}} |
|
2210 | 2210 | assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'}, |
|
2211 | 2211 | :child => {:tag => 'option', :attributes => {:value => 'PostgreSQL', :selected => nil}} |
|
2212 | 2212 | assert_tag 'select', :attributes => {:name => 'issue[custom_field_values][1][]'}, |
|
2213 | 2213 | :child => {:tag => 'option', :attributes => {:value => 'Oracle', :selected => 'selected'}} |
|
2214 | 2214 | end |
|
2215 | 2215 | |
|
2216 | 2216 | def test_update_edit_form |
|
2217 | 2217 | @request.session[:user_id] = 2 |
|
2218 | 2218 | xhr :put, :new, :project_id => 1, |
|
2219 | 2219 | :id => 1, |
|
2220 | 2220 | :issue => {:tracker_id => 2, |
|
2221 | 2221 | :subject => 'This is the test_new issue', |
|
2222 | 2222 | :description => 'This is the description', |
|
2223 | 2223 | :priority_id => 5} |
|
2224 | 2224 | assert_response :success |
|
2225 | 2225 | assert_template 'attributes' |
|
2226 | 2226 | |
|
2227 | 2227 | issue = assigns(:issue) |
|
2228 | 2228 | assert_kind_of Issue, issue |
|
2229 | 2229 | assert_equal 1, issue.id |
|
2230 | 2230 | assert_equal 1, issue.project_id |
|
2231 | 2231 | assert_equal 2, issue.tracker_id |
|
2232 | 2232 | assert_equal 'This is the test_new issue', issue.subject |
|
2233 | 2233 | end |
|
2234 | 2234 | |
|
2235 | 2235 | def test_update_edit_form_should_propose_transitions_based_on_initial_status |
|
2236 | 2236 | @request.session[:user_id] = 2 |
|
2237 | 2237 | Workflow.delete_all |
|
2238 | 2238 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1) |
|
2239 | 2239 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5) |
|
2240 | 2240 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4) |
|
2241 | 2241 | |
|
2242 | 2242 | xhr :put, :new, :project_id => 1, |
|
2243 | 2243 | :id => 2, |
|
2244 | 2244 | :issue => {:tracker_id => 2, |
|
2245 | 2245 | :status_id => 5, |
|
2246 | 2246 | :subject => 'This is an issue'} |
|
2247 | 2247 | |
|
2248 | 2248 | assert_equal 5, assigns(:issue).status_id |
|
2249 | 2249 | assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort |
|
2250 | 2250 | end |
|
2251 | 2251 | |
|
2252 | 2252 | def test_update_edit_form_with_project_change |
|
2253 | 2253 | @request.session[:user_id] = 2 |
|
2254 | 2254 | xhr :put, :new, :project_id => 1, |
|
2255 | 2255 | :id => 1, |
|
2256 | 2256 | :project_change => '1', |
|
2257 | 2257 | :issue => {:project_id => 2, |
|
2258 | 2258 | :tracker_id => 2, |
|
2259 | 2259 | :subject => 'This is the test_new issue', |
|
2260 | 2260 | :description => 'This is the description', |
|
2261 | 2261 | :priority_id => 5} |
|
2262 | 2262 | assert_response :success |
|
2263 | 2263 | assert_template 'form' |
|
2264 | 2264 | |
|
2265 | 2265 | issue = assigns(:issue) |
|
2266 | 2266 | assert_kind_of Issue, issue |
|
2267 | 2267 | assert_equal 1, issue.id |
|
2268 | 2268 | assert_equal 2, issue.project_id |
|
2269 | 2269 | assert_equal 2, issue.tracker_id |
|
2270 | 2270 | assert_equal 'This is the test_new issue', issue.subject |
|
2271 | 2271 | end |
|
2272 | 2272 | |
|
2273 | 2273 | def test_put_update_without_custom_fields_param |
|
2274 | 2274 | @request.session[:user_id] = 2 |
|
2275 | 2275 | ActionMailer::Base.deliveries.clear |
|
2276 | 2276 | |
|
2277 | 2277 | issue = Issue.find(1) |
|
2278 | 2278 | assert_equal '125', issue.custom_value_for(2).value |
|
2279 | 2279 | old_subject = issue.subject |
|
2280 | 2280 | new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' |
|
2281 | 2281 | |
|
2282 | 2282 | assert_difference('Journal.count') do |
|
2283 | 2283 | assert_difference('JournalDetail.count', 2) do |
|
2284 | 2284 | put :update, :id => 1, :issue => {:subject => new_subject, |
|
2285 | 2285 | :priority_id => '6', |
|
2286 | 2286 | :category_id => '1' # no change |
|
2287 | 2287 | } |
|
2288 | 2288 | end |
|
2289 | 2289 | end |
|
2290 | 2290 | assert_redirected_to :action => 'show', :id => '1' |
|
2291 | 2291 | issue.reload |
|
2292 | 2292 | assert_equal new_subject, issue.subject |
|
2293 | 2293 | # Make sure custom fields were not cleared |
|
2294 | 2294 | assert_equal '125', issue.custom_value_for(2).value |
|
2295 | 2295 | |
|
2296 | 2296 | mail = ActionMailer::Base.deliveries.last |
|
2297 | 2297 | assert_not_nil mail |
|
2298 | 2298 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2299 | 2299 | assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail |
|
2300 | 2300 | end |
|
2301 | 2301 | |
|
2302 | 2302 | def test_put_update_with_project_change |
|
2303 | 2303 | @request.session[:user_id] = 2 |
|
2304 | 2304 | ActionMailer::Base.deliveries.clear |
|
2305 | 2305 | |
|
2306 | 2306 | assert_difference('Journal.count') do |
|
2307 | 2307 | assert_difference('JournalDetail.count', 3) do |
|
2308 | 2308 | put :update, :id => 1, :issue => {:project_id => '2', |
|
2309 | 2309 | :tracker_id => '1', # no change |
|
2310 | 2310 | :priority_id => '6', |
|
2311 | 2311 | :category_id => '3' |
|
2312 | 2312 | } |
|
2313 | 2313 | end |
|
2314 | 2314 | end |
|
2315 | 2315 | assert_redirected_to :action => 'show', :id => '1' |
|
2316 | 2316 | issue = Issue.find(1) |
|
2317 | 2317 | assert_equal 2, issue.project_id |
|
2318 | 2318 | assert_equal 1, issue.tracker_id |
|
2319 | 2319 | assert_equal 6, issue.priority_id |
|
2320 | 2320 | assert_equal 3, issue.category_id |
|
2321 | 2321 | |
|
2322 | 2322 | mail = ActionMailer::Base.deliveries.last |
|
2323 | 2323 | assert_not_nil mail |
|
2324 | 2324 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2325 | 2325 | assert_mail_body_match "Project changed from eCookbook to OnlineStore", mail |
|
2326 | 2326 | end |
|
2327 | 2327 | |
|
2328 | 2328 | def test_put_update_with_tracker_change |
|
2329 | 2329 | @request.session[:user_id] = 2 |
|
2330 | 2330 | ActionMailer::Base.deliveries.clear |
|
2331 | 2331 | |
|
2332 | 2332 | assert_difference('Journal.count') do |
|
2333 | 2333 | assert_difference('JournalDetail.count', 2) do |
|
2334 | 2334 | put :update, :id => 1, :issue => {:project_id => '1', |
|
2335 | 2335 | :tracker_id => '2', |
|
2336 | 2336 | :priority_id => '6' |
|
2337 | 2337 | } |
|
2338 | 2338 | end |
|
2339 | 2339 | end |
|
2340 | 2340 | assert_redirected_to :action => 'show', :id => '1' |
|
2341 | 2341 | issue = Issue.find(1) |
|
2342 | 2342 | assert_equal 1, issue.project_id |
|
2343 | 2343 | assert_equal 2, issue.tracker_id |
|
2344 | 2344 | assert_equal 6, issue.priority_id |
|
2345 | 2345 | assert_equal 1, issue.category_id |
|
2346 | 2346 | |
|
2347 | 2347 | mail = ActionMailer::Base.deliveries.last |
|
2348 | 2348 | assert_not_nil mail |
|
2349 | 2349 | assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]") |
|
2350 | 2350 | assert_mail_body_match "Tracker changed from Bug to Feature request", mail |
|
2351 | 2351 | end |
|
2352 | 2352 | |
|
2353 | 2353 | def test_put_update_with_custom_field_change |
|
2354 | 2354 | @request.session[:user_id] = 2 |
|
2355 | 2355 | issue = Issue.find(1) |
|
2356 | 2356 | assert_equal '125', issue.custom_value_for(2).value |
|
2357 | 2357 | |
|
2358 | 2358 | assert_difference('Journal.count') do |
|
2359 | 2359 | assert_difference('JournalDetail.count', 3) do |
|
2360 | 2360 | put :update, :id => 1, :issue => {:subject => 'Custom field change', |
|
2361 | 2361 | :priority_id => '6', |
|
2362 | 2362 | :category_id => '1', # no change |
|
2363 | 2363 | :custom_field_values => { '2' => 'New custom value' } |
|
2364 | 2364 | } |
|
2365 | 2365 | end |
|
2366 | 2366 | end |
|
2367 | 2367 | assert_redirected_to :action => 'show', :id => '1' |
|
2368 | 2368 | issue.reload |
|
2369 | 2369 | assert_equal 'New custom value', issue.custom_value_for(2).value |
|
2370 | 2370 | |
|
2371 | 2371 | mail = ActionMailer::Base.deliveries.last |
|
2372 | 2372 | assert_not_nil mail |
|
2373 | 2373 | assert_mail_body_match "Searchable field changed from 125 to New custom value", mail |
|
2374 | 2374 | end |
|
2375 | 2375 | |
|
2376 | 2376 | def test_put_update_with_multi_custom_field_change |
|
2377 | 2377 | field = CustomField.find(1) |
|
2378 | 2378 | field.update_attribute :multiple, true |
|
2379 | 2379 | issue = Issue.find(1) |
|
2380 | 2380 | issue.custom_field_values = {1 => ['MySQL', 'Oracle']} |
|
2381 | 2381 | issue.save! |
|
2382 | 2382 | |
|
2383 | 2383 | @request.session[:user_id] = 2 |
|
2384 | 2384 | assert_difference('Journal.count') do |
|
2385 | 2385 | assert_difference('JournalDetail.count', 3) do |
|
2386 | 2386 | put :update, :id => 1, |
|
2387 | 2387 | :issue => { |
|
2388 | 2388 | :subject => 'Custom field change', |
|
2389 | 2389 | :custom_field_values => { '1' => ['', 'Oracle', 'PostgreSQL'] } |
|
2390 | 2390 | } |
|
2391 | 2391 | end |
|
2392 | 2392 | end |
|
2393 | 2393 | assert_redirected_to :action => 'show', :id => '1' |
|
2394 | 2394 | assert_equal ['Oracle', 'PostgreSQL'], Issue.find(1).custom_field_value(1).sort |
|
2395 | 2395 | end |
|
2396 | 2396 | |
|
2397 | 2397 | def test_put_update_with_status_and_assignee_change |
|
2398 | 2398 | issue = Issue.find(1) |
|
2399 | 2399 | assert_equal 1, issue.status_id |
|
2400 | 2400 | @request.session[:user_id] = 2 |
|
2401 | 2401 | assert_difference('TimeEntry.count', 0) do |
|
2402 | 2402 | put :update, |
|
2403 | 2403 | :id => 1, |
|
2404 | 2404 | :issue => { :status_id => 2, :assigned_to_id => 3 }, |
|
2405 | 2405 | :notes => 'Assigned to dlopper', |
|
2406 | 2406 | :time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first } |
|
2407 | 2407 | end |
|
2408 | 2408 | assert_redirected_to :action => 'show', :id => '1' |
|
2409 | 2409 | issue.reload |
|
2410 | 2410 | assert_equal 2, issue.status_id |
|
2411 | 2411 | j = Journal.find(:first, :order => 'id DESC') |
|
2412 | 2412 | assert_equal 'Assigned to dlopper', j.notes |
|
2413 | 2413 | assert_equal 2, j.details.size |
|
2414 | 2414 | |
|
2415 | 2415 | mail = ActionMailer::Base.deliveries.last |
|
2416 | 2416 | assert_mail_body_match "Status changed from New to Assigned", mail |
|
2417 | 2417 | # subject should contain the new status |
|
2418 | 2418 | assert mail.subject.include?("(#{ IssueStatus.find(2).name })") |
|
2419 | 2419 | end |
|
2420 | 2420 | |
|
2421 | 2421 | def test_put_update_with_note_only |
|
2422 | 2422 | notes = 'Note added by IssuesControllerTest#test_update_with_note_only' |
|
2423 | 2423 | # anonymous user |
|
2424 | 2424 | put :update, |
|
2425 | 2425 | :id => 1, |
|
2426 | 2426 | :notes => notes |
|
2427 | 2427 | assert_redirected_to :action => 'show', :id => '1' |
|
2428 | 2428 | j = Journal.find(:first, :order => 'id DESC') |
|
2429 | 2429 | assert_equal notes, j.notes |
|
2430 | 2430 | assert_equal 0, j.details.size |
|
2431 | 2431 | assert_equal User.anonymous, j.user |
|
2432 | 2432 | |
|
2433 | 2433 | mail = ActionMailer::Base.deliveries.last |
|
2434 | 2434 | assert_mail_body_match notes, mail |
|
2435 | 2435 | end |
|
2436 | 2436 | |
|
2437 | 2437 | def test_put_update_with_note_and_spent_time |
|
2438 | 2438 | @request.session[:user_id] = 2 |
|
2439 | 2439 | spent_hours_before = Issue.find(1).spent_hours |
|
2440 | 2440 | assert_difference('TimeEntry.count') do |
|
2441 | 2441 | put :update, |
|
2442 | 2442 | :id => 1, |
|
2443 | 2443 | :notes => '2.5 hours added', |
|
2444 | 2444 | :time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id } |
|
2445 | 2445 | end |
|
2446 | 2446 | assert_redirected_to :action => 'show', :id => '1' |
|
2447 | 2447 | |
|
2448 | 2448 | issue = Issue.find(1) |
|
2449 | 2449 | |
|
2450 | 2450 | j = Journal.find(:first, :order => 'id DESC') |
|
2451 | 2451 | assert_equal '2.5 hours added', j.notes |
|
2452 | 2452 | assert_equal 0, j.details.size |
|
2453 | 2453 | |
|
2454 | 2454 | t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time') |
|
2455 | 2455 | assert_not_nil t |
|
2456 | 2456 | assert_equal 2.5, t.hours |
|
2457 | 2457 | assert_equal spent_hours_before + 2.5, issue.spent_hours |
|
2458 | 2458 | end |
|
2459 | 2459 | |
|
2460 | 2460 | def test_put_update_with_attachment_only |
|
2461 | 2461 | set_tmp_attachments_directory |
|
2462 | 2462 | |
|
2463 | 2463 | # Delete all fixtured journals, a race condition can occur causing the wrong |
|
2464 | 2464 | # journal to get fetched in the next find. |
|
2465 | 2465 | Journal.delete_all |
|
2466 | 2466 | |
|
2467 | 2467 | # anonymous user |
|
2468 | 2468 | assert_difference 'Attachment.count' do |
|
2469 | 2469 | put :update, :id => 1, |
|
2470 | 2470 | :notes => '', |
|
2471 | 2471 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
2472 | 2472 | end |
|
2473 | 2473 | |
|
2474 | 2474 | assert_redirected_to :action => 'show', :id => '1' |
|
2475 | 2475 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
2476 | 2476 | assert j.notes.blank? |
|
2477 | 2477 | assert_equal 1, j.details.size |
|
2478 | 2478 | assert_equal 'testfile.txt', j.details.first.value |
|
2479 | 2479 | assert_equal User.anonymous, j.user |
|
2480 | 2480 | |
|
2481 | 2481 | attachment = Attachment.first(:order => 'id DESC') |
|
2482 | 2482 | assert_equal Issue.find(1), attachment.container |
|
2483 | 2483 | assert_equal User.anonymous, attachment.author |
|
2484 | 2484 | assert_equal 'testfile.txt', attachment.filename |
|
2485 | 2485 | assert_equal 'text/plain', attachment.content_type |
|
2486 | 2486 | assert_equal 'test file', attachment.description |
|
2487 | 2487 | assert_equal 59, attachment.filesize |
|
2488 | 2488 | assert File.exists?(attachment.diskfile) |
|
2489 | 2489 | assert_equal 59, File.size(attachment.diskfile) |
|
2490 | 2490 | |
|
2491 | 2491 | mail = ActionMailer::Base.deliveries.last |
|
2492 | 2492 | assert_mail_body_match 'testfile.txt', mail |
|
2493 | 2493 | end |
|
2494 | 2494 | |
|
2495 | 2495 | def test_put_update_with_failure_should_save_attachments |
|
2496 | 2496 | set_tmp_attachments_directory |
|
2497 | 2497 | @request.session[:user_id] = 2 |
|
2498 | 2498 | |
|
2499 | 2499 | assert_no_difference 'Journal.count' do |
|
2500 | 2500 | assert_difference 'Attachment.count' do |
|
2501 | 2501 | put :update, :id => 1, |
|
2502 | 2502 | :issue => { :subject => '' }, |
|
2503 | 2503 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
2504 | 2504 | assert_response :success |
|
2505 | 2505 | assert_template 'edit' |
|
2506 | 2506 | end |
|
2507 | 2507 | end |
|
2508 | 2508 | |
|
2509 | 2509 | attachment = Attachment.first(:order => 'id DESC') |
|
2510 | 2510 | assert_equal 'testfile.txt', attachment.filename |
|
2511 | 2511 | assert File.exists?(attachment.diskfile) |
|
2512 | 2512 | assert_nil attachment.container |
|
2513 | 2513 | |
|
2514 | 2514 | assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} |
|
2515 | 2515 | assert_tag 'span', :content => /testfile.txt/ |
|
2516 | 2516 | end |
|
2517 | 2517 | |
|
2518 | 2518 | def test_put_update_with_failure_should_keep_saved_attachments |
|
2519 | 2519 | set_tmp_attachments_directory |
|
2520 | 2520 | attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) |
|
2521 | 2521 | @request.session[:user_id] = 2 |
|
2522 | 2522 | |
|
2523 | 2523 | assert_no_difference 'Journal.count' do |
|
2524 | 2524 | assert_no_difference 'Attachment.count' do |
|
2525 | 2525 | put :update, :id => 1, |
|
2526 | 2526 | :issue => { :subject => '' }, |
|
2527 | 2527 | :attachments => {'p0' => {'token' => attachment.token}} |
|
2528 | 2528 | assert_response :success |
|
2529 | 2529 | assert_template 'edit' |
|
2530 | 2530 | end |
|
2531 | 2531 | end |
|
2532 | 2532 | |
|
2533 | 2533 | assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} |
|
2534 | 2534 | assert_tag 'span', :content => /testfile.txt/ |
|
2535 | 2535 | end |
|
2536 | 2536 | |
|
2537 | 2537 | def test_put_update_should_attach_saved_attachments |
|
2538 | 2538 | set_tmp_attachments_directory |
|
2539 | 2539 | attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) |
|
2540 | 2540 | @request.session[:user_id] = 2 |
|
2541 | 2541 | |
|
2542 | 2542 | assert_difference 'Journal.count' do |
|
2543 | 2543 | assert_difference 'JournalDetail.count' do |
|
2544 | 2544 | assert_no_difference 'Attachment.count' do |
|
2545 | 2545 | put :update, :id => 1, |
|
2546 | 2546 | :notes => 'Attachment added', |
|
2547 | 2547 | :attachments => {'p0' => {'token' => attachment.token}} |
|
2548 | 2548 | assert_redirected_to '/issues/1' |
|
2549 | 2549 | end |
|
2550 | 2550 | end |
|
2551 | 2551 | end |
|
2552 | 2552 | |
|
2553 | 2553 | attachment.reload |
|
2554 | 2554 | assert_equal Issue.find(1), attachment.container |
|
2555 | 2555 | |
|
2556 | 2556 | journal = Journal.first(:order => 'id DESC') |
|
2557 | 2557 | assert_equal 1, journal.details.size |
|
2558 | 2558 | assert_equal 'testfile.txt', journal.details.first.value |
|
2559 | 2559 | end |
|
2560 | 2560 | |
|
2561 | 2561 | def test_put_update_with_attachment_that_fails_to_save |
|
2562 | 2562 | set_tmp_attachments_directory |
|
2563 | 2563 | |
|
2564 | 2564 | # Delete all fixtured journals, a race condition can occur causing the wrong |
|
2565 | 2565 | # journal to get fetched in the next find. |
|
2566 | 2566 | Journal.delete_all |
|
2567 | 2567 | |
|
2568 | 2568 | # Mock out the unsaved attachment |
|
2569 | 2569 | Attachment.any_instance.stubs(:create).returns(Attachment.new) |
|
2570 | 2570 | |
|
2571 | 2571 | # anonymous user |
|
2572 | 2572 | put :update, |
|
2573 | 2573 | :id => 1, |
|
2574 | 2574 | :notes => '', |
|
2575 | 2575 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
2576 | 2576 | assert_redirected_to :action => 'show', :id => '1' |
|
2577 | 2577 | assert_equal '1 file(s) could not be saved.', flash[:warning] |
|
2578 | 2578 | end |
|
2579 | 2579 | |
|
2580 | 2580 | def test_put_update_with_no_change |
|
2581 | 2581 | issue = Issue.find(1) |
|
2582 | 2582 | issue.journals.clear |
|
2583 | 2583 | ActionMailer::Base.deliveries.clear |
|
2584 | 2584 | |
|
2585 | 2585 | put :update, |
|
2586 | 2586 | :id => 1, |
|
2587 | 2587 | :notes => '' |
|
2588 | 2588 | assert_redirected_to :action => 'show', :id => '1' |
|
2589 | 2589 | |
|
2590 | 2590 | issue.reload |
|
2591 | 2591 | assert issue.journals.empty? |
|
2592 | 2592 | # No email should be sent |
|
2593 | 2593 | assert ActionMailer::Base.deliveries.empty? |
|
2594 | 2594 | end |
|
2595 | 2595 | |
|
2596 | 2596 | def test_put_update_should_send_a_notification |
|
2597 | 2597 | @request.session[:user_id] = 2 |
|
2598 | 2598 | ActionMailer::Base.deliveries.clear |
|
2599 | 2599 | issue = Issue.find(1) |
|
2600 | 2600 | old_subject = issue.subject |
|
2601 | 2601 | new_subject = 'Subject modified by IssuesControllerTest#test_post_edit' |
|
2602 | 2602 | |
|
2603 | 2603 | put :update, :id => 1, :issue => {:subject => new_subject, |
|
2604 | 2604 | :priority_id => '6', |
|
2605 | 2605 | :category_id => '1' # no change |
|
2606 | 2606 | } |
|
2607 | 2607 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
2608 | 2608 | end |
|
2609 | 2609 | |
|
2610 | 2610 | def test_put_update_with_invalid_spent_time_hours_only |
|
2611 | 2611 | @request.session[:user_id] = 2 |
|
2612 | 2612 | notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time' |
|
2613 | 2613 | |
|
2614 | 2614 | assert_no_difference('Journal.count') do |
|
2615 | 2615 | put :update, |
|
2616 | 2616 | :id => 1, |
|
2617 | 2617 | :notes => notes, |
|
2618 | 2618 | :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"} |
|
2619 | 2619 | end |
|
2620 | 2620 | assert_response :success |
|
2621 | 2621 | assert_template 'edit' |
|
2622 | 2622 | |
|
2623 | 2623 | assert_error_tag :descendant => {:content => /Activity can't be blank/} |
|
2624 | 2624 | assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes |
|
2625 | 2625 | assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" } |
|
2626 | 2626 | end |
|
2627 | 2627 | |
|
2628 | 2628 | def test_put_update_with_invalid_spent_time_comments_only |
|
2629 | 2629 | @request.session[:user_id] = 2 |
|
2630 | 2630 | notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time' |
|
2631 | 2631 | |
|
2632 | 2632 | assert_no_difference('Journal.count') do |
|
2633 | 2633 | put :update, |
|
2634 | 2634 | :id => 1, |
|
2635 | 2635 | :notes => notes, |
|
2636 | 2636 | :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""} |
|
2637 | 2637 | end |
|
2638 | 2638 | assert_response :success |
|
2639 | 2639 | assert_template 'edit' |
|
2640 | 2640 | |
|
2641 | 2641 | assert_error_tag :descendant => {:content => /Activity can't be blank/} |
|
2642 | 2642 | assert_error_tag :descendant => {:content => /Hours can't be blank/} |
|
2643 | 2643 | assert_tag :textarea, :attributes => { :name => 'notes' }, :content => "\n"+notes |
|
2644 | 2644 | assert_tag :input, :attributes => { :name => 'time_entry[comments]', :value => "this is my comment" } |
|
2645 | 2645 | end |
|
2646 | 2646 | |
|
2647 | 2647 | def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject |
|
2648 | 2648 | issue = Issue.find(2) |
|
2649 | 2649 | @request.session[:user_id] = 2 |
|
2650 | 2650 | |
|
2651 | 2651 | put :update, |
|
2652 | 2652 | :id => issue.id, |
|
2653 | 2653 | :issue => { |
|
2654 | 2654 | :fixed_version_id => 4 |
|
2655 | 2655 | } |
|
2656 | 2656 | |
|
2657 | 2657 | assert_response :redirect |
|
2658 | 2658 | issue.reload |
|
2659 | 2659 | assert_equal 4, issue.fixed_version_id |
|
2660 | 2660 | assert_not_equal issue.project_id, issue.fixed_version.project_id |
|
2661 | 2661 | end |
|
2662 | 2662 | |
|
2663 | 2663 | def test_put_update_should_redirect_back_using_the_back_url_parameter |
|
2664 | 2664 | issue = Issue.find(2) |
|
2665 | 2665 | @request.session[:user_id] = 2 |
|
2666 | 2666 | |
|
2667 | 2667 | put :update, |
|
2668 | 2668 | :id => issue.id, |
|
2669 | 2669 | :issue => { |
|
2670 | 2670 | :fixed_version_id => 4 |
|
2671 | 2671 | }, |
|
2672 | 2672 | :back_url => '/issues' |
|
2673 | 2673 | |
|
2674 | 2674 | assert_response :redirect |
|
2675 | 2675 | assert_redirected_to '/issues' |
|
2676 | 2676 | end |
|
2677 | 2677 | |
|
2678 | 2678 | def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host |
|
2679 | 2679 | issue = Issue.find(2) |
|
2680 | 2680 | @request.session[:user_id] = 2 |
|
2681 | 2681 | |
|
2682 | 2682 | put :update, |
|
2683 | 2683 | :id => issue.id, |
|
2684 | 2684 | :issue => { |
|
2685 | 2685 | :fixed_version_id => 4 |
|
2686 | 2686 | }, |
|
2687 | 2687 | :back_url => 'http://google.com' |
|
2688 | 2688 | |
|
2689 | 2689 | assert_response :redirect |
|
2690 | 2690 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id |
|
2691 | 2691 | end |
|
2692 | 2692 | |
|
2693 | 2693 | def test_get_bulk_edit |
|
2694 | 2694 | @request.session[:user_id] = 2 |
|
2695 | 2695 | get :bulk_edit, :ids => [1, 2] |
|
2696 | 2696 | assert_response :success |
|
2697 | 2697 | assert_template 'bulk_edit' |
|
2698 | 2698 | |
|
2699 | 2699 | assert_tag :select, :attributes => {:name => 'issue[project_id]'} |
|
2700 | 2700 | assert_tag :input, :attributes => {:name => 'issue[parent_issue_id]'} |
|
2701 | 2701 | |
|
2702 | 2702 | # Project specific custom field, date type |
|
2703 | 2703 | field = CustomField.find(9) |
|
2704 | 2704 | assert !field.is_for_all? |
|
2705 | 2705 | assert_equal 'date', field.field_format |
|
2706 | 2706 | assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} |
|
2707 | 2707 | |
|
2708 | 2708 | # System wide custom field |
|
2709 | 2709 | assert CustomField.find(1).is_for_all? |
|
2710 | 2710 | assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'} |
|
2711 | 2711 | |
|
2712 | 2712 | # Be sure we don't display inactive IssuePriorities |
|
2713 | 2713 | assert ! IssuePriority.find(15).active? |
|
2714 | 2714 | assert_no_tag :option, :attributes => {:value => '15'}, |
|
2715 | 2715 | :parent => {:tag => 'select', :attributes => {:id => 'issue_priority_id'} } |
|
2716 | 2716 | end |
|
2717 | 2717 | |
|
2718 | 2718 | def test_get_bulk_edit_on_different_projects |
|
2719 | 2719 | @request.session[:user_id] = 2 |
|
2720 | 2720 | get :bulk_edit, :ids => [1, 2, 6] |
|
2721 | 2721 | assert_response :success |
|
2722 | 2722 | assert_template 'bulk_edit' |
|
2723 | 2723 | |
|
2724 | 2724 | # Can not set issues from different projects as children of an issue |
|
2725 | 2725 | assert_no_tag :input, :attributes => {:name => 'issue[parent_issue_id]'} |
|
2726 | 2726 | |
|
2727 | 2727 | # Project specific custom field, date type |
|
2728 | 2728 | field = CustomField.find(9) |
|
2729 | 2729 | assert !field.is_for_all? |
|
2730 | 2730 | assert !field.project_ids.include?(Issue.find(6).project_id) |
|
2731 | 2731 | assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} |
|
2732 | 2732 | end |
|
2733 | 2733 | |
|
2734 | 2734 | def test_get_bulk_edit_with_user_custom_field |
|
2735 | 2735 | field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true) |
|
2736 | 2736 | |
|
2737 | 2737 | @request.session[:user_id] = 2 |
|
2738 | 2738 | get :bulk_edit, :ids => [1, 2] |
|
2739 | 2739 | assert_response :success |
|
2740 | 2740 | assert_template 'bulk_edit' |
|
2741 | 2741 | |
|
2742 | 2742 | assert_tag :select, |
|
2743 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, | |
|
2743 | :attributes => {:name => "issue[custom_field_values][#{field.id}]", :class => 'user_cf'}, | |
|
2744 | 2744 | :children => { |
|
2745 | 2745 | :only => {:tag => 'option'}, |
|
2746 | 2746 | :count => Project.find(1).users.count + 2 # "no change" + "none" options |
|
2747 | 2747 | } |
|
2748 | 2748 | end |
|
2749 | 2749 | |
|
2750 | 2750 | def test_get_bulk_edit_with_version_custom_field |
|
2751 | 2751 | field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true) |
|
2752 | 2752 | |
|
2753 | 2753 | @request.session[:user_id] = 2 |
|
2754 | 2754 | get :bulk_edit, :ids => [1, 2] |
|
2755 | 2755 | assert_response :success |
|
2756 | 2756 | assert_template 'bulk_edit' |
|
2757 | 2757 | |
|
2758 | 2758 | assert_tag :select, |
|
2759 | 2759 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, |
|
2760 | 2760 | :children => { |
|
2761 | 2761 | :only => {:tag => 'option'}, |
|
2762 | 2762 | :count => Project.find(1).shared_versions.count + 2 # "no change" + "none" options |
|
2763 | 2763 | } |
|
2764 | 2764 | end |
|
2765 | 2765 | |
|
2766 | 2766 | def test_get_bulk_edit_with_multi_custom_field |
|
2767 | 2767 | field = CustomField.find(1) |
|
2768 | 2768 | field.update_attribute :multiple, true |
|
2769 | 2769 | |
|
2770 | 2770 | @request.session[:user_id] = 2 |
|
2771 | 2771 | get :bulk_edit, :ids => [1, 2] |
|
2772 | 2772 | assert_response :success |
|
2773 | 2773 | assert_template 'bulk_edit' |
|
2774 | 2774 | |
|
2775 | 2775 | assert_tag :select, |
|
2776 | 2776 | :attributes => {:name => "issue[custom_field_values][1][]"}, |
|
2777 | 2777 | :children => { |
|
2778 | 2778 | :only => {:tag => 'option'}, |
|
2779 | 2779 | :count => field.possible_values.size + 1 # "none" options |
|
2780 | 2780 | } |
|
2781 | 2781 | end |
|
2782 | 2782 | |
|
2783 | 2783 | def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues |
|
2784 | 2784 | Workflow.delete_all |
|
2785 | 2785 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1) |
|
2786 | 2786 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3) |
|
2787 | 2787 | Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4) |
|
2788 | 2788 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1) |
|
2789 | 2789 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3) |
|
2790 | 2790 | Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5) |
|
2791 | 2791 | @request.session[:user_id] = 2 |
|
2792 | 2792 | get :bulk_edit, :ids => [1, 2] |
|
2793 | 2793 | |
|
2794 | 2794 | assert_response :success |
|
2795 | 2795 | statuses = assigns(:available_statuses) |
|
2796 | 2796 | assert_not_nil statuses |
|
2797 | 2797 | assert_equal [1, 3], statuses.map(&:id).sort |
|
2798 | 2798 | |
|
2799 | 2799 | assert_tag 'select', :attributes => {:name => 'issue[status_id]'}, |
|
2800 | 2800 | :children => {:count => 3} # 2 statuses + "no change" option |
|
2801 | 2801 | end |
|
2802 | 2802 | |
|
2803 | 2803 | def test_bulk_edit_should_propose_target_project_open_shared_versions |
|
2804 | 2804 | @request.session[:user_id] = 2 |
|
2805 | 2805 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} |
|
2806 | 2806 | assert_response :success |
|
2807 | 2807 | assert_template 'bulk_edit' |
|
2808 | 2808 | assert_equal Project.find(1).shared_versions.open.all.sort, assigns(:versions).sort |
|
2809 | 2809 | assert_tag 'select', |
|
2810 | 2810 | :attributes => {:name => 'issue[fixed_version_id]'}, |
|
2811 | 2811 | :descendant => {:tag => 'option', :content => '2.0'} |
|
2812 | 2812 | end |
|
2813 | 2813 | |
|
2814 | 2814 | def test_bulk_edit_should_propose_target_project_categories |
|
2815 | 2815 | @request.session[:user_id] = 2 |
|
2816 | 2816 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} |
|
2817 | 2817 | assert_response :success |
|
2818 | 2818 | assert_template 'bulk_edit' |
|
2819 | 2819 | assert_equal Project.find(1).issue_categories.sort, assigns(:categories).sort |
|
2820 | 2820 | assert_tag 'select', |
|
2821 | 2821 | :attributes => {:name => 'issue[category_id]'}, |
|
2822 | 2822 | :descendant => {:tag => 'option', :content => 'Recipes'} |
|
2823 | 2823 | end |
|
2824 | 2824 | |
|
2825 | 2825 | def test_bulk_update |
|
2826 | 2826 | @request.session[:user_id] = 2 |
|
2827 | 2827 | # update issues priority |
|
2828 | 2828 | post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', |
|
2829 | 2829 | :issue => {:priority_id => 7, |
|
2830 | 2830 | :assigned_to_id => '', |
|
2831 | 2831 | :custom_field_values => {'2' => ''}} |
|
2832 | 2832 | |
|
2833 | 2833 | assert_response 302 |
|
2834 | 2834 | # check that the issues were updated |
|
2835 | 2835 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
2836 | 2836 | |
|
2837 | 2837 | issue = Issue.find(1) |
|
2838 | 2838 | journal = issue.journals.find(:first, :order => 'created_on DESC') |
|
2839 | 2839 | assert_equal '125', issue.custom_value_for(2).value |
|
2840 | 2840 | assert_equal 'Bulk editing', journal.notes |
|
2841 | 2841 | assert_equal 1, journal.details.size |
|
2842 | 2842 | end |
|
2843 | 2843 | |
|
2844 | 2844 | def test_bulk_update_with_group_assignee |
|
2845 | 2845 | group = Group.find(11) |
|
2846 | 2846 | project = Project.find(1) |
|
2847 | 2847 | project.members << Member.new(:principal => group, :roles => [Role.givable.first]) |
|
2848 | 2848 | |
|
2849 | 2849 | @request.session[:user_id] = 2 |
|
2850 | 2850 | # update issues assignee |
|
2851 | 2851 | post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', |
|
2852 | 2852 | :issue => {:priority_id => '', |
|
2853 | 2853 | :assigned_to_id => group.id, |
|
2854 | 2854 | :custom_field_values => {'2' => ''}} |
|
2855 | 2855 | |
|
2856 | 2856 | assert_response 302 |
|
2857 | 2857 | assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to} |
|
2858 | 2858 | end |
|
2859 | 2859 | |
|
2860 | 2860 | def test_bulk_update_on_different_projects |
|
2861 | 2861 | @request.session[:user_id] = 2 |
|
2862 | 2862 | # update issues priority |
|
2863 | 2863 | post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing', |
|
2864 | 2864 | :issue => {:priority_id => 7, |
|
2865 | 2865 | :assigned_to_id => '', |
|
2866 | 2866 | :custom_field_values => {'2' => ''}} |
|
2867 | 2867 | |
|
2868 | 2868 | assert_response 302 |
|
2869 | 2869 | # check that the issues were updated |
|
2870 | 2870 | assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id) |
|
2871 | 2871 | |
|
2872 | 2872 | issue = Issue.find(1) |
|
2873 | 2873 | journal = issue.journals.find(:first, :order => 'created_on DESC') |
|
2874 | 2874 | assert_equal '125', issue.custom_value_for(2).value |
|
2875 | 2875 | assert_equal 'Bulk editing', journal.notes |
|
2876 | 2876 | assert_equal 1, journal.details.size |
|
2877 | 2877 | end |
|
2878 | 2878 | |
|
2879 | 2879 | def test_bulk_update_on_different_projects_without_rights |
|
2880 | 2880 | @request.session[:user_id] = 3 |
|
2881 | 2881 | user = User.find(3) |
|
2882 | 2882 | action = { :controller => "issues", :action => "bulk_update" } |
|
2883 | 2883 | assert user.allowed_to?(action, Issue.find(1).project) |
|
2884 | 2884 | assert ! user.allowed_to?(action, Issue.find(6).project) |
|
2885 | 2885 | post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail', |
|
2886 | 2886 | :issue => {:priority_id => 7, |
|
2887 | 2887 | :assigned_to_id => '', |
|
2888 | 2888 | :custom_field_values => {'2' => ''}} |
|
2889 | 2889 | assert_response 403 |
|
2890 | 2890 | assert_not_equal "Bulk should fail", Journal.last.notes |
|
2891 | 2891 | end |
|
2892 | 2892 | |
|
2893 | 2893 | def test_bullk_update_should_send_a_notification |
|
2894 | 2894 | @request.session[:user_id] = 2 |
|
2895 | 2895 | ActionMailer::Base.deliveries.clear |
|
2896 | 2896 | post(:bulk_update, |
|
2897 | 2897 | { |
|
2898 | 2898 | :ids => [1, 2], |
|
2899 | 2899 | :notes => 'Bulk editing', |
|
2900 | 2900 | :issue => { |
|
2901 | 2901 | :priority_id => 7, |
|
2902 | 2902 | :assigned_to_id => '', |
|
2903 | 2903 | :custom_field_values => {'2' => ''} |
|
2904 | 2904 | } |
|
2905 | 2905 | }) |
|
2906 | 2906 | |
|
2907 | 2907 | assert_response 302 |
|
2908 | 2908 | assert_equal 2, ActionMailer::Base.deliveries.size |
|
2909 | 2909 | end |
|
2910 | 2910 | |
|
2911 | 2911 | def test_bulk_update_project |
|
2912 | 2912 | @request.session[:user_id] = 2 |
|
2913 | 2913 | post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'} |
|
2914 | 2914 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
|
2915 | 2915 | # Issues moved to project 2 |
|
2916 | 2916 | assert_equal 2, Issue.find(1).project_id |
|
2917 | 2917 | assert_equal 2, Issue.find(2).project_id |
|
2918 | 2918 | # No tracker change |
|
2919 | 2919 | assert_equal 1, Issue.find(1).tracker_id |
|
2920 | 2920 | assert_equal 2, Issue.find(2).tracker_id |
|
2921 | 2921 | end |
|
2922 | 2922 | |
|
2923 | 2923 | def test_bulk_update_project_on_single_issue_should_follow_when_needed |
|
2924 | 2924 | @request.session[:user_id] = 2 |
|
2925 | 2925 | post :bulk_update, :id => 1, :issue => {:project_id => '2'}, :follow => '1' |
|
2926 | 2926 | assert_redirected_to '/issues/1' |
|
2927 | 2927 | end |
|
2928 | 2928 | |
|
2929 | 2929 | def test_bulk_update_project_on_multiple_issues_should_follow_when_needed |
|
2930 | 2930 | @request.session[:user_id] = 2 |
|
2931 | 2931 | post :bulk_update, :id => [1, 2], :issue => {:project_id => '2'}, :follow => '1' |
|
2932 | 2932 | assert_redirected_to '/projects/onlinestore/issues' |
|
2933 | 2933 | end |
|
2934 | 2934 | |
|
2935 | 2935 | def test_bulk_update_tracker |
|
2936 | 2936 | @request.session[:user_id] = 2 |
|
2937 | 2937 | post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2'} |
|
2938 | 2938 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
|
2939 | 2939 | assert_equal 2, Issue.find(1).tracker_id |
|
2940 | 2940 | assert_equal 2, Issue.find(2).tracker_id |
|
2941 | 2941 | end |
|
2942 | 2942 | |
|
2943 | 2943 | def test_bulk_update_status |
|
2944 | 2944 | @request.session[:user_id] = 2 |
|
2945 | 2945 | # update issues priority |
|
2946 | 2946 | post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status', |
|
2947 | 2947 | :issue => {:priority_id => '', |
|
2948 | 2948 | :assigned_to_id => '', |
|
2949 | 2949 | :status_id => '5'} |
|
2950 | 2950 | |
|
2951 | 2951 | assert_response 302 |
|
2952 | 2952 | issue = Issue.find(1) |
|
2953 | 2953 | assert issue.closed? |
|
2954 | 2954 | end |
|
2955 | 2955 | |
|
2956 | 2956 | def test_bulk_update_priority |
|
2957 | 2957 | @request.session[:user_id] = 2 |
|
2958 | 2958 | post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6} |
|
2959 | 2959 | |
|
2960 | 2960 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
|
2961 | 2961 | assert_equal 6, Issue.find(1).priority_id |
|
2962 | 2962 | assert_equal 6, Issue.find(2).priority_id |
|
2963 | 2963 | end |
|
2964 | 2964 | |
|
2965 | 2965 | def test_bulk_update_with_notes |
|
2966 | 2966 | @request.session[:user_id] = 2 |
|
2967 | 2967 | post :bulk_update, :ids => [1, 2], :notes => 'Moving two issues' |
|
2968 | 2968 | |
|
2969 | 2969 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
|
2970 | 2970 | assert_equal 'Moving two issues', Issue.find(1).journals.sort_by(&:id).last.notes |
|
2971 | 2971 | assert_equal 'Moving two issues', Issue.find(2).journals.sort_by(&:id).last.notes |
|
2972 | 2972 | end |
|
2973 | 2973 | |
|
2974 | 2974 | def test_bulk_update_parent_id |
|
2975 | 2975 | @request.session[:user_id] = 2 |
|
2976 | 2976 | post :bulk_update, :ids => [1, 3], |
|
2977 | 2977 | :notes => 'Bulk editing parent', |
|
2978 | 2978 | :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_issue_id => '2'} |
|
2979 | 2979 | |
|
2980 | 2980 | assert_response 302 |
|
2981 | 2981 | parent = Issue.find(2) |
|
2982 | 2982 | assert_equal parent.id, Issue.find(1).parent_id |
|
2983 | 2983 | assert_equal parent.id, Issue.find(3).parent_id |
|
2984 | 2984 | assert_equal [1, 3], parent.children.collect(&:id).sort |
|
2985 | 2985 | end |
|
2986 | 2986 | |
|
2987 | 2987 | def test_bulk_update_custom_field |
|
2988 | 2988 | @request.session[:user_id] = 2 |
|
2989 | 2989 | # update issues priority |
|
2990 | 2990 | post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field', |
|
2991 | 2991 | :issue => {:priority_id => '', |
|
2992 | 2992 | :assigned_to_id => '', |
|
2993 | 2993 | :custom_field_values => {'2' => '777'}} |
|
2994 | 2994 | |
|
2995 | 2995 | assert_response 302 |
|
2996 | 2996 | |
|
2997 | 2997 | issue = Issue.find(1) |
|
2998 | 2998 | journal = issue.journals.find(:first, :order => 'created_on DESC') |
|
2999 | 2999 | assert_equal '777', issue.custom_value_for(2).value |
|
3000 | 3000 | assert_equal 1, journal.details.size |
|
3001 | 3001 | assert_equal '125', journal.details.first.old_value |
|
3002 | 3002 | assert_equal '777', journal.details.first.value |
|
3003 | 3003 | end |
|
3004 | 3004 | |
|
3005 | 3005 | def test_bulk_update_custom_field_to_blank |
|
3006 | 3006 | @request.session[:user_id] = 2 |
|
3007 | 3007 | post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing custom field', |
|
3008 | 3008 | :issue => {:priority_id => '', |
|
3009 | 3009 | :assigned_to_id => '', |
|
3010 | 3010 | :custom_field_values => {'1' => '__none__'}} |
|
3011 | 3011 | assert_response 302 |
|
3012 | 3012 | assert_equal '', Issue.find(1).custom_field_value(1) |
|
3013 | 3013 | assert_equal '', Issue.find(3).custom_field_value(1) |
|
3014 | 3014 | end |
|
3015 | 3015 | |
|
3016 | 3016 | def test_bulk_update_multi_custom_field |
|
3017 | 3017 | field = CustomField.find(1) |
|
3018 | 3018 | field.update_attribute :multiple, true |
|
3019 | 3019 | |
|
3020 | 3020 | @request.session[:user_id] = 2 |
|
3021 | 3021 | post :bulk_update, :ids => [1, 2, 3], :notes => 'Bulk editing multi custom field', |
|
3022 | 3022 | :issue => {:priority_id => '', |
|
3023 | 3023 | :assigned_to_id => '', |
|
3024 | 3024 | :custom_field_values => {'1' => ['MySQL', 'Oracle']}} |
|
3025 | 3025 | |
|
3026 | 3026 | assert_response 302 |
|
3027 | 3027 | |
|
3028 | 3028 | assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort |
|
3029 | 3029 | assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort |
|
3030 | 3030 | # the custom field is not associated with the issue tracker |
|
3031 | 3031 | assert_nil Issue.find(2).custom_field_value(1) |
|
3032 | 3032 | end |
|
3033 | 3033 | |
|
3034 | 3034 | def test_bulk_update_multi_custom_field_to_blank |
|
3035 | 3035 | field = CustomField.find(1) |
|
3036 | 3036 | field.update_attribute :multiple, true |
|
3037 | 3037 | |
|
3038 | 3038 | @request.session[:user_id] = 2 |
|
3039 | 3039 | post :bulk_update, :ids => [1, 3], :notes => 'Bulk editing multi custom field', |
|
3040 | 3040 | :issue => {:priority_id => '', |
|
3041 | 3041 | :assigned_to_id => '', |
|
3042 | 3042 | :custom_field_values => {'1' => ['__none__']}} |
|
3043 | 3043 | assert_response 302 |
|
3044 | 3044 | assert_equal [''], Issue.find(1).custom_field_value(1) |
|
3045 | 3045 | assert_equal [''], Issue.find(3).custom_field_value(1) |
|
3046 | 3046 | end |
|
3047 | 3047 | |
|
3048 | 3048 | def test_bulk_update_unassign |
|
3049 | 3049 | assert_not_nil Issue.find(2).assigned_to |
|
3050 | 3050 | @request.session[:user_id] = 2 |
|
3051 | 3051 | # unassign issues |
|
3052 | 3052 | post :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'} |
|
3053 | 3053 | assert_response 302 |
|
3054 | 3054 | # check that the issues were updated |
|
3055 | 3055 | assert_nil Issue.find(2).assigned_to |
|
3056 | 3056 | end |
|
3057 | 3057 | |
|
3058 | 3058 | def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject |
|
3059 | 3059 | @request.session[:user_id] = 2 |
|
3060 | 3060 | |
|
3061 | 3061 | post :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4} |
|
3062 | 3062 | |
|
3063 | 3063 | assert_response :redirect |
|
3064 | 3064 | issues = Issue.find([1,2]) |
|
3065 | 3065 | issues.each do |issue| |
|
3066 | 3066 | assert_equal 4, issue.fixed_version_id |
|
3067 | 3067 | assert_not_equal issue.project_id, issue.fixed_version.project_id |
|
3068 | 3068 | end |
|
3069 | 3069 | end |
|
3070 | 3070 | |
|
3071 | 3071 | def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter |
|
3072 | 3072 | @request.session[:user_id] = 2 |
|
3073 | 3073 | post :bulk_update, :ids => [1,2], :back_url => '/issues' |
|
3074 | 3074 | |
|
3075 | 3075 | assert_response :redirect |
|
3076 | 3076 | assert_redirected_to '/issues' |
|
3077 | 3077 | end |
|
3078 | 3078 | |
|
3079 | 3079 | def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host |
|
3080 | 3080 | @request.session[:user_id] = 2 |
|
3081 | 3081 | post :bulk_update, :ids => [1,2], :back_url => 'http://google.com' |
|
3082 | 3082 | |
|
3083 | 3083 | assert_response :redirect |
|
3084 | 3084 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier |
|
3085 | 3085 | end |
|
3086 | 3086 | |
|
3087 | 3087 | def test_bulk_update_with_failure_should_set_flash |
|
3088 | 3088 | @request.session[:user_id] = 2 |
|
3089 | 3089 | Issue.update_all("subject = ''", "id = 2") # Make it invalid |
|
3090 | 3090 | post :bulk_update, :ids => [1, 2], :issue => {:priority_id => 6} |
|
3091 | 3091 | |
|
3092 | 3092 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook' |
|
3093 | 3093 | assert_equal 'Failed to save 1 issue(s) on 2 selected: #2.', flash[:error] |
|
3094 | 3094 | end |
|
3095 | 3095 | |
|
3096 | 3096 | def test_get_bulk_copy |
|
3097 | 3097 | @request.session[:user_id] = 2 |
|
3098 | 3098 | get :bulk_edit, :ids => [1, 2, 3], :copy => '1' |
|
3099 | 3099 | assert_response :success |
|
3100 | 3100 | assert_template 'bulk_edit' |
|
3101 | 3101 | |
|
3102 | 3102 | issues = assigns(:issues) |
|
3103 | 3103 | assert_not_nil issues |
|
3104 | 3104 | assert_equal [1, 2, 3], issues.map(&:id).sort |
|
3105 | 3105 | |
|
3106 | 3106 | assert_select 'input[name=copy_attachments]' |
|
3107 | 3107 | end |
|
3108 | 3108 | |
|
3109 | 3109 | def test_bulk_copy_to_another_project |
|
3110 | 3110 | @request.session[:user_id] = 2 |
|
3111 | 3111 | assert_difference 'Issue.count', 2 do |
|
3112 | 3112 | assert_no_difference 'Project.find(1).issues.count' do |
|
3113 | 3113 | post :bulk_update, :ids => [1, 2], :issue => {:project_id => '2'}, :copy => '1' |
|
3114 | 3114 | end |
|
3115 | 3115 | end |
|
3116 | 3116 | assert_redirected_to '/projects/ecookbook/issues' |
|
3117 | 3117 | |
|
3118 | 3118 | copies = Issue.all(:order => 'id DESC', :limit => issues.size) |
|
3119 | 3119 | copies.each do |copy| |
|
3120 | 3120 | assert_equal 2, copy.project_id |
|
3121 | 3121 | end |
|
3122 | 3122 | end |
|
3123 | 3123 | |
|
3124 | 3124 | def test_bulk_copy_should_allow_not_changing_the_issue_attributes |
|
3125 | 3125 | @request.session[:user_id] = 2 |
|
3126 | 3126 | issues = [ |
|
3127 | 3127 | Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 1, :priority_id => 2, :subject => 'issue 1', :author_id => 1, :assigned_to_id => nil), |
|
3128 | 3128 | Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2, :priority_id => 1, :subject => 'issue 2', :author_id => 2, :assigned_to_id => 3) |
|
3129 | 3129 | ] |
|
3130 | 3130 | |
|
3131 | 3131 | assert_difference 'Issue.count', issues.size do |
|
3132 | 3132 | post :bulk_update, :ids => issues.map(&:id), :copy => '1', |
|
3133 | 3133 | :issue => { |
|
3134 | 3134 | :project_id => '', :tracker_id => '', :assigned_to_id => '', |
|
3135 | 3135 | :status_id => '', :start_date => '', :due_date => '' |
|
3136 | 3136 | } |
|
3137 | 3137 | end |
|
3138 | 3138 | |
|
3139 | 3139 | copies = Issue.all(:order => 'id DESC', :limit => issues.size) |
|
3140 | 3140 | issues.each do |orig| |
|
3141 | 3141 | copy = copies.detect {|c| c.subject == orig.subject} |
|
3142 | 3142 | assert_not_nil copy |
|
3143 | 3143 | assert_equal orig.project_id, copy.project_id |
|
3144 | 3144 | assert_equal orig.tracker_id, copy.tracker_id |
|
3145 | 3145 | assert_equal orig.status_id, copy.status_id |
|
3146 | 3146 | assert_equal orig.assigned_to_id, copy.assigned_to_id |
|
3147 | 3147 | assert_equal orig.priority_id, copy.priority_id |
|
3148 | 3148 | end |
|
3149 | 3149 | end |
|
3150 | 3150 | |
|
3151 | 3151 | def test_bulk_copy_should_allow_changing_the_issue_attributes |
|
3152 | 3152 | # Fixes random test failure with Mysql |
|
3153 | 3153 | # where Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) |
|
3154 | 3154 | # doesn't return the expected results |
|
3155 | 3155 | Issue.delete_all("project_id=2") |
|
3156 | 3156 | |
|
3157 | 3157 | @request.session[:user_id] = 2 |
|
3158 | 3158 | assert_difference 'Issue.count', 2 do |
|
3159 | 3159 | assert_no_difference 'Project.find(1).issues.count' do |
|
3160 | 3160 | post :bulk_update, :ids => [1, 2], :copy => '1', |
|
3161 | 3161 | :issue => { |
|
3162 | 3162 | :project_id => '2', :tracker_id => '', :assigned_to_id => '4', |
|
3163 | 3163 | :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31' |
|
3164 | 3164 | } |
|
3165 | 3165 | end |
|
3166 | 3166 | end |
|
3167 | 3167 | |
|
3168 | 3168 | copied_issues = Issue.all(:limit => 2, :order => 'id desc', :conditions => {:project_id => 2}) |
|
3169 | 3169 | assert_equal 2, copied_issues.size |
|
3170 | 3170 | copied_issues.each do |issue| |
|
3171 | 3171 | assert_equal 2, issue.project_id, "Project is incorrect" |
|
3172 | 3172 | assert_equal 4, issue.assigned_to_id, "Assigned to is incorrect" |
|
3173 | 3173 | assert_equal 1, issue.status_id, "Status is incorrect" |
|
3174 | 3174 | assert_equal '2009-12-01', issue.start_date.to_s, "Start date is incorrect" |
|
3175 | 3175 | assert_equal '2009-12-31', issue.due_date.to_s, "Due date is incorrect" |
|
3176 | 3176 | end |
|
3177 | 3177 | end |
|
3178 | 3178 | |
|
3179 | 3179 | def test_bulk_copy_should_allow_adding_a_note |
|
3180 | 3180 | @request.session[:user_id] = 2 |
|
3181 | 3181 | assert_difference 'Issue.count', 1 do |
|
3182 | 3182 | post :bulk_update, :ids => [1], :copy => '1', |
|
3183 | 3183 | :notes => 'Copying one issue', |
|
3184 | 3184 | :issue => { |
|
3185 | 3185 | :project_id => '', :tracker_id => '', :assigned_to_id => '4', |
|
3186 | 3186 | :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31' |
|
3187 | 3187 | } |
|
3188 | 3188 | end |
|
3189 | 3189 | |
|
3190 | 3190 | issue = Issue.first(:order => 'id DESC') |
|
3191 | 3191 | assert_equal 1, issue.journals.size |
|
3192 | 3192 | journal = issue.journals.first |
|
3193 | 3193 | assert_equal 0, journal.details.size |
|
3194 | 3194 | assert_equal 'Copying one issue', journal.notes |
|
3195 | 3195 | end |
|
3196 | 3196 | |
|
3197 | 3197 | def test_bulk_copy_should_allow_not_copying_the_attachments |
|
3198 | 3198 | attachment_count = Issue.find(3).attachments.size |
|
3199 | 3199 | assert attachment_count > 0 |
|
3200 | 3200 | @request.session[:user_id] = 2 |
|
3201 | 3201 | |
|
3202 | 3202 | assert_difference 'Issue.count', 1 do |
|
3203 | 3203 | assert_no_difference 'Attachment.count' do |
|
3204 | 3204 | post :bulk_update, :ids => [3], :copy => '1', |
|
3205 | 3205 | :issue => { |
|
3206 | 3206 | :project_id => '' |
|
3207 | 3207 | } |
|
3208 | 3208 | end |
|
3209 | 3209 | end |
|
3210 | 3210 | end |
|
3211 | 3211 | |
|
3212 | 3212 | def test_bulk_copy_should_allow_copying_the_attachments |
|
3213 | 3213 | attachment_count = Issue.find(3).attachments.size |
|
3214 | 3214 | assert attachment_count > 0 |
|
3215 | 3215 | @request.session[:user_id] = 2 |
|
3216 | 3216 | |
|
3217 | 3217 | assert_difference 'Issue.count', 1 do |
|
3218 | 3218 | assert_difference 'Attachment.count', attachment_count do |
|
3219 | 3219 | post :bulk_update, :ids => [3], :copy => '1', :copy_attachments => '1', |
|
3220 | 3220 | :issue => { |
|
3221 | 3221 | :project_id => '' |
|
3222 | 3222 | } |
|
3223 | 3223 | end |
|
3224 | 3224 | end |
|
3225 | 3225 | end |
|
3226 | 3226 | |
|
3227 | 3227 | def test_bulk_copy_to_another_project_should_follow_when_needed |
|
3228 | 3228 | @request.session[:user_id] = 2 |
|
3229 | 3229 | post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1' |
|
3230 | 3230 | issue = Issue.first(:order => 'id DESC') |
|
3231 | 3231 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue |
|
3232 | 3232 | end |
|
3233 | 3233 | |
|
3234 | 3234 | def test_destroy_issue_with_no_time_entries |
|
3235 | 3235 | assert_nil TimeEntry.find_by_issue_id(2) |
|
3236 | 3236 | @request.session[:user_id] = 2 |
|
3237 | 3237 | |
|
3238 | 3238 | assert_difference 'Issue.count', -1 do |
|
3239 | 3239 | delete :destroy, :id => 2 |
|
3240 | 3240 | end |
|
3241 | 3241 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
3242 | 3242 | assert_nil Issue.find_by_id(2) |
|
3243 | 3243 | end |
|
3244 | 3244 | |
|
3245 | 3245 | def test_destroy_issues_with_time_entries |
|
3246 | 3246 | @request.session[:user_id] = 2 |
|
3247 | 3247 | |
|
3248 | 3248 | assert_no_difference 'Issue.count' do |
|
3249 | 3249 | delete :destroy, :ids => [1, 3] |
|
3250 | 3250 | end |
|
3251 | 3251 | assert_response :success |
|
3252 | 3252 | assert_template 'destroy' |
|
3253 | 3253 | assert_not_nil assigns(:hours) |
|
3254 | 3254 | assert Issue.find_by_id(1) && Issue.find_by_id(3) |
|
3255 | 3255 | assert_tag 'form', |
|
3256 | 3256 | :descendant => {:tag => 'input', :attributes => {:name => '_method', :value => 'delete'}} |
|
3257 | 3257 | end |
|
3258 | 3258 | |
|
3259 | 3259 | def test_destroy_issues_and_destroy_time_entries |
|
3260 | 3260 | @request.session[:user_id] = 2 |
|
3261 | 3261 | |
|
3262 | 3262 | assert_difference 'Issue.count', -2 do |
|
3263 | 3263 | assert_difference 'TimeEntry.count', -3 do |
|
3264 | 3264 | delete :destroy, :ids => [1, 3], :todo => 'destroy' |
|
3265 | 3265 | end |
|
3266 | 3266 | end |
|
3267 | 3267 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
3268 | 3268 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
3269 | 3269 | assert_nil TimeEntry.find_by_id([1, 2]) |
|
3270 | 3270 | end |
|
3271 | 3271 | |
|
3272 | 3272 | def test_destroy_issues_and_assign_time_entries_to_project |
|
3273 | 3273 | @request.session[:user_id] = 2 |
|
3274 | 3274 | |
|
3275 | 3275 | assert_difference 'Issue.count', -2 do |
|
3276 | 3276 | assert_no_difference 'TimeEntry.count' do |
|
3277 | 3277 | delete :destroy, :ids => [1, 3], :todo => 'nullify' |
|
3278 | 3278 | end |
|
3279 | 3279 | end |
|
3280 | 3280 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
3281 | 3281 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
3282 | 3282 | assert_nil TimeEntry.find(1).issue_id |
|
3283 | 3283 | assert_nil TimeEntry.find(2).issue_id |
|
3284 | 3284 | end |
|
3285 | 3285 | |
|
3286 | 3286 | def test_destroy_issues_and_reassign_time_entries_to_another_issue |
|
3287 | 3287 | @request.session[:user_id] = 2 |
|
3288 | 3288 | |
|
3289 | 3289 | assert_difference 'Issue.count', -2 do |
|
3290 | 3290 | assert_no_difference 'TimeEntry.count' do |
|
3291 | 3291 | delete :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2 |
|
3292 | 3292 | end |
|
3293 | 3293 | end |
|
3294 | 3294 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
3295 | 3295 | assert !(Issue.find_by_id(1) || Issue.find_by_id(3)) |
|
3296 | 3296 | assert_equal 2, TimeEntry.find(1).issue_id |
|
3297 | 3297 | assert_equal 2, TimeEntry.find(2).issue_id |
|
3298 | 3298 | end |
|
3299 | 3299 | |
|
3300 | 3300 | def test_destroy_issues_from_different_projects |
|
3301 | 3301 | @request.session[:user_id] = 2 |
|
3302 | 3302 | |
|
3303 | 3303 | assert_difference 'Issue.count', -3 do |
|
3304 | 3304 | delete :destroy, :ids => [1, 2, 6], :todo => 'destroy' |
|
3305 | 3305 | end |
|
3306 | 3306 | assert_redirected_to :controller => 'issues', :action => 'index' |
|
3307 | 3307 | assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6)) |
|
3308 | 3308 | end |
|
3309 | 3309 | |
|
3310 | 3310 | def test_destroy_parent_and_child_issues |
|
3311 | 3311 | parent = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Parent Issue') |
|
3312 | 3312 | child = Issue.create!(:project_id => 1, :author_id => 1, :tracker_id => 1, :subject => 'Child Issue', :parent_issue_id => parent.id) |
|
3313 | 3313 | assert child.is_descendant_of?(parent.reload) |
|
3314 | 3314 | |
|
3315 | 3315 | @request.session[:user_id] = 2 |
|
3316 | 3316 | assert_difference 'Issue.count', -2 do |
|
3317 | 3317 | delete :destroy, :ids => [parent.id, child.id], :todo => 'destroy' |
|
3318 | 3318 | end |
|
3319 | 3319 | assert_response 302 |
|
3320 | 3320 | end |
|
3321 | 3321 | |
|
3322 | 3322 | def test_default_search_scope |
|
3323 | 3323 | get :index |
|
3324 | 3324 | assert_tag :div, :attributes => {:id => 'quick-search'}, |
|
3325 | 3325 | :child => {:tag => 'form', |
|
3326 | 3326 | :child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}} |
|
3327 | 3327 | end |
|
3328 | 3328 | end |
General Comments 0
You need to be logged in to leave comments.
Login now