|
@@
-1,689
+1,690
|
|
1
|
# Redmine - project management software
|
|
1
|
# Redmine - project management software
|
|
2
|
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
|
2
|
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
|
3
|
#
|
|
3
|
#
|
|
4
|
# This program is free software; you can redistribute it and/or
|
|
4
|
# This program is free software; you can redistribute it and/or
|
|
5
|
# modify it under the terms of the GNU General Public License
|
|
5
|
# modify it under the terms of the GNU General Public License
|
|
6
|
# as published by the Free Software Foundation; either version 2
|
|
6
|
# as published by the Free Software Foundation; either version 2
|
|
7
|
# of the License, or (at your option) any later version.
|
|
7
|
# of the License, or (at your option) any later version.
|
|
8
|
#
|
|
8
|
#
|
|
9
|
# This program is distributed in the hope that it will be useful,
|
|
9
|
# This program is distributed in the hope that it will be useful,
|
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
# GNU General Public License for more details.
|
|
12
|
# GNU General Public License for more details.
|
|
13
|
#
|
|
13
|
#
|
|
14
|
# You should have received a copy of the GNU General Public License
|
|
14
|
# You should have received a copy of the GNU General Public License
|
|
15
|
# along with this program; if not, write to the Free Software
|
|
15
|
# along with this program; if not, write to the Free Software
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
16
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
17
|
|
|
17
|
|
|
18
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
18
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
require 'issues_controller'
|
|
19
|
require 'issues_controller'
|
|
20
|
|
|
20
|
|
|
21
|
# Re-raise errors caught by the controller.
|
|
21
|
# Re-raise errors caught by the controller.
|
|
22
|
class IssuesController; def rescue_action(e) raise e end; end
|
|
22
|
class IssuesController; def rescue_action(e) raise e end; end
|
|
23
|
|
|
23
|
|
|
24
|
class IssuesControllerTest < Test::Unit::TestCase
|
|
24
|
class IssuesControllerTest < Test::Unit::TestCase
|
|
25
|
fixtures :projects,
|
|
25
|
fixtures :projects,
|
|
26
|
:users,
|
|
26
|
:users,
|
|
27
|
:roles,
|
|
27
|
:roles,
|
|
28
|
:members,
|
|
28
|
:members,
|
|
29
|
:issues,
|
|
29
|
:issues,
|
|
30
|
:issue_statuses,
|
|
30
|
:issue_statuses,
|
|
|
|
|
31
|
:versions,
|
|
31
|
:trackers,
|
|
32
|
:trackers,
|
|
32
|
:projects_trackers,
|
|
33
|
:projects_trackers,
|
|
33
|
:issue_categories,
|
|
34
|
:issue_categories,
|
|
34
|
:enabled_modules,
|
|
35
|
:enabled_modules,
|
|
35
|
:enumerations,
|
|
36
|
:enumerations,
|
|
36
|
:attachments,
|
|
37
|
:attachments,
|
|
37
|
:workflows,
|
|
38
|
:workflows,
|
|
38
|
:custom_fields,
|
|
39
|
:custom_fields,
|
|
39
|
:custom_values,
|
|
40
|
:custom_values,
|
|
40
|
:custom_fields_trackers,
|
|
41
|
:custom_fields_trackers,
|
|
41
|
:time_entries,
|
|
42
|
:time_entries,
|
|
42
|
:journals,
|
|
43
|
:journals,
|
|
43
|
:journal_details
|
|
44
|
:journal_details
|
|
44
|
|
|
45
|
|
|
45
|
def setup
|
|
46
|
def setup
|
|
46
|
@controller = IssuesController.new
|
|
47
|
@controller = IssuesController.new
|
|
47
|
@request = ActionController::TestRequest.new
|
|
48
|
@request = ActionController::TestRequest.new
|
|
48
|
@response = ActionController::TestResponse.new
|
|
49
|
@response = ActionController::TestResponse.new
|
|
49
|
User.current = nil
|
|
50
|
User.current = nil
|
|
50
|
end
|
|
51
|
end
|
|
51
|
|
|
52
|
|
|
52
|
def test_index
|
|
53
|
def test_index
|
|
53
|
get :index
|
|
54
|
get :index
|
|
54
|
assert_response :success
|
|
55
|
assert_response :success
|
|
55
|
assert_template 'index.rhtml'
|
|
56
|
assert_template 'index.rhtml'
|
|
56
|
assert_not_nil assigns(:issues)
|
|
57
|
assert_not_nil assigns(:issues)
|
|
57
|
assert_nil assigns(:project)
|
|
58
|
assert_nil assigns(:project)
|
|
58
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
59
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
59
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
60
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
60
|
# private projects hidden
|
|
61
|
# private projects hidden
|
|
61
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
62
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
62
|
assert_no_tag :tag => 'a', :content => /Issue on project 2/
|
|
63
|
assert_no_tag :tag => 'a', :content => /Issue on project 2/
|
|
63
|
end
|
|
64
|
end
|
|
64
|
|
|
65
|
|
|
65
|
def test_index_with_project
|
|
66
|
def test_index_with_project
|
|
66
|
Setting.display_subprojects_issues = 0
|
|
67
|
Setting.display_subprojects_issues = 0
|
|
67
|
get :index, :project_id => 1
|
|
68
|
get :index, :project_id => 1
|
|
68
|
assert_response :success
|
|
69
|
assert_response :success
|
|
69
|
assert_template 'index.rhtml'
|
|
70
|
assert_template 'index.rhtml'
|
|
70
|
assert_not_nil assigns(:issues)
|
|
71
|
assert_not_nil assigns(:issues)
|
|
71
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
72
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
72
|
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
|
73
|
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
|
73
|
end
|
|
74
|
end
|
|
74
|
|
|
75
|
|
|
75
|
def test_index_with_project_and_subprojects
|
|
76
|
def test_index_with_project_and_subprojects
|
|
76
|
Setting.display_subprojects_issues = 1
|
|
77
|
Setting.display_subprojects_issues = 1
|
|
77
|
get :index, :project_id => 1
|
|
78
|
get :index, :project_id => 1
|
|
78
|
assert_response :success
|
|
79
|
assert_response :success
|
|
79
|
assert_template 'index.rhtml'
|
|
80
|
assert_template 'index.rhtml'
|
|
80
|
assert_not_nil assigns(:issues)
|
|
81
|
assert_not_nil assigns(:issues)
|
|
81
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
82
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
82
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
83
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
83
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
84
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
84
|
end
|
|
85
|
end
|
|
85
|
|
|
86
|
|
|
86
|
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
|
87
|
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
|
87
|
@request.session[:user_id] = 2
|
|
88
|
@request.session[:user_id] = 2
|
|
88
|
Setting.display_subprojects_issues = 1
|
|
89
|
Setting.display_subprojects_issues = 1
|
|
89
|
get :index, :project_id => 1
|
|
90
|
get :index, :project_id => 1
|
|
90
|
assert_response :success
|
|
91
|
assert_response :success
|
|
91
|
assert_template 'index.rhtml'
|
|
92
|
assert_template 'index.rhtml'
|
|
92
|
assert_not_nil assigns(:issues)
|
|
93
|
assert_not_nil assigns(:issues)
|
|
93
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
94
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
94
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
95
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
95
|
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
96
|
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
96
|
end
|
|
97
|
end
|
|
97
|
|
|
98
|
|
|
98
|
def test_index_with_project_and_filter
|
|
99
|
def test_index_with_project_and_filter
|
|
99
|
get :index, :project_id => 1, :set_filter => 1
|
|
100
|
get :index, :project_id => 1, :set_filter => 1
|
|
100
|
assert_response :success
|
|
101
|
assert_response :success
|
|
101
|
assert_template 'index.rhtml'
|
|
102
|
assert_template 'index.rhtml'
|
|
102
|
assert_not_nil assigns(:issues)
|
|
103
|
assert_not_nil assigns(:issues)
|
|
103
|
end
|
|
104
|
end
|
|
104
|
|
|
105
|
|
|
105
|
def test_index_csv_with_project
|
|
106
|
def test_index_csv_with_project
|
|
106
|
get :index, :format => 'csv'
|
|
107
|
get :index, :format => 'csv'
|
|
107
|
assert_response :success
|
|
108
|
assert_response :success
|
|
108
|
assert_not_nil assigns(:issues)
|
|
109
|
assert_not_nil assigns(:issues)
|
|
109
|
assert_equal 'text/csv', @response.content_type
|
|
110
|
assert_equal 'text/csv', @response.content_type
|
|
110
|
|
|
111
|
|
|
111
|
get :index, :project_id => 1, :format => 'csv'
|
|
112
|
get :index, :project_id => 1, :format => 'csv'
|
|
112
|
assert_response :success
|
|
113
|
assert_response :success
|
|
113
|
assert_not_nil assigns(:issues)
|
|
114
|
assert_not_nil assigns(:issues)
|
|
114
|
assert_equal 'text/csv', @response.content_type
|
|
115
|
assert_equal 'text/csv', @response.content_type
|
|
115
|
end
|
|
116
|
end
|
|
116
|
|
|
117
|
|
|
117
|
def test_index_pdf
|
|
118
|
def test_index_pdf
|
|
118
|
get :index, :format => 'pdf'
|
|
119
|
get :index, :format => 'pdf'
|
|
119
|
assert_response :success
|
|
120
|
assert_response :success
|
|
120
|
assert_not_nil assigns(:issues)
|
|
121
|
assert_not_nil assigns(:issues)
|
|
121
|
assert_equal 'application/pdf', @response.content_type
|
|
122
|
assert_equal 'application/pdf', @response.content_type
|
|
122
|
|
|
123
|
|
|
123
|
get :index, :project_id => 1, :format => 'pdf'
|
|
124
|
get :index, :project_id => 1, :format => 'pdf'
|
|
124
|
assert_response :success
|
|
125
|
assert_response :success
|
|
125
|
assert_not_nil assigns(:issues)
|
|
126
|
assert_not_nil assigns(:issues)
|
|
126
|
assert_equal 'application/pdf', @response.content_type
|
|
127
|
assert_equal 'application/pdf', @response.content_type
|
|
127
|
end
|
|
128
|
end
|
|
128
|
|
|
129
|
|
|
129
|
def test_gantt
|
|
130
|
def test_gantt
|
|
130
|
get :gantt, :project_id => 1
|
|
131
|
get :gantt, :project_id => 1
|
|
131
|
assert_response :success
|
|
132
|
assert_response :success
|
|
132
|
assert_template 'gantt.rhtml'
|
|
133
|
assert_template 'gantt.rhtml'
|
|
133
|
assert_not_nil assigns(:gantt)
|
|
134
|
assert_not_nil assigns(:gantt)
|
|
134
|
events = assigns(:gantt).events
|
|
135
|
events = assigns(:gantt).events
|
|
135
|
assert_not_nil events
|
|
136
|
assert_not_nil events
|
|
136
|
# Issue with start and due dates
|
|
137
|
# Issue with start and due dates
|
|
137
|
i = Issue.find(1)
|
|
138
|
i = Issue.find(1)
|
|
138
|
assert_not_nil i.due_date
|
|
139
|
assert_not_nil i.due_date
|
|
139
|
assert events.include?(Issue.find(1))
|
|
140
|
assert events.include?(Issue.find(1))
|
|
140
|
# Issue with without due date but targeted to a version with date
|
|
141
|
# Issue with without due date but targeted to a version with date
|
|
141
|
i = Issue.find(2)
|
|
142
|
i = Issue.find(2)
|
|
142
|
assert_nil i.due_date
|
|
143
|
assert_nil i.due_date
|
|
143
|
assert events.include?(i)
|
|
144
|
assert events.include?(i)
|
|
144
|
end
|
|
145
|
end
|
|
145
|
|
|
146
|
|
|
146
|
def test_gantt_export_to_pdf
|
|
147
|
def test_gantt_export_to_pdf
|
|
147
|
get :gantt, :project_id => 1, :format => 'pdf'
|
|
148
|
get :gantt, :project_id => 1, :format => 'pdf'
|
|
148
|
assert_response :success
|
|
149
|
assert_response :success
|
|
149
|
assert_template 'gantt.rfpdf'
|
|
150
|
assert_template 'gantt.rfpdf'
|
|
150
|
assert_equal 'application/pdf', @response.content_type
|
|
151
|
assert_equal 'application/pdf', @response.content_type
|
|
151
|
assert_not_nil assigns(:gantt)
|
|
152
|
assert_not_nil assigns(:gantt)
|
|
152
|
end
|
|
153
|
end
|
|
153
|
|
|
154
|
|
|
154
|
if Object.const_defined?(:Magick)
|
|
155
|
if Object.const_defined?(:Magick)
|
|
155
|
def test_gantt_image
|
|
156
|
def test_gantt_image
|
|
156
|
get :gantt, :project_id => 1, :format => 'png'
|
|
157
|
get :gantt, :project_id => 1, :format => 'png'
|
|
157
|
assert_response :success
|
|
158
|
assert_response :success
|
|
158
|
assert_equal 'image/png', @response.content_type
|
|
159
|
assert_equal 'image/png', @response.content_type
|
|
159
|
end
|
|
160
|
end
|
|
160
|
else
|
|
161
|
else
|
|
161
|
puts "RMagick not installed. Skipping tests !!!"
|
|
162
|
puts "RMagick not installed. Skipping tests !!!"
|
|
162
|
end
|
|
163
|
end
|
|
163
|
|
|
164
|
|
|
164
|
def test_calendar
|
|
165
|
def test_calendar
|
|
165
|
get :calendar, :project_id => 1
|
|
166
|
get :calendar, :project_id => 1
|
|
166
|
assert_response :success
|
|
167
|
assert_response :success
|
|
167
|
assert_template 'calendar'
|
|
168
|
assert_template 'calendar'
|
|
168
|
assert_not_nil assigns(:calendar)
|
|
169
|
assert_not_nil assigns(:calendar)
|
|
169
|
end
|
|
170
|
end
|
|
170
|
|
|
171
|
|
|
171
|
def test_changes
|
|
172
|
def test_changes
|
|
172
|
get :changes, :project_id => 1
|
|
173
|
get :changes, :project_id => 1
|
|
173
|
assert_response :success
|
|
174
|
assert_response :success
|
|
174
|
assert_not_nil assigns(:journals)
|
|
175
|
assert_not_nil assigns(:journals)
|
|
175
|
assert_equal 'application/atom+xml', @response.content_type
|
|
176
|
assert_equal 'application/atom+xml', @response.content_type
|
|
176
|
end
|
|
177
|
end
|
|
177
|
|
|
178
|
|
|
178
|
def test_show_by_anonymous
|
|
179
|
def test_show_by_anonymous
|
|
179
|
get :show, :id => 1
|
|
180
|
get :show, :id => 1
|
|
180
|
assert_response :success
|
|
181
|
assert_response :success
|
|
181
|
assert_template 'show.rhtml'
|
|
182
|
assert_template 'show.rhtml'
|
|
182
|
assert_not_nil assigns(:issue)
|
|
183
|
assert_not_nil assigns(:issue)
|
|
183
|
assert_equal Issue.find(1), assigns(:issue)
|
|
184
|
assert_equal Issue.find(1), assigns(:issue)
|
|
184
|
|
|
185
|
|
|
185
|
# anonymous role is allowed to add a note
|
|
186
|
# anonymous role is allowed to add a note
|
|
186
|
assert_tag :tag => 'form',
|
|
187
|
assert_tag :tag => 'form',
|
|
187
|
:descendant => { :tag => 'fieldset',
|
|
188
|
:descendant => { :tag => 'fieldset',
|
|
188
|
:child => { :tag => 'legend',
|
|
189
|
:child => { :tag => 'legend',
|
|
189
|
:content => /Notes/ } }
|
|
190
|
:content => /Notes/ } }
|
|
190
|
end
|
|
191
|
end
|
|
191
|
|
|
192
|
|
|
192
|
def test_show_by_manager
|
|
193
|
def test_show_by_manager
|
|
193
|
@request.session[:user_id] = 2
|
|
194
|
@request.session[:user_id] = 2
|
|
194
|
get :show, :id => 1
|
|
195
|
get :show, :id => 1
|
|
195
|
assert_response :success
|
|
196
|
assert_response :success
|
|
196
|
|
|
197
|
|
|
197
|
assert_tag :tag => 'form',
|
|
198
|
assert_tag :tag => 'form',
|
|
198
|
:descendant => { :tag => 'fieldset',
|
|
199
|
:descendant => { :tag => 'fieldset',
|
|
199
|
:child => { :tag => 'legend',
|
|
200
|
:child => { :tag => 'legend',
|
|
200
|
:content => /Change properties/ } },
|
|
201
|
:content => /Change properties/ } },
|
|
201
|
:descendant => { :tag => 'fieldset',
|
|
202
|
:descendant => { :tag => 'fieldset',
|
|
202
|
:child => { :tag => 'legend',
|
|
203
|
:child => { :tag => 'legend',
|
|
203
|
:content => /Log time/ } },
|
|
204
|
:content => /Log time/ } },
|
|
204
|
:descendant => { :tag => 'fieldset',
|
|
205
|
:descendant => { :tag => 'fieldset',
|
|
205
|
:child => { :tag => 'legend',
|
|
206
|
:child => { :tag => 'legend',
|
|
206
|
:content => /Notes/ } }
|
|
207
|
:content => /Notes/ } }
|
|
207
|
end
|
|
208
|
end
|
|
208
|
|
|
209
|
|
|
209
|
def test_get_new
|
|
210
|
def test_get_new
|
|
210
|
@request.session[:user_id] = 2
|
|
211
|
@request.session[:user_id] = 2
|
|
211
|
get :new, :project_id => 1, :tracker_id => 1
|
|
212
|
get :new, :project_id => 1, :tracker_id => 1
|
|
212
|
assert_response :success
|
|
213
|
assert_response :success
|
|
213
|
assert_template 'new'
|
|
214
|
assert_template 'new'
|
|
214
|
|
|
215
|
|
|
215
|
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
|
216
|
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
|
216
|
:value => 'Default string' }
|
|
217
|
:value => 'Default string' }
|
|
217
|
end
|
|
218
|
end
|
|
218
|
|
|
219
|
|
|
219
|
def test_get_new_without_tracker_id
|
|
220
|
def test_get_new_without_tracker_id
|
|
220
|
@request.session[:user_id] = 2
|
|
221
|
@request.session[:user_id] = 2
|
|
221
|
get :new, :project_id => 1
|
|
222
|
get :new, :project_id => 1
|
|
222
|
assert_response :success
|
|
223
|
assert_response :success
|
|
223
|
assert_template 'new'
|
|
224
|
assert_template 'new'
|
|
224
|
|
|
225
|
|
|
225
|
issue = assigns(:issue)
|
|
226
|
issue = assigns(:issue)
|
|
226
|
assert_not_nil issue
|
|
227
|
assert_not_nil issue
|
|
227
|
assert_equal Project.find(1).trackers.first, issue.tracker
|
|
228
|
assert_equal Project.find(1).trackers.first, issue.tracker
|
|
228
|
end
|
|
229
|
end
|
|
229
|
|
|
230
|
|
|
230
|
def test_update_new_form
|
|
231
|
def test_update_new_form
|
|
231
|
@request.session[:user_id] = 2
|
|
232
|
@request.session[:user_id] = 2
|
|
232
|
xhr :post, :new, :project_id => 1,
|
|
233
|
xhr :post, :new, :project_id => 1,
|
|
233
|
:issue => {:tracker_id => 2,
|
|
234
|
:issue => {:tracker_id => 2,
|
|
234
|
:subject => 'This is the test_new issue',
|
|
235
|
:subject => 'This is the test_new issue',
|
|
235
|
:description => 'This is the description',
|
|
236
|
:description => 'This is the description',
|
|
236
|
:priority_id => 5}
|
|
237
|
:priority_id => 5}
|
|
237
|
assert_response :success
|
|
238
|
assert_response :success
|
|
238
|
assert_template 'new'
|
|
239
|
assert_template 'new'
|
|
239
|
end
|
|
240
|
end
|
|
240
|
|
|
241
|
|
|
241
|
def test_post_new
|
|
242
|
def test_post_new
|
|
242
|
@request.session[:user_id] = 2
|
|
243
|
@request.session[:user_id] = 2
|
|
243
|
post :new, :project_id => 1,
|
|
244
|
post :new, :project_id => 1,
|
|
244
|
:issue => {:tracker_id => 3,
|
|
245
|
:issue => {:tracker_id => 3,
|
|
245
|
:subject => 'This is the test_new issue',
|
|
246
|
:subject => 'This is the test_new issue',
|
|
246
|
:description => 'This is the description',
|
|
247
|
:description => 'This is the description',
|
|
247
|
:priority_id => 5,
|
|
248
|
:priority_id => 5,
|
|
248
|
:estimated_hours => '',
|
|
249
|
:estimated_hours => '',
|
|
249
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
250
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
250
|
assert_redirected_to 'issues/show'
|
|
251
|
assert_redirected_to 'issues/show'
|
|
251
|
|
|
252
|
|
|
252
|
issue = Issue.find_by_subject('This is the test_new issue')
|
|
253
|
issue = Issue.find_by_subject('This is the test_new issue')
|
|
253
|
assert_not_nil issue
|
|
254
|
assert_not_nil issue
|
|
254
|
assert_equal 2, issue.author_id
|
|
255
|
assert_equal 2, issue.author_id
|
|
255
|
assert_equal 3, issue.tracker_id
|
|
256
|
assert_equal 3, issue.tracker_id
|
|
256
|
assert_nil issue.estimated_hours
|
|
257
|
assert_nil issue.estimated_hours
|
|
257
|
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
|
258
|
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
|
258
|
assert_not_nil v
|
|
259
|
assert_not_nil v
|
|
259
|
assert_equal 'Value for field 2', v.value
|
|
260
|
assert_equal 'Value for field 2', v.value
|
|
260
|
end
|
|
261
|
end
|
|
261
|
|
|
262
|
|
|
262
|
def test_post_new_without_custom_fields_param
|
|
263
|
def test_post_new_without_custom_fields_param
|
|
263
|
@request.session[:user_id] = 2
|
|
264
|
@request.session[:user_id] = 2
|
|
264
|
post :new, :project_id => 1,
|
|
265
|
post :new, :project_id => 1,
|
|
265
|
:issue => {:tracker_id => 1,
|
|
266
|
:issue => {:tracker_id => 1,
|
|
266
|
:subject => 'This is the test_new issue',
|
|
267
|
:subject => 'This is the test_new issue',
|
|
267
|
:description => 'This is the description',
|
|
268
|
:description => 'This is the description',
|
|
268
|
:priority_id => 5}
|
|
269
|
:priority_id => 5}
|
|
269
|
assert_redirected_to 'issues/show'
|
|
270
|
assert_redirected_to 'issues/show'
|
|
270
|
end
|
|
271
|
end
|
|
271
|
|
|
272
|
|
|
272
|
def test_post_new_with_required_custom_field_and_without_custom_fields_param
|
|
273
|
def test_post_new_with_required_custom_field_and_without_custom_fields_param
|
|
273
|
field = IssueCustomField.find_by_name('Database')
|
|
274
|
field = IssueCustomField.find_by_name('Database')
|
|
274
|
field.update_attribute(:is_required, true)
|
|
275
|
field.update_attribute(:is_required, true)
|
|
275
|
|
|
276
|
|
|
276
|
@request.session[:user_id] = 2
|
|
277
|
@request.session[:user_id] = 2
|
|
277
|
post :new, :project_id => 1,
|
|
278
|
post :new, :project_id => 1,
|
|
278
|
:issue => {:tracker_id => 1,
|
|
279
|
:issue => {:tracker_id => 1,
|
|
279
|
:subject => 'This is the test_new issue',
|
|
280
|
:subject => 'This is the test_new issue',
|
|
280
|
:description => 'This is the description',
|
|
281
|
:description => 'This is the description',
|
|
281
|
:priority_id => 5}
|
|
282
|
:priority_id => 5}
|
|
282
|
assert_response :success
|
|
283
|
assert_response :success
|
|
283
|
assert_template 'new'
|
|
284
|
assert_template 'new'
|
|
284
|
issue = assigns(:issue)
|
|
285
|
issue = assigns(:issue)
|
|
285
|
assert_not_nil issue
|
|
286
|
assert_not_nil issue
|
|
286
|
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
|
287
|
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
|
287
|
end
|
|
288
|
end
|
|
288
|
|
|
289
|
|
|
289
|
def test_post_should_preserve_fields_values_on_validation_failure
|
|
290
|
def test_post_should_preserve_fields_values_on_validation_failure
|
|
290
|
@request.session[:user_id] = 2
|
|
291
|
@request.session[:user_id] = 2
|
|
291
|
post :new, :project_id => 1,
|
|
292
|
post :new, :project_id => 1,
|
|
292
|
:issue => {:tracker_id => 1,
|
|
293
|
:issue => {:tracker_id => 1,
|
|
293
|
:subject => 'This is the test_new issue',
|
|
294
|
:subject => 'This is the test_new issue',
|
|
294
|
# empty description
|
|
295
|
# empty description
|
|
295
|
:description => '',
|
|
296
|
:description => '',
|
|
296
|
:priority_id => 6,
|
|
297
|
:priority_id => 6,
|
|
297
|
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
|
298
|
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
|
298
|
assert_response :success
|
|
299
|
assert_response :success
|
|
299
|
assert_template 'new'
|
|
300
|
assert_template 'new'
|
|
300
|
|
|
301
|
|
|
301
|
assert_tag :input, :attributes => { :name => 'issue[subject]',
|
|
302
|
assert_tag :input, :attributes => { :name => 'issue[subject]',
|
|
302
|
:value => 'This is the test_new issue' }
|
|
303
|
:value => 'This is the test_new issue' }
|
|
303
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
304
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
304
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
305
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
305
|
:value => '6' },
|
|
306
|
:value => '6' },
|
|
306
|
:content => 'High' }
|
|
307
|
:content => 'High' }
|
|
307
|
# Custom fields
|
|
308
|
# Custom fields
|
|
308
|
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
|
309
|
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
|
309
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
310
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
310
|
:value => 'Oracle' },
|
|
311
|
:value => 'Oracle' },
|
|
311
|
:content => 'Oracle' }
|
|
312
|
:content => 'Oracle' }
|
|
312
|
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
|
313
|
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
|
313
|
:value => 'Value for field 2'}
|
|
314
|
:value => 'Value for field 2'}
|
|
314
|
end
|
|
315
|
end
|
|
315
|
|
|
316
|
|
|
316
|
def test_copy_issue
|
|
317
|
def test_copy_issue
|
|
317
|
@request.session[:user_id] = 2
|
|
318
|
@request.session[:user_id] = 2
|
|
318
|
get :new, :project_id => 1, :copy_from => 1
|
|
319
|
get :new, :project_id => 1, :copy_from => 1
|
|
319
|
assert_template 'new'
|
|
320
|
assert_template 'new'
|
|
320
|
assert_not_nil assigns(:issue)
|
|
321
|
assert_not_nil assigns(:issue)
|
|
321
|
orig = Issue.find(1)
|
|
322
|
orig = Issue.find(1)
|
|
322
|
assert_equal orig.subject, assigns(:issue).subject
|
|
323
|
assert_equal orig.subject, assigns(:issue).subject
|
|
323
|
end
|
|
324
|
end
|
|
324
|
|
|
325
|
|
|
325
|
def test_get_edit
|
|
326
|
def test_get_edit
|
|
326
|
@request.session[:user_id] = 2
|
|
327
|
@request.session[:user_id] = 2
|
|
327
|
get :edit, :id => 1
|
|
328
|
get :edit, :id => 1
|
|
328
|
assert_response :success
|
|
329
|
assert_response :success
|
|
329
|
assert_template 'edit'
|
|
330
|
assert_template 'edit'
|
|
330
|
assert_not_nil assigns(:issue)
|
|
331
|
assert_not_nil assigns(:issue)
|
|
331
|
assert_equal Issue.find(1), assigns(:issue)
|
|
332
|
assert_equal Issue.find(1), assigns(:issue)
|
|
332
|
end
|
|
333
|
end
|
|
333
|
|
|
334
|
|
|
334
|
def test_get_edit_with_params
|
|
335
|
def test_get_edit_with_params
|
|
335
|
@request.session[:user_id] = 2
|
|
336
|
@request.session[:user_id] = 2
|
|
336
|
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
|
337
|
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
|
337
|
assert_response :success
|
|
338
|
assert_response :success
|
|
338
|
assert_template 'edit'
|
|
339
|
assert_template 'edit'
|
|
339
|
|
|
340
|
|
|
340
|
issue = assigns(:issue)
|
|
341
|
issue = assigns(:issue)
|
|
341
|
assert_not_nil issue
|
|
342
|
assert_not_nil issue
|
|
342
|
|
|
343
|
|
|
343
|
assert_equal 5, issue.status_id
|
|
344
|
assert_equal 5, issue.status_id
|
|
344
|
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
|
345
|
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
|
345
|
:child => { :tag => 'option',
|
|
346
|
:child => { :tag => 'option',
|
|
346
|
:content => 'Closed',
|
|
347
|
:content => 'Closed',
|
|
347
|
:attributes => { :selected => 'selected' } }
|
|
348
|
:attributes => { :selected => 'selected' } }
|
|
348
|
|
|
349
|
|
|
349
|
assert_equal 7, issue.priority_id
|
|
350
|
assert_equal 7, issue.priority_id
|
|
350
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
351
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
351
|
:child => { :tag => 'option',
|
|
352
|
:child => { :tag => 'option',
|
|
352
|
:content => 'Urgent',
|
|
353
|
:content => 'Urgent',
|
|
353
|
:attributes => { :selected => 'selected' } }
|
|
354
|
:attributes => { :selected => 'selected' } }
|
|
354
|
end
|
|
355
|
end
|
|
355
|
|
|
356
|
|
|
356
|
def test_reply_to_issue
|
|
357
|
def test_reply_to_issue
|
|
357
|
@request.session[:user_id] = 2
|
|
358
|
@request.session[:user_id] = 2
|
|
358
|
get :reply, :id => 1
|
|
359
|
get :reply, :id => 1
|
|
359
|
assert_response :success
|
|
360
|
assert_response :success
|
|
360
|
assert_select_rjs :show, "update"
|
|
361
|
assert_select_rjs :show, "update"
|
|
361
|
end
|
|
362
|
end
|
|
362
|
|
|
363
|
|
|
363
|
def test_reply_to_note
|
|
364
|
def test_reply_to_note
|
|
364
|
@request.session[:user_id] = 2
|
|
365
|
@request.session[:user_id] = 2
|
|
365
|
get :reply, :id => 1, :journal_id => 2
|
|
366
|
get :reply, :id => 1, :journal_id => 2
|
|
366
|
assert_response :success
|
|
367
|
assert_response :success
|
|
367
|
assert_select_rjs :show, "update"
|
|
368
|
assert_select_rjs :show, "update"
|
|
368
|
end
|
|
369
|
end
|
|
369
|
|
|
370
|
|
|
370
|
def test_post_edit_without_custom_fields_param
|
|
371
|
def test_post_edit_without_custom_fields_param
|
|
371
|
@request.session[:user_id] = 2
|
|
372
|
@request.session[:user_id] = 2
|
|
372
|
ActionMailer::Base.deliveries.clear
|
|
373
|
ActionMailer::Base.deliveries.clear
|
|
373
|
|
|
374
|
|
|
374
|
issue = Issue.find(1)
|
|
375
|
issue = Issue.find(1)
|
|
375
|
assert_equal '125', issue.custom_value_for(2).value
|
|
376
|
assert_equal '125', issue.custom_value_for(2).value
|
|
376
|
old_subject = issue.subject
|
|
377
|
old_subject = issue.subject
|
|
377
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
378
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
378
|
|
|
379
|
|
|
379
|
assert_difference('Journal.count') do
|
|
380
|
assert_difference('Journal.count') do
|
|
380
|
assert_difference('JournalDetail.count', 2) do
|
|
381
|
assert_difference('JournalDetail.count', 2) do
|
|
381
|
post :edit, :id => 1, :issue => {:subject => new_subject,
|
|
382
|
post :edit, :id => 1, :issue => {:subject => new_subject,
|
|
382
|
:priority_id => '6',
|
|
383
|
:priority_id => '6',
|
|
383
|
:category_id => '1' # no change
|
|
384
|
:category_id => '1' # no change
|
|
384
|
}
|
|
385
|
}
|
|
385
|
end
|
|
386
|
end
|
|
386
|
end
|
|
387
|
end
|
|
387
|
assert_redirected_to 'issues/show/1'
|
|
388
|
assert_redirected_to 'issues/show/1'
|
|
388
|
issue.reload
|
|
389
|
issue.reload
|
|
389
|
assert_equal new_subject, issue.subject
|
|
390
|
assert_equal new_subject, issue.subject
|
|
390
|
# Make sure custom fields were not cleared
|
|
391
|
# Make sure custom fields were not cleared
|
|
391
|
assert_equal '125', issue.custom_value_for(2).value
|
|
392
|
assert_equal '125', issue.custom_value_for(2).value
|
|
392
|
|
|
393
|
|
|
393
|
mail = ActionMailer::Base.deliveries.last
|
|
394
|
mail = ActionMailer::Base.deliveries.last
|
|
394
|
assert_kind_of TMail::Mail, mail
|
|
395
|
assert_kind_of TMail::Mail, mail
|
|
395
|
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
|
396
|
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
|
396
|
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
|
397
|
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
|
397
|
end
|
|
398
|
end
|
|
398
|
|
|
399
|
|
|
399
|
def test_post_edit_with_custom_field_change
|
|
400
|
def test_post_edit_with_custom_field_change
|
|
400
|
@request.session[:user_id] = 2
|
|
401
|
@request.session[:user_id] = 2
|
|
401
|
issue = Issue.find(1)
|
|
402
|
issue = Issue.find(1)
|
|
402
|
assert_equal '125', issue.custom_value_for(2).value
|
|
403
|
assert_equal '125', issue.custom_value_for(2).value
|
|
403
|
|
|
404
|
|
|
404
|
assert_difference('Journal.count') do
|
|
405
|
assert_difference('Journal.count') do
|
|
405
|
assert_difference('JournalDetail.count', 3) do
|
|
406
|
assert_difference('JournalDetail.count', 3) do
|
|
406
|
post :edit, :id => 1, :issue => {:subject => 'Custom field change',
|
|
407
|
post :edit, :id => 1, :issue => {:subject => 'Custom field change',
|
|
407
|
:priority_id => '6',
|
|
408
|
:priority_id => '6',
|
|
408
|
:category_id => '1', # no change
|
|
409
|
:category_id => '1', # no change
|
|
409
|
:custom_field_values => { '2' => 'New custom value' }
|
|
410
|
:custom_field_values => { '2' => 'New custom value' }
|
|
410
|
}
|
|
411
|
}
|
|
411
|
end
|
|
412
|
end
|
|
412
|
end
|
|
413
|
end
|
|
413
|
assert_redirected_to 'issues/show/1'
|
|
414
|
assert_redirected_to 'issues/show/1'
|
|
414
|
issue.reload
|
|
415
|
issue.reload
|
|
415
|
assert_equal 'New custom value', issue.custom_value_for(2).value
|
|
416
|
assert_equal 'New custom value', issue.custom_value_for(2).value
|
|
416
|
|
|
417
|
|
|
417
|
mail = ActionMailer::Base.deliveries.last
|
|
418
|
mail = ActionMailer::Base.deliveries.last
|
|
418
|
assert_kind_of TMail::Mail, mail
|
|
419
|
assert_kind_of TMail::Mail, mail
|
|
419
|
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
|
420
|
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
|
420
|
end
|
|
421
|
end
|
|
421
|
|
|
422
|
|
|
422
|
def test_post_edit_with_status_and_assignee_change
|
|
423
|
def test_post_edit_with_status_and_assignee_change
|
|
423
|
issue = Issue.find(1)
|
|
424
|
issue = Issue.find(1)
|
|
424
|
assert_equal 1, issue.status_id
|
|
425
|
assert_equal 1, issue.status_id
|
|
425
|
@request.session[:user_id] = 2
|
|
426
|
@request.session[:user_id] = 2
|
|
426
|
assert_difference('TimeEntry.count', 0) do
|
|
427
|
assert_difference('TimeEntry.count', 0) do
|
|
427
|
post :edit,
|
|
428
|
post :edit,
|
|
428
|
:id => 1,
|
|
429
|
:id => 1,
|
|
429
|
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
|
430
|
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
|
430
|
:notes => 'Assigned to dlopper',
|
|
431
|
:notes => 'Assigned to dlopper',
|
|
431
|
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
|
432
|
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
|
432
|
end
|
|
433
|
end
|
|
433
|
assert_redirected_to 'issues/show/1'
|
|
434
|
assert_redirected_to 'issues/show/1'
|
|
434
|
issue.reload
|
|
435
|
issue.reload
|
|
435
|
assert_equal 2, issue.status_id
|
|
436
|
assert_equal 2, issue.status_id
|
|
436
|
j = issue.journals.find(:first, :order => 'id DESC')
|
|
437
|
j = issue.journals.find(:first, :order => 'id DESC')
|
|
437
|
assert_equal 'Assigned to dlopper', j.notes
|
|
438
|
assert_equal 'Assigned to dlopper', j.notes
|
|
438
|
assert_equal 2, j.details.size
|
|
439
|
assert_equal 2, j.details.size
|
|
439
|
|
|
440
|
|
|
440
|
mail = ActionMailer::Base.deliveries.last
|
|
441
|
mail = ActionMailer::Base.deliveries.last
|
|
441
|
assert mail.body.include?("Status changed from New to Assigned")
|
|
442
|
assert mail.body.include?("Status changed from New to Assigned")
|
|
442
|
end
|
|
443
|
end
|
|
443
|
|
|
444
|
|
|
444
|
def test_post_edit_with_note_only
|
|
445
|
def test_post_edit_with_note_only
|
|
445
|
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
|
446
|
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
|
446
|
# anonymous user
|
|
447
|
# anonymous user
|
|
447
|
post :edit,
|
|
448
|
post :edit,
|
|
448
|
:id => 1,
|
|
449
|
:id => 1,
|
|
449
|
:notes => notes
|
|
450
|
:notes => notes
|
|
450
|
assert_redirected_to 'issues/show/1'
|
|
451
|
assert_redirected_to 'issues/show/1'
|
|
451
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
452
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
452
|
assert_equal notes, j.notes
|
|
453
|
assert_equal notes, j.notes
|
|
453
|
assert_equal 0, j.details.size
|
|
454
|
assert_equal 0, j.details.size
|
|
454
|
assert_equal User.anonymous, j.user
|
|
455
|
assert_equal User.anonymous, j.user
|
|
455
|
|
|
456
|
|
|
456
|
mail = ActionMailer::Base.deliveries.last
|
|
457
|
mail = ActionMailer::Base.deliveries.last
|
|
457
|
assert mail.body.include?(notes)
|
|
458
|
assert mail.body.include?(notes)
|
|
458
|
end
|
|
459
|
end
|
|
459
|
|
|
460
|
|
|
460
|
def test_post_edit_with_note_and_spent_time
|
|
461
|
def test_post_edit_with_note_and_spent_time
|
|
461
|
@request.session[:user_id] = 2
|
|
462
|
@request.session[:user_id] = 2
|
|
462
|
spent_hours_before = Issue.find(1).spent_hours
|
|
463
|
spent_hours_before = Issue.find(1).spent_hours
|
|
463
|
assert_difference('TimeEntry.count') do
|
|
464
|
assert_difference('TimeEntry.count') do
|
|
464
|
post :edit,
|
|
465
|
post :edit,
|
|
465
|
:id => 1,
|
|
466
|
:id => 1,
|
|
466
|
:notes => '2.5 hours added',
|
|
467
|
:notes => '2.5 hours added',
|
|
467
|
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
|
468
|
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
|
468
|
end
|
|
469
|
end
|
|
469
|
assert_redirected_to 'issues/show/1'
|
|
470
|
assert_redirected_to 'issues/show/1'
|
|
470
|
|
|
471
|
|
|
471
|
issue = Issue.find(1)
|
|
472
|
issue = Issue.find(1)
|
|
472
|
|
|
473
|
|
|
473
|
j = issue.journals.find(:first, :order => 'id DESC')
|
|
474
|
j = issue.journals.find(:first, :order => 'id DESC')
|
|
474
|
assert_equal '2.5 hours added', j.notes
|
|
475
|
assert_equal '2.5 hours added', j.notes
|
|
475
|
assert_equal 0, j.details.size
|
|
476
|
assert_equal 0, j.details.size
|
|
476
|
|
|
477
|
|
|
477
|
t = issue.time_entries.find(:first, :order => 'id DESC')
|
|
478
|
t = issue.time_entries.find(:first, :order => 'id DESC')
|
|
478
|
assert_not_nil t
|
|
479
|
assert_not_nil t
|
|
479
|
assert_equal 2.5, t.hours
|
|
480
|
assert_equal 2.5, t.hours
|
|
480
|
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
|
481
|
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
|
481
|
end
|
|
482
|
end
|
|
482
|
|
|
483
|
|
|
483
|
def test_post_edit_with_attachment_only
|
|
484
|
def test_post_edit_with_attachment_only
|
|
484
|
set_tmp_attachments_directory
|
|
485
|
set_tmp_attachments_directory
|
|
485
|
|
|
486
|
|
|
486
|
# anonymous user
|
|
487
|
# anonymous user
|
|
487
|
post :edit,
|
|
488
|
post :edit,
|
|
488
|
:id => 1,
|
|
489
|
:id => 1,
|
|
489
|
:notes => '',
|
|
490
|
:notes => '',
|
|
490
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
491
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
491
|
assert_redirected_to 'issues/show/1'
|
|
492
|
assert_redirected_to 'issues/show/1'
|
|
492
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
493
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
493
|
assert j.notes.blank?
|
|
494
|
assert j.notes.blank?
|
|
494
|
assert_equal 1, j.details.size
|
|
495
|
assert_equal 1, j.details.size
|
|
495
|
assert_equal 'testfile.txt', j.details.first.value
|
|
496
|
assert_equal 'testfile.txt', j.details.first.value
|
|
496
|
assert_equal User.anonymous, j.user
|
|
497
|
assert_equal User.anonymous, j.user
|
|
497
|
|
|
498
|
|
|
498
|
mail = ActionMailer::Base.deliveries.last
|
|
499
|
mail = ActionMailer::Base.deliveries.last
|
|
499
|
assert mail.body.include?('testfile.txt')
|
|
500
|
assert mail.body.include?('testfile.txt')
|
|
500
|
end
|
|
501
|
end
|
|
501
|
|
|
502
|
|
|
502
|
def test_post_edit_with_no_change
|
|
503
|
def test_post_edit_with_no_change
|
|
503
|
issue = Issue.find(1)
|
|
504
|
issue = Issue.find(1)
|
|
504
|
issue.journals.clear
|
|
505
|
issue.journals.clear
|
|
505
|
ActionMailer::Base.deliveries.clear
|
|
506
|
ActionMailer::Base.deliveries.clear
|
|
506
|
|
|
507
|
|
|
507
|
post :edit,
|
|
508
|
post :edit,
|
|
508
|
:id => 1,
|
|
509
|
:id => 1,
|
|
509
|
:notes => ''
|
|
510
|
:notes => ''
|
|
510
|
assert_redirected_to 'issues/show/1'
|
|
511
|
assert_redirected_to 'issues/show/1'
|
|
511
|
|
|
512
|
|
|
512
|
issue.reload
|
|
513
|
issue.reload
|
|
513
|
assert issue.journals.empty?
|
|
514
|
assert issue.journals.empty?
|
|
514
|
# No email should be sent
|
|
515
|
# No email should be sent
|
|
515
|
assert ActionMailer::Base.deliveries.empty?
|
|
516
|
assert ActionMailer::Base.deliveries.empty?
|
|
516
|
end
|
|
517
|
end
|
|
517
|
|
|
518
|
|
|
518
|
def test_bulk_edit
|
|
519
|
def test_bulk_edit
|
|
519
|
@request.session[:user_id] = 2
|
|
520
|
@request.session[:user_id] = 2
|
|
520
|
# update issues priority
|
|
521
|
# update issues priority
|
|
521
|
post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
|
|
522
|
post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
|
|
522
|
assert_response 302
|
|
523
|
assert_response 302
|
|
523
|
# check that the issues were updated
|
|
524
|
# check that the issues were updated
|
|
524
|
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
|
525
|
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
|
525
|
assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
|
|
526
|
assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
|
|
526
|
end
|
|
527
|
end
|
|
527
|
|
|
528
|
|
|
528
|
def test_bulk_unassign
|
|
529
|
def test_bulk_unassign
|
|
529
|
assert_not_nil Issue.find(2).assigned_to
|
|
530
|
assert_not_nil Issue.find(2).assigned_to
|
|
530
|
@request.session[:user_id] = 2
|
|
531
|
@request.session[:user_id] = 2
|
|
531
|
# unassign issues
|
|
532
|
# unassign issues
|
|
532
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
|
|
533
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
|
|
533
|
assert_response 302
|
|
534
|
assert_response 302
|
|
534
|
# check that the issues were updated
|
|
535
|
# check that the issues were updated
|
|
535
|
assert_nil Issue.find(2).assigned_to
|
|
536
|
assert_nil Issue.find(2).assigned_to
|
|
536
|
end
|
|
537
|
end
|
|
537
|
|
|
538
|
|
|
538
|
def test_move_one_issue_to_another_project
|
|
539
|
def test_move_one_issue_to_another_project
|
|
539
|
@request.session[:user_id] = 1
|
|
540
|
@request.session[:user_id] = 1
|
|
540
|
post :move, :id => 1, :new_project_id => 2
|
|
541
|
post :move, :id => 1, :new_project_id => 2
|
|
541
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
542
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
542
|
assert_equal 2, Issue.find(1).project_id
|
|
543
|
assert_equal 2, Issue.find(1).project_id
|
|
543
|
end
|
|
544
|
end
|
|
544
|
|
|
545
|
|
|
545
|
def test_bulk_move_to_another_project
|
|
546
|
def test_bulk_move_to_another_project
|
|
546
|
@request.session[:user_id] = 1
|
|
547
|
@request.session[:user_id] = 1
|
|
547
|
post :move, :ids => [1, 2], :new_project_id => 2
|
|
548
|
post :move, :ids => [1, 2], :new_project_id => 2
|
|
548
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
549
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
549
|
# Issues moved to project 2
|
|
550
|
# Issues moved to project 2
|
|
550
|
assert_equal 2, Issue.find(1).project_id
|
|
551
|
assert_equal 2, Issue.find(1).project_id
|
|
551
|
assert_equal 2, Issue.find(2).project_id
|
|
552
|
assert_equal 2, Issue.find(2).project_id
|
|
552
|
# No tracker change
|
|
553
|
# No tracker change
|
|
553
|
assert_equal 1, Issue.find(1).tracker_id
|
|
554
|
assert_equal 1, Issue.find(1).tracker_id
|
|
554
|
assert_equal 2, Issue.find(2).tracker_id
|
|
555
|
assert_equal 2, Issue.find(2).tracker_id
|
|
555
|
end
|
|
556
|
end
|
|
556
|
|
|
557
|
|
|
557
|
def test_bulk_move_to_another_tracker
|
|
558
|
def test_bulk_move_to_another_tracker
|
|
558
|
@request.session[:user_id] = 1
|
|
559
|
@request.session[:user_id] = 1
|
|
559
|
post :move, :ids => [1, 2], :new_tracker_id => 2
|
|
560
|
post :move, :ids => [1, 2], :new_tracker_id => 2
|
|
560
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
561
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
561
|
assert_equal 2, Issue.find(1).tracker_id
|
|
562
|
assert_equal 2, Issue.find(1).tracker_id
|
|
562
|
assert_equal 2, Issue.find(2).tracker_id
|
|
563
|
assert_equal 2, Issue.find(2).tracker_id
|
|
563
|
end
|
|
564
|
end
|
|
564
|
|
|
565
|
|
|
565
|
def test_context_menu_one_issue
|
|
566
|
def test_context_menu_one_issue
|
|
566
|
@request.session[:user_id] = 2
|
|
567
|
@request.session[:user_id] = 2
|
|
567
|
get :context_menu, :ids => [1]
|
|
568
|
get :context_menu, :ids => [1]
|
|
568
|
assert_response :success
|
|
569
|
assert_response :success
|
|
569
|
assert_template 'context_menu'
|
|
570
|
assert_template 'context_menu'
|
|
570
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
571
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
571
|
:attributes => { :href => '/issues/edit/1',
|
|
572
|
:attributes => { :href => '/issues/edit/1',
|
|
572
|
:class => 'icon-edit' }
|
|
573
|
:class => 'icon-edit' }
|
|
573
|
assert_tag :tag => 'a', :content => 'Closed',
|
|
574
|
assert_tag :tag => 'a', :content => 'Closed',
|
|
574
|
:attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
|
|
575
|
:attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
|
|
575
|
:class => '' }
|
|
576
|
:class => '' }
|
|
576
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
577
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
577
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&priority_id=8',
|
|
578
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&priority_id=8',
|
|
578
|
:class => '' }
|
|
579
|
:class => '' }
|
|
579
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
|
580
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
|
580
|
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1',
|
|
581
|
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1',
|
|
581
|
:class => '' }
|
|
582
|
:class => '' }
|
|
582
|
assert_tag :tag => 'a', :content => 'Copy',
|
|
583
|
assert_tag :tag => 'a', :content => 'Copy',
|
|
583
|
:attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
|
|
584
|
:attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
|
|
584
|
:class => 'icon-copy' }
|
|
585
|
:class => 'icon-copy' }
|
|
585
|
assert_tag :tag => 'a', :content => 'Move',
|
|
586
|
assert_tag :tag => 'a', :content => 'Move',
|
|
586
|
:attributes => { :href => '/issues/move?ids%5B%5D=1',
|
|
587
|
:attributes => { :href => '/issues/move?ids%5B%5D=1',
|
|
587
|
:class => 'icon-move' }
|
|
588
|
:class => 'icon-move' }
|
|
588
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
589
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
589
|
:attributes => { :href => '/issues/destroy?ids%5B%5D=1',
|
|
590
|
:attributes => { :href => '/issues/destroy?ids%5B%5D=1',
|
|
590
|
:class => 'icon-del' }
|
|
591
|
:class => 'icon-del' }
|
|
591
|
end
|
|
592
|
end
|
|
592
|
|
|
593
|
|
|
593
|
def test_context_menu_one_issue_by_anonymous
|
|
594
|
def test_context_menu_one_issue_by_anonymous
|
|
594
|
get :context_menu, :ids => [1]
|
|
595
|
get :context_menu, :ids => [1]
|
|
595
|
assert_response :success
|
|
596
|
assert_response :success
|
|
596
|
assert_template 'context_menu'
|
|
597
|
assert_template 'context_menu'
|
|
597
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
598
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
598
|
:attributes => { :href => '#',
|
|
599
|
:attributes => { :href => '#',
|
|
599
|
:class => 'icon-del disabled' }
|
|
600
|
:class => 'icon-del disabled' }
|
|
600
|
end
|
|
601
|
end
|
|
601
|
|
|
602
|
|
|
602
|
def test_context_menu_multiple_issues_of_same_project
|
|
603
|
def test_context_menu_multiple_issues_of_same_project
|
|
603
|
@request.session[:user_id] = 2
|
|
604
|
@request.session[:user_id] = 2
|
|
604
|
get :context_menu, :ids => [1, 2]
|
|
605
|
get :context_menu, :ids => [1, 2]
|
|
605
|
assert_response :success
|
|
606
|
assert_response :success
|
|
606
|
assert_template 'context_menu'
|
|
607
|
assert_template 'context_menu'
|
|
607
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
608
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
608
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2',
|
|
609
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2',
|
|
609
|
:class => 'icon-edit' }
|
|
610
|
:class => 'icon-edit' }
|
|
610
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
611
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
611
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&priority_id=8',
|
|
612
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&priority_id=8',
|
|
612
|
:class => '' }
|
|
613
|
:class => '' }
|
|
613
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
|
614
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
|
614
|
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1&ids%5B%5D=2',
|
|
615
|
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1&ids%5B%5D=2',
|
|
615
|
:class => '' }
|
|
616
|
:class => '' }
|
|
616
|
assert_tag :tag => 'a', :content => 'Move',
|
|
617
|
assert_tag :tag => 'a', :content => 'Move',
|
|
617
|
:attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2',
|
|
618
|
:attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2',
|
|
618
|
:class => 'icon-move' }
|
|
619
|
:class => 'icon-move' }
|
|
619
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
620
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
620
|
:attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2',
|
|
621
|
:attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2',
|
|
621
|
:class => 'icon-del' }
|
|
622
|
:class => 'icon-del' }
|
|
622
|
end
|
|
623
|
end
|
|
623
|
|
|
624
|
|
|
624
|
def test_context_menu_multiple_issues_of_different_project
|
|
625
|
def test_context_menu_multiple_issues_of_different_project
|
|
625
|
@request.session[:user_id] = 2
|
|
626
|
@request.session[:user_id] = 2
|
|
626
|
get :context_menu, :ids => [1, 2, 4]
|
|
627
|
get :context_menu, :ids => [1, 2, 4]
|
|
627
|
assert_response :success
|
|
628
|
assert_response :success
|
|
628
|
assert_template 'context_menu'
|
|
629
|
assert_template 'context_menu'
|
|
629
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
630
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
630
|
:attributes => { :href => '#',
|
|
631
|
:attributes => { :href => '#',
|
|
631
|
:class => 'icon-del disabled' }
|
|
632
|
:class => 'icon-del disabled' }
|
|
632
|
end
|
|
633
|
end
|
|
633
|
|
|
634
|
|
|
634
|
def test_destroy_issue_with_no_time_entries
|
|
635
|
def test_destroy_issue_with_no_time_entries
|
|
635
|
assert_nil TimeEntry.find_by_issue_id(2)
|
|
636
|
assert_nil TimeEntry.find_by_issue_id(2)
|
|
636
|
@request.session[:user_id] = 2
|
|
637
|
@request.session[:user_id] = 2
|
|
637
|
post :destroy, :id => 2
|
|
638
|
post :destroy, :id => 2
|
|
638
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
639
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
639
|
assert_nil Issue.find_by_id(2)
|
|
640
|
assert_nil Issue.find_by_id(2)
|
|
640
|
end
|
|
641
|
end
|
|
641
|
|
|
642
|
|
|
642
|
def test_destroy_issues_with_time_entries
|
|
643
|
def test_destroy_issues_with_time_entries
|
|
643
|
@request.session[:user_id] = 2
|
|
644
|
@request.session[:user_id] = 2
|
|
644
|
post :destroy, :ids => [1, 3]
|
|
645
|
post :destroy, :ids => [1, 3]
|
|
645
|
assert_response :success
|
|
646
|
assert_response :success
|
|
646
|
assert_template 'destroy'
|
|
647
|
assert_template 'destroy'
|
|
647
|
assert_not_nil assigns(:hours)
|
|
648
|
assert_not_nil assigns(:hours)
|
|
648
|
assert Issue.find_by_id(1) && Issue.find_by_id(3)
|
|
649
|
assert Issue.find_by_id(1) && Issue.find_by_id(3)
|
|
649
|
end
|
|
650
|
end
|
|
650
|
|
|
651
|
|
|
651
|
def test_destroy_issues_and_destroy_time_entries
|
|
652
|
def test_destroy_issues_and_destroy_time_entries
|
|
652
|
@request.session[:user_id] = 2
|
|
653
|
@request.session[:user_id] = 2
|
|
653
|
post :destroy, :ids => [1, 3], :todo => 'destroy'
|
|
654
|
post :destroy, :ids => [1, 3], :todo => 'destroy'
|
|
654
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
655
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
655
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
656
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
656
|
assert_nil TimeEntry.find_by_id([1, 2])
|
|
657
|
assert_nil TimeEntry.find_by_id([1, 2])
|
|
657
|
end
|
|
658
|
end
|
|
658
|
|
|
659
|
|
|
659
|
def test_destroy_issues_and_assign_time_entries_to_project
|
|
660
|
def test_destroy_issues_and_assign_time_entries_to_project
|
|
660
|
@request.session[:user_id] = 2
|
|
661
|
@request.session[:user_id] = 2
|
|
661
|
post :destroy, :ids => [1, 3], :todo => 'nullify'
|
|
662
|
post :destroy, :ids => [1, 3], :todo => 'nullify'
|
|
662
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
663
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
663
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
664
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
664
|
assert_nil TimeEntry.find(1).issue_id
|
|
665
|
assert_nil TimeEntry.find(1).issue_id
|
|
665
|
assert_nil TimeEntry.find(2).issue_id
|
|
666
|
assert_nil TimeEntry.find(2).issue_id
|
|
666
|
end
|
|
667
|
end
|
|
667
|
|
|
668
|
|
|
668
|
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
|
669
|
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
|
669
|
@request.session[:user_id] = 2
|
|
670
|
@request.session[:user_id] = 2
|
|
670
|
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
|
671
|
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
|
671
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
672
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
672
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
673
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
673
|
assert_equal 2, TimeEntry.find(1).issue_id
|
|
674
|
assert_equal 2, TimeEntry.find(1).issue_id
|
|
674
|
assert_equal 2, TimeEntry.find(2).issue_id
|
|
675
|
assert_equal 2, TimeEntry.find(2).issue_id
|
|
675
|
end
|
|
676
|
end
|
|
676
|
|
|
677
|
|
|
677
|
def test_destroy_attachment
|
|
678
|
def test_destroy_attachment
|
|
678
|
issue = Issue.find(3)
|
|
679
|
issue = Issue.find(3)
|
|
679
|
a = issue.attachments.size
|
|
680
|
a = issue.attachments.size
|
|
680
|
@request.session[:user_id] = 2
|
|
681
|
@request.session[:user_id] = 2
|
|
681
|
post :destroy_attachment, :id => 3, :attachment_id => 1
|
|
682
|
post :destroy_attachment, :id => 3, :attachment_id => 1
|
|
682
|
assert_redirected_to 'issues/show/3'
|
|
683
|
assert_redirected_to 'issues/show/3'
|
|
683
|
assert_nil Attachment.find_by_id(1)
|
|
684
|
assert_nil Attachment.find_by_id(1)
|
|
684
|
issue.reload
|
|
685
|
issue.reload
|
|
685
|
assert_equal((a-1), issue.attachments.size)
|
|
686
|
assert_equal((a-1), issue.attachments.size)
|
|
686
|
j = issue.journals.find(:first, :order => 'created_on DESC')
|
|
687
|
j = issue.journals.find(:first, :order => 'created_on DESC')
|
|
687
|
assert_equal 'attachment', j.details.first.property
|
|
688
|
assert_equal 'attachment', j.details.first.property
|
|
688
|
end
|
|
689
|
end
|
|
689
|
end
|
|
690
|
end
|