|
@@
-1,1076
+1,1076
|
|
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 < ActionController::TestCase
|
|
24
|
class IssuesControllerTest < ActionController::TestCase
|
|
25
|
fixtures :projects,
|
|
25
|
fixtures :projects,
|
|
26
|
:users,
|
|
26
|
:users,
|
|
27
|
:roles,
|
|
27
|
:roles,
|
|
28
|
:members,
|
|
28
|
:members,
|
|
29
|
:member_roles,
|
|
29
|
:member_roles,
|
|
30
|
:issues,
|
|
30
|
:issues,
|
|
31
|
:issue_statuses,
|
|
31
|
:issue_statuses,
|
|
32
|
:versions,
|
|
32
|
:versions,
|
|
33
|
:trackers,
|
|
33
|
:trackers,
|
|
34
|
:projects_trackers,
|
|
34
|
:projects_trackers,
|
|
35
|
:issue_categories,
|
|
35
|
:issue_categories,
|
|
36
|
:enabled_modules,
|
|
36
|
:enabled_modules,
|
|
37
|
:enumerations,
|
|
37
|
:enumerations,
|
|
38
|
:attachments,
|
|
38
|
:attachments,
|
|
39
|
:workflows,
|
|
39
|
:workflows,
|
|
40
|
:custom_fields,
|
|
40
|
:custom_fields,
|
|
41
|
:custom_values,
|
|
41
|
:custom_values,
|
|
42
|
:custom_fields_projects,
|
|
42
|
:custom_fields_projects,
|
|
43
|
:custom_fields_trackers,
|
|
43
|
:custom_fields_trackers,
|
|
44
|
:time_entries,
|
|
44
|
:time_entries,
|
|
45
|
:journals,
|
|
45
|
:journals,
|
|
46
|
:journal_details,
|
|
46
|
:journal_details,
|
|
47
|
:queries
|
|
47
|
:queries
|
|
48
|
|
|
48
|
|
|
49
|
def setup
|
|
49
|
def setup
|
|
50
|
@controller = IssuesController.new
|
|
50
|
@controller = IssuesController.new
|
|
51
|
@request = ActionController::TestRequest.new
|
|
51
|
@request = ActionController::TestRequest.new
|
|
52
|
@response = ActionController::TestResponse.new
|
|
52
|
@response = ActionController::TestResponse.new
|
|
53
|
User.current = nil
|
|
53
|
User.current = nil
|
|
54
|
end
|
|
54
|
end
|
|
55
|
|
|
55
|
|
|
56
|
def test_index
|
|
56
|
def test_index
|
|
57
|
Setting.default_language = 'en'
|
|
57
|
Setting.default_language = 'en'
|
|
58
|
|
|
58
|
|
|
59
|
get :index
|
|
59
|
get :index
|
|
60
|
assert_response :success
|
|
60
|
assert_response :success
|
|
61
|
assert_template 'index.rhtml'
|
|
61
|
assert_template 'index.rhtml'
|
|
62
|
assert_not_nil assigns(:issues)
|
|
62
|
assert_not_nil assigns(:issues)
|
|
63
|
assert_nil assigns(:project)
|
|
63
|
assert_nil assigns(:project)
|
|
64
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
64
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
65
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
65
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
66
|
# private projects hidden
|
|
66
|
# private projects hidden
|
|
67
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
67
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
68
|
assert_no_tag :tag => 'a', :content => /Issue on project 2/
|
|
68
|
assert_no_tag :tag => 'a', :content => /Issue on project 2/
|
|
69
|
# project column
|
|
69
|
# project column
|
|
70
|
assert_tag :tag => 'th', :content => /Project/
|
|
70
|
assert_tag :tag => 'th', :content => /Project/
|
|
71
|
end
|
|
71
|
end
|
|
72
|
|
|
72
|
|
|
73
|
def test_index_should_not_list_issues_when_module_disabled
|
|
73
|
def test_index_should_not_list_issues_when_module_disabled
|
|
74
|
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
|
74
|
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
|
75
|
get :index
|
|
75
|
get :index
|
|
76
|
assert_response :success
|
|
76
|
assert_response :success
|
|
77
|
assert_template 'index.rhtml'
|
|
77
|
assert_template 'index.rhtml'
|
|
78
|
assert_not_nil assigns(:issues)
|
|
78
|
assert_not_nil assigns(:issues)
|
|
79
|
assert_nil assigns(:project)
|
|
79
|
assert_nil assigns(:project)
|
|
80
|
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
|
80
|
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
|
81
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
81
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
82
|
end
|
|
82
|
end
|
|
83
|
|
|
83
|
|
|
84
|
def test_index_should_not_list_issues_when_module_disabled
|
|
84
|
def test_index_should_not_list_issues_when_module_disabled
|
|
85
|
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
|
85
|
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
|
86
|
get :index
|
|
86
|
get :index
|
|
87
|
assert_response :success
|
|
87
|
assert_response :success
|
|
88
|
assert_template 'index.rhtml'
|
|
88
|
assert_template 'index.rhtml'
|
|
89
|
assert_not_nil assigns(:issues)
|
|
89
|
assert_not_nil assigns(:issues)
|
|
90
|
assert_nil assigns(:project)
|
|
90
|
assert_nil assigns(:project)
|
|
91
|
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
|
91
|
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
|
92
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
92
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
93
|
end
|
|
93
|
end
|
|
94
|
|
|
94
|
|
|
95
|
def test_index_with_project
|
|
95
|
def test_index_with_project
|
|
96
|
Setting.display_subprojects_issues = 0
|
|
96
|
Setting.display_subprojects_issues = 0
|
|
97
|
get :index, :project_id => 1
|
|
97
|
get :index, :project_id => 1
|
|
98
|
assert_response :success
|
|
98
|
assert_response :success
|
|
99
|
assert_template 'index.rhtml'
|
|
99
|
assert_template 'index.rhtml'
|
|
100
|
assert_not_nil assigns(:issues)
|
|
100
|
assert_not_nil assigns(:issues)
|
|
101
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
101
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
102
|
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
|
102
|
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
|
103
|
end
|
|
103
|
end
|
|
104
|
|
|
104
|
|
|
105
|
def test_index_with_project_and_subprojects
|
|
105
|
def test_index_with_project_and_subprojects
|
|
106
|
Setting.display_subprojects_issues = 1
|
|
106
|
Setting.display_subprojects_issues = 1
|
|
107
|
get :index, :project_id => 1
|
|
107
|
get :index, :project_id => 1
|
|
108
|
assert_response :success
|
|
108
|
assert_response :success
|
|
109
|
assert_template 'index.rhtml'
|
|
109
|
assert_template 'index.rhtml'
|
|
110
|
assert_not_nil assigns(:issues)
|
|
110
|
assert_not_nil assigns(:issues)
|
|
111
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
111
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
112
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
112
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
113
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
113
|
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
114
|
end
|
|
114
|
end
|
|
115
|
|
|
115
|
|
|
116
|
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
|
116
|
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
|
117
|
@request.session[:user_id] = 2
|
|
117
|
@request.session[:user_id] = 2
|
|
118
|
Setting.display_subprojects_issues = 1
|
|
118
|
Setting.display_subprojects_issues = 1
|
|
119
|
get :index, :project_id => 1
|
|
119
|
get :index, :project_id => 1
|
|
120
|
assert_response :success
|
|
120
|
assert_response :success
|
|
121
|
assert_template 'index.rhtml'
|
|
121
|
assert_template 'index.rhtml'
|
|
122
|
assert_not_nil assigns(:issues)
|
|
122
|
assert_not_nil assigns(:issues)
|
|
123
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
123
|
assert_tag :tag => 'a', :content => /Can't print recipes/
|
|
124
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
124
|
assert_tag :tag => 'a', :content => /Subproject issue/
|
|
125
|
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
125
|
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
|
126
|
end
|
|
126
|
end
|
|
127
|
|
|
127
|
|
|
128
|
def test_index_with_project_and_filter
|
|
128
|
def test_index_with_project_and_filter
|
|
129
|
get :index, :project_id => 1, :set_filter => 1
|
|
129
|
get :index, :project_id => 1, :set_filter => 1
|
|
130
|
assert_response :success
|
|
130
|
assert_response :success
|
|
131
|
assert_template 'index.rhtml'
|
|
131
|
assert_template 'index.rhtml'
|
|
132
|
assert_not_nil assigns(:issues)
|
|
132
|
assert_not_nil assigns(:issues)
|
|
133
|
end
|
|
133
|
end
|
|
134
|
|
|
134
|
|
|
135
|
def test_index_with_query
|
|
135
|
def test_index_with_query
|
|
136
|
get :index, :project_id => 1, :query_id => 5
|
|
136
|
get :index, :project_id => 1, :query_id => 5
|
|
137
|
assert_response :success
|
|
137
|
assert_response :success
|
|
138
|
assert_template 'index.rhtml'
|
|
138
|
assert_template 'index.rhtml'
|
|
139
|
assert_not_nil assigns(:issues)
|
|
139
|
assert_not_nil assigns(:issues)
|
|
140
|
assert_nil assigns(:issue_count_by_group)
|
|
140
|
assert_nil assigns(:issue_count_by_group)
|
|
141
|
end
|
|
141
|
end
|
|
142
|
|
|
142
|
|
|
143
|
def test_index_with_query_grouped_by_tracker
|
|
143
|
def test_index_with_query_grouped_by_tracker
|
|
144
|
get :index, :project_id => 1, :query_id => 6
|
|
144
|
get :index, :project_id => 1, :query_id => 6
|
|
145
|
assert_response :success
|
|
145
|
assert_response :success
|
|
146
|
assert_template 'index.rhtml'
|
|
146
|
assert_template 'index.rhtml'
|
|
147
|
assert_not_nil assigns(:issues)
|
|
147
|
assert_not_nil assigns(:issues)
|
|
148
|
assert_not_nil assigns(:issue_count_by_group)
|
|
148
|
assert_not_nil assigns(:issue_count_by_group)
|
|
149
|
end
|
|
149
|
end
|
|
150
|
|
|
150
|
|
|
151
|
def test_index_with_query_grouped_by_list_custom_field
|
|
151
|
def test_index_with_query_grouped_by_list_custom_field
|
|
152
|
get :index, :project_id => 1, :query_id => 9
|
|
152
|
get :index, :project_id => 1, :query_id => 9
|
|
153
|
assert_response :success
|
|
153
|
assert_response :success
|
|
154
|
assert_template 'index.rhtml'
|
|
154
|
assert_template 'index.rhtml'
|
|
155
|
assert_not_nil assigns(:issues)
|
|
155
|
assert_not_nil assigns(:issues)
|
|
156
|
assert_not_nil assigns(:issue_count_by_group)
|
|
156
|
assert_not_nil assigns(:issue_count_by_group)
|
|
157
|
end
|
|
157
|
end
|
|
158
|
|
|
158
|
|
|
159
|
def test_index_sort_by_field_not_included_in_columns
|
|
159
|
def test_index_sort_by_field_not_included_in_columns
|
|
160
|
Setting.issue_list_default_columns = %w(subject author)
|
|
160
|
Setting.issue_list_default_columns = %w(subject author)
|
|
161
|
get :index, :sort => 'tracker'
|
|
161
|
get :index, :sort => 'tracker'
|
|
162
|
end
|
|
162
|
end
|
|
163
|
|
|
163
|
|
|
164
|
def test_index_csv_with_project
|
|
164
|
def test_index_csv_with_project
|
|
165
|
Setting.default_language = 'en'
|
|
165
|
Setting.default_language = 'en'
|
|
166
|
|
|
166
|
|
|
167
|
get :index, :format => 'csv'
|
|
167
|
get :index, :format => 'csv'
|
|
168
|
assert_response :success
|
|
168
|
assert_response :success
|
|
169
|
assert_not_nil assigns(:issues)
|
|
169
|
assert_not_nil assigns(:issues)
|
|
170
|
assert_equal 'text/csv', @response.content_type
|
|
170
|
assert_equal 'text/csv', @response.content_type
|
|
171
|
assert @response.body.starts_with?("#,")
|
|
171
|
assert @response.body.starts_with?("#,")
|
|
172
|
|
|
172
|
|
|
173
|
get :index, :project_id => 1, :format => 'csv'
|
|
173
|
get :index, :project_id => 1, :format => 'csv'
|
|
174
|
assert_response :success
|
|
174
|
assert_response :success
|
|
175
|
assert_not_nil assigns(:issues)
|
|
175
|
assert_not_nil assigns(:issues)
|
|
176
|
assert_equal 'text/csv', @response.content_type
|
|
176
|
assert_equal 'text/csv', @response.content_type
|
|
177
|
end
|
|
177
|
end
|
|
178
|
|
|
178
|
|
|
179
|
def test_index_pdf
|
|
179
|
def test_index_pdf
|
|
180
|
get :index, :format => 'pdf'
|
|
180
|
get :index, :format => 'pdf'
|
|
181
|
assert_response :success
|
|
181
|
assert_response :success
|
|
182
|
assert_not_nil assigns(:issues)
|
|
182
|
assert_not_nil assigns(:issues)
|
|
183
|
assert_equal 'application/pdf', @response.content_type
|
|
183
|
assert_equal 'application/pdf', @response.content_type
|
|
184
|
|
|
184
|
|
|
185
|
get :index, :project_id => 1, :format => 'pdf'
|
|
185
|
get :index, :project_id => 1, :format => 'pdf'
|
|
186
|
assert_response :success
|
|
186
|
assert_response :success
|
|
187
|
assert_not_nil assigns(:issues)
|
|
187
|
assert_not_nil assigns(:issues)
|
|
188
|
assert_equal 'application/pdf', @response.content_type
|
|
188
|
assert_equal 'application/pdf', @response.content_type
|
|
189
|
|
|
189
|
|
|
190
|
get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
|
|
190
|
get :index, :project_id => 1, :query_id => 6, :format => 'pdf'
|
|
191
|
assert_response :success
|
|
191
|
assert_response :success
|
|
192
|
assert_not_nil assigns(:issues)
|
|
192
|
assert_not_nil assigns(:issues)
|
|
193
|
assert_equal 'application/pdf', @response.content_type
|
|
193
|
assert_equal 'application/pdf', @response.content_type
|
|
194
|
end
|
|
194
|
end
|
|
195
|
|
|
195
|
|
|
196
|
def test_index_pdf_with_query_grouped_by_list_custom_field
|
|
196
|
def test_index_pdf_with_query_grouped_by_list_custom_field
|
|
197
|
get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
|
|
197
|
get :index, :project_id => 1, :query_id => 9, :format => 'pdf'
|
|
198
|
assert_response :success
|
|
198
|
assert_response :success
|
|
199
|
assert_not_nil assigns(:issues)
|
|
199
|
assert_not_nil assigns(:issues)
|
|
200
|
assert_not_nil assigns(:issue_count_by_group)
|
|
200
|
assert_not_nil assigns(:issue_count_by_group)
|
|
201
|
assert_equal 'application/pdf', @response.content_type
|
|
201
|
assert_equal 'application/pdf', @response.content_type
|
|
202
|
end
|
|
202
|
end
|
|
203
|
|
|
203
|
|
|
204
|
def test_index_sort
|
|
204
|
def test_index_sort
|
|
205
|
get :index, :sort => 'tracker,id:desc'
|
|
205
|
get :index, :sort => 'tracker,id:desc'
|
|
206
|
assert_response :success
|
|
206
|
assert_response :success
|
|
207
|
|
|
207
|
|
|
208
|
sort_params = @request.session['issues_index_sort']
|
|
208
|
sort_params = @request.session['issues_index_sort']
|
|
209
|
assert sort_params.is_a?(String)
|
|
209
|
assert sort_params.is_a?(String)
|
|
210
|
assert_equal 'tracker,id:desc', sort_params
|
|
210
|
assert_equal 'tracker,id:desc', sort_params
|
|
211
|
|
|
211
|
|
|
212
|
issues = assigns(:issues)
|
|
212
|
issues = assigns(:issues)
|
|
213
|
assert_not_nil issues
|
|
213
|
assert_not_nil issues
|
|
214
|
assert !issues.empty?
|
|
214
|
assert !issues.empty?
|
|
215
|
assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
|
|
215
|
assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
|
|
216
|
end
|
|
216
|
end
|
|
217
|
|
|
217
|
|
|
218
|
def test_index_with_columns
|
|
218
|
def test_index_with_columns
|
|
219
|
columns = ['tracker', 'subject', 'assigned_to']
|
|
219
|
columns = ['tracker', 'subject', 'assigned_to']
|
|
220
|
get :index, :set_filter => 1, :query => { 'column_names' => columns}
|
|
220
|
get :index, :set_filter => 1, :query => { 'column_names' => columns}
|
|
221
|
assert_response :success
|
|
221
|
assert_response :success
|
|
222
|
|
|
222
|
|
|
223
|
# query should use specified columns
|
|
223
|
# query should use specified columns
|
|
224
|
query = assigns(:query)
|
|
224
|
query = assigns(:query)
|
|
225
|
assert_kind_of Query, query
|
|
225
|
assert_kind_of Query, query
|
|
226
|
assert_equal columns, query.column_names.map(&:to_s)
|
|
226
|
assert_equal columns, query.column_names.map(&:to_s)
|
|
227
|
|
|
227
|
|
|
228
|
# columns should be stored in session
|
|
228
|
# columns should be stored in session
|
|
229
|
assert_kind_of Hash, session[:query]
|
|
229
|
assert_kind_of Hash, session[:query]
|
|
230
|
assert_kind_of Array, session[:query][:column_names]
|
|
230
|
assert_kind_of Array, session[:query][:column_names]
|
|
231
|
assert_equal columns, session[:query][:column_names].map(&:to_s)
|
|
231
|
assert_equal columns, session[:query][:column_names].map(&:to_s)
|
|
232
|
end
|
|
232
|
end
|
|
233
|
|
|
233
|
|
|
234
|
def test_changes
|
|
234
|
def test_changes
|
|
235
|
get :changes, :project_id => 1
|
|
235
|
get :changes, :project_id => 1
|
|
236
|
assert_response :success
|
|
236
|
assert_response :success
|
|
237
|
assert_not_nil assigns(:journals)
|
|
237
|
assert_not_nil assigns(:journals)
|
|
238
|
assert_equal 'application/atom+xml', @response.content_type
|
|
238
|
assert_equal 'application/atom+xml', @response.content_type
|
|
239
|
end
|
|
239
|
end
|
|
240
|
|
|
240
|
|
|
241
|
def test_show_by_anonymous
|
|
241
|
def test_show_by_anonymous
|
|
242
|
get :show, :id => 1
|
|
242
|
get :show, :id => 1
|
|
243
|
assert_response :success
|
|
243
|
assert_response :success
|
|
244
|
assert_template 'show.rhtml'
|
|
244
|
assert_template 'show.rhtml'
|
|
245
|
assert_not_nil assigns(:issue)
|
|
245
|
assert_not_nil assigns(:issue)
|
|
246
|
assert_equal Issue.find(1), assigns(:issue)
|
|
246
|
assert_equal Issue.find(1), assigns(:issue)
|
|
247
|
|
|
247
|
|
|
248
|
# anonymous role is allowed to add a note
|
|
248
|
# anonymous role is allowed to add a note
|
|
249
|
assert_tag :tag => 'form',
|
|
249
|
assert_tag :tag => 'form',
|
|
250
|
:descendant => { :tag => 'fieldset',
|
|
250
|
:descendant => { :tag => 'fieldset',
|
|
251
|
:child => { :tag => 'legend',
|
|
251
|
:child => { :tag => 'legend',
|
|
252
|
:content => /Notes/ } }
|
|
252
|
:content => /Notes/ } }
|
|
253
|
end
|
|
253
|
end
|
|
254
|
|
|
254
|
|
|
255
|
def test_show_by_manager
|
|
255
|
def test_show_by_manager
|
|
256
|
@request.session[:user_id] = 2
|
|
256
|
@request.session[:user_id] = 2
|
|
257
|
get :show, :id => 1
|
|
257
|
get :show, :id => 1
|
|
258
|
assert_response :success
|
|
258
|
assert_response :success
|
|
259
|
|
|
259
|
|
|
260
|
assert_tag :tag => 'form',
|
|
260
|
assert_tag :tag => 'form',
|
|
261
|
:descendant => { :tag => 'fieldset',
|
|
261
|
:descendant => { :tag => 'fieldset',
|
|
262
|
:child => { :tag => 'legend',
|
|
262
|
:child => { :tag => 'legend',
|
|
263
|
:content => /Change properties/ } },
|
|
263
|
:content => /Change properties/ } },
|
|
264
|
:descendant => { :tag => 'fieldset',
|
|
264
|
:descendant => { :tag => 'fieldset',
|
|
265
|
:child => { :tag => 'legend',
|
|
265
|
:child => { :tag => 'legend',
|
|
266
|
:content => /Log time/ } },
|
|
266
|
:content => /Log time/ } },
|
|
267
|
:descendant => { :tag => 'fieldset',
|
|
267
|
:descendant => { :tag => 'fieldset',
|
|
268
|
:child => { :tag => 'legend',
|
|
268
|
:child => { :tag => 'legend',
|
|
269
|
:content => /Notes/ } }
|
|
269
|
:content => /Notes/ } }
|
|
270
|
end
|
|
270
|
end
|
|
271
|
|
|
271
|
|
|
272
|
def test_show_should_deny_anonymous_access_without_permission
|
|
272
|
def test_show_should_deny_anonymous_access_without_permission
|
|
273
|
Role.anonymous.remove_permission!(:view_issues)
|
|
273
|
Role.anonymous.remove_permission!(:view_issues)
|
|
274
|
get :show, :id => 1
|
|
274
|
get :show, :id => 1
|
|
275
|
assert_response :redirect
|
|
275
|
assert_response :redirect
|
|
276
|
end
|
|
276
|
end
|
|
277
|
|
|
277
|
|
|
278
|
def test_show_should_deny_non_member_access_without_permission
|
|
278
|
def test_show_should_deny_non_member_access_without_permission
|
|
279
|
Role.non_member.remove_permission!(:view_issues)
|
|
279
|
Role.non_member.remove_permission!(:view_issues)
|
|
280
|
@request.session[:user_id] = 9
|
|
280
|
@request.session[:user_id] = 9
|
|
281
|
get :show, :id => 1
|
|
281
|
get :show, :id => 1
|
|
282
|
assert_response 403
|
|
282
|
assert_response 403
|
|
283
|
end
|
|
283
|
end
|
|
284
|
|
|
284
|
|
|
285
|
def test_show_should_deny_member_access_without_permission
|
|
285
|
def test_show_should_deny_member_access_without_permission
|
|
286
|
Role.find(1).remove_permission!(:view_issues)
|
|
286
|
Role.find(1).remove_permission!(:view_issues)
|
|
287
|
@request.session[:user_id] = 2
|
|
287
|
@request.session[:user_id] = 2
|
|
288
|
get :show, :id => 1
|
|
288
|
get :show, :id => 1
|
|
289
|
assert_response 403
|
|
289
|
assert_response 403
|
|
290
|
end
|
|
290
|
end
|
|
291
|
|
|
291
|
|
|
292
|
def test_show_should_not_disclose_relations_to_invisible_issues
|
|
292
|
def test_show_should_not_disclose_relations_to_invisible_issues
|
|
293
|
Setting.cross_project_issue_relations = '1'
|
|
293
|
Setting.cross_project_issue_relations = '1'
|
|
294
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
|
|
294
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
|
|
295
|
# Relation to a private project issue
|
|
295
|
# Relation to a private project issue
|
|
296
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
|
|
296
|
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(4), :relation_type => 'relates')
|
|
297
|
|
|
297
|
|
|
298
|
get :show, :id => 1
|
|
298
|
get :show, :id => 1
|
|
299
|
assert_response :success
|
|
299
|
assert_response :success
|
|
300
|
|
|
300
|
|
|
301
|
assert_tag :div, :attributes => { :id => 'relations' },
|
|
301
|
assert_tag :div, :attributes => { :id => 'relations' },
|
|
302
|
:descendant => { :tag => 'a', :content => /#2$/ }
|
|
302
|
:descendant => { :tag => 'a', :content => /#2$/ }
|
|
303
|
assert_no_tag :div, :attributes => { :id => 'relations' },
|
|
303
|
assert_no_tag :div, :attributes => { :id => 'relations' },
|
|
304
|
:descendant => { :tag => 'a', :content => /#4$/ }
|
|
304
|
:descendant => { :tag => 'a', :content => /#4$/ }
|
|
305
|
end
|
|
305
|
end
|
|
306
|
|
|
306
|
|
|
307
|
def test_show_atom
|
|
307
|
def test_show_atom
|
|
308
|
get :show, :id => 2, :format => 'atom'
|
|
308
|
get :show, :id => 2, :format => 'atom'
|
|
309
|
assert_response :success
|
|
309
|
assert_response :success
|
|
310
|
assert_template 'changes.rxml'
|
|
310
|
assert_template 'changes.rxml'
|
|
311
|
# Inline image
|
|
311
|
# Inline image
|
|
312
|
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
|
|
312
|
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
|
|
313
|
end
|
|
313
|
end
|
|
314
|
|
|
314
|
|
|
315
|
def test_show_export_to_pdf
|
|
315
|
def test_show_export_to_pdf
|
|
316
|
get :show, :id => 3, :format => 'pdf'
|
|
316
|
get :show, :id => 3, :format => 'pdf'
|
|
317
|
assert_response :success
|
|
317
|
assert_response :success
|
|
318
|
assert_equal 'application/pdf', @response.content_type
|
|
318
|
assert_equal 'application/pdf', @response.content_type
|
|
319
|
assert @response.body.starts_with?('%PDF')
|
|
319
|
assert @response.body.starts_with?('%PDF')
|
|
320
|
assert_not_nil assigns(:issue)
|
|
320
|
assert_not_nil assigns(:issue)
|
|
321
|
end
|
|
321
|
end
|
|
322
|
|
|
322
|
|
|
323
|
def test_get_new
|
|
323
|
def test_get_new
|
|
324
|
@request.session[:user_id] = 2
|
|
324
|
@request.session[:user_id] = 2
|
|
325
|
get :new, :project_id => 1, :tracker_id => 1
|
|
325
|
get :new, :project_id => 1, :tracker_id => 1
|
|
326
|
assert_response :success
|
|
326
|
assert_response :success
|
|
327
|
assert_template 'new'
|
|
327
|
assert_template 'new'
|
|
328
|
|
|
328
|
|
|
329
|
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
|
329
|
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
|
330
|
:value => 'Default string' }
|
|
330
|
:value => 'Default string' }
|
|
331
|
end
|
|
331
|
end
|
|
332
|
|
|
332
|
|
|
333
|
def test_get_new_without_tracker_id
|
|
333
|
def test_get_new_without_tracker_id
|
|
334
|
@request.session[:user_id] = 2
|
|
334
|
@request.session[:user_id] = 2
|
|
335
|
get :new, :project_id => 1
|
|
335
|
get :new, :project_id => 1
|
|
336
|
assert_response :success
|
|
336
|
assert_response :success
|
|
337
|
assert_template 'new'
|
|
337
|
assert_template 'new'
|
|
338
|
|
|
338
|
|
|
339
|
issue = assigns(:issue)
|
|
339
|
issue = assigns(:issue)
|
|
340
|
assert_not_nil issue
|
|
340
|
assert_not_nil issue
|
|
341
|
assert_equal Project.find(1).trackers.first, issue.tracker
|
|
341
|
assert_equal Project.find(1).trackers.first, issue.tracker
|
|
342
|
end
|
|
342
|
end
|
|
343
|
|
|
343
|
|
|
344
|
def test_get_new_with_no_default_status_should_display_an_error
|
|
344
|
def test_get_new_with_no_default_status_should_display_an_error
|
|
345
|
@request.session[:user_id] = 2
|
|
345
|
@request.session[:user_id] = 2
|
|
346
|
IssueStatus.delete_all
|
|
346
|
IssueStatus.delete_all
|
|
347
|
|
|
347
|
|
|
348
|
get :new, :project_id => 1
|
|
348
|
get :new, :project_id => 1
|
|
349
|
assert_response 500
|
|
349
|
assert_response 500
|
|
350
|
assert_not_nil flash[:error]
|
|
350
|
assert_not_nil flash[:error]
|
|
351
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
|
351
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
|
352
|
:content => /No default issue/
|
|
352
|
:content => /No default issue/
|
|
353
|
end
|
|
353
|
end
|
|
354
|
|
|
354
|
|
|
355
|
def test_get_new_with_no_tracker_should_display_an_error
|
|
355
|
def test_get_new_with_no_tracker_should_display_an_error
|
|
356
|
@request.session[:user_id] = 2
|
|
356
|
@request.session[:user_id] = 2
|
|
357
|
Tracker.delete_all
|
|
357
|
Tracker.delete_all
|
|
358
|
|
|
358
|
|
|
359
|
get :new, :project_id => 1
|
|
359
|
get :new, :project_id => 1
|
|
360
|
assert_response 500
|
|
360
|
assert_response 500
|
|
361
|
assert_not_nil flash[:error]
|
|
361
|
assert_not_nil flash[:error]
|
|
362
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
|
362
|
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
|
363
|
:content => /No tracker/
|
|
363
|
:content => /No tracker/
|
|
364
|
end
|
|
364
|
end
|
|
365
|
|
|
365
|
|
|
366
|
def test_update_new_form
|
|
366
|
def test_update_new_form
|
|
367
|
@request.session[:user_id] = 2
|
|
367
|
@request.session[:user_id] = 2
|
|
368
|
xhr :post, :update_form, :project_id => 1,
|
|
368
|
xhr :post, :new, :project_id => 1,
|
|
369
|
:issue => {:tracker_id => 2,
|
|
369
|
:issue => {:tracker_id => 2,
|
|
370
|
:subject => 'This is the test_new issue',
|
|
370
|
:subject => 'This is the test_new issue',
|
|
371
|
:description => 'This is the description',
|
|
371
|
:description => 'This is the description',
|
|
372
|
:priority_id => 5}
|
|
372
|
:priority_id => 5}
|
|
373
|
assert_response :success
|
|
373
|
assert_response :success
|
|
374
|
assert_template 'attributes'
|
|
374
|
assert_template 'attributes'
|
|
375
|
|
|
375
|
|
|
376
|
issue = assigns(:issue)
|
|
376
|
issue = assigns(:issue)
|
|
377
|
assert_kind_of Issue, issue
|
|
377
|
assert_kind_of Issue, issue
|
|
378
|
assert_equal 1, issue.project_id
|
|
378
|
assert_equal 1, issue.project_id
|
|
379
|
assert_equal 2, issue.tracker_id
|
|
379
|
assert_equal 2, issue.tracker_id
|
|
380
|
assert_equal 'This is the test_new issue', issue.subject
|
|
380
|
assert_equal 'This is the test_new issue', issue.subject
|
|
381
|
end
|
|
381
|
end
|
|
382
|
|
|
382
|
|
|
383
|
def test_post_create
|
|
383
|
def test_post_create
|
|
384
|
@request.session[:user_id] = 2
|
|
384
|
@request.session[:user_id] = 2
|
|
385
|
assert_difference 'Issue.count' do
|
|
385
|
assert_difference 'Issue.count' do
|
|
386
|
post :create, :project_id => 1,
|
|
386
|
post :create, :project_id => 1,
|
|
387
|
:issue => {:tracker_id => 3,
|
|
387
|
:issue => {:tracker_id => 3,
|
|
388
|
:status_id => 2,
|
|
388
|
:status_id => 2,
|
|
389
|
:subject => 'This is the test_new issue',
|
|
389
|
:subject => 'This is the test_new issue',
|
|
390
|
:description => 'This is the description',
|
|
390
|
:description => 'This is the description',
|
|
391
|
:priority_id => 5,
|
|
391
|
:priority_id => 5,
|
|
392
|
:estimated_hours => '',
|
|
392
|
:estimated_hours => '',
|
|
393
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
393
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
394
|
end
|
|
394
|
end
|
|
395
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
395
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
396
|
|
|
396
|
|
|
397
|
issue = Issue.find_by_subject('This is the test_new issue')
|
|
397
|
issue = Issue.find_by_subject('This is the test_new issue')
|
|
398
|
assert_not_nil issue
|
|
398
|
assert_not_nil issue
|
|
399
|
assert_equal 2, issue.author_id
|
|
399
|
assert_equal 2, issue.author_id
|
|
400
|
assert_equal 3, issue.tracker_id
|
|
400
|
assert_equal 3, issue.tracker_id
|
|
401
|
assert_equal 2, issue.status_id
|
|
401
|
assert_equal 2, issue.status_id
|
|
402
|
assert_nil issue.estimated_hours
|
|
402
|
assert_nil issue.estimated_hours
|
|
403
|
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
|
403
|
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
|
404
|
assert_not_nil v
|
|
404
|
assert_not_nil v
|
|
405
|
assert_equal 'Value for field 2', v.value
|
|
405
|
assert_equal 'Value for field 2', v.value
|
|
406
|
end
|
|
406
|
end
|
|
407
|
|
|
407
|
|
|
408
|
def test_post_create_and_continue
|
|
408
|
def test_post_create_and_continue
|
|
409
|
@request.session[:user_id] = 2
|
|
409
|
@request.session[:user_id] = 2
|
|
410
|
post :create, :project_id => 1,
|
|
410
|
post :create, :project_id => 1,
|
|
411
|
:issue => {:tracker_id => 3,
|
|
411
|
:issue => {:tracker_id => 3,
|
|
412
|
:subject => 'This is first issue',
|
|
412
|
:subject => 'This is first issue',
|
|
413
|
:priority_id => 5},
|
|
413
|
:priority_id => 5},
|
|
414
|
:continue => ''
|
|
414
|
:continue => ''
|
|
415
|
assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
|
|
415
|
assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
|
|
416
|
end
|
|
416
|
end
|
|
417
|
|
|
417
|
|
|
418
|
def test_post_create_without_custom_fields_param
|
|
418
|
def test_post_create_without_custom_fields_param
|
|
419
|
@request.session[:user_id] = 2
|
|
419
|
@request.session[:user_id] = 2
|
|
420
|
assert_difference 'Issue.count' do
|
|
420
|
assert_difference 'Issue.count' do
|
|
421
|
post :create, :project_id => 1,
|
|
421
|
post :create, :project_id => 1,
|
|
422
|
:issue => {:tracker_id => 1,
|
|
422
|
:issue => {:tracker_id => 1,
|
|
423
|
:subject => 'This is the test_new issue',
|
|
423
|
:subject => 'This is the test_new issue',
|
|
424
|
:description => 'This is the description',
|
|
424
|
:description => 'This is the description',
|
|
425
|
:priority_id => 5}
|
|
425
|
:priority_id => 5}
|
|
426
|
end
|
|
426
|
end
|
|
427
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
427
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
428
|
end
|
|
428
|
end
|
|
429
|
|
|
429
|
|
|
430
|
def test_post_create_with_required_custom_field_and_without_custom_fields_param
|
|
430
|
def test_post_create_with_required_custom_field_and_without_custom_fields_param
|
|
431
|
field = IssueCustomField.find_by_name('Database')
|
|
431
|
field = IssueCustomField.find_by_name('Database')
|
|
432
|
field.update_attribute(:is_required, true)
|
|
432
|
field.update_attribute(:is_required, true)
|
|
433
|
|
|
433
|
|
|
434
|
@request.session[:user_id] = 2
|
|
434
|
@request.session[:user_id] = 2
|
|
435
|
post :create, :project_id => 1,
|
|
435
|
post :create, :project_id => 1,
|
|
436
|
:issue => {:tracker_id => 1,
|
|
436
|
:issue => {:tracker_id => 1,
|
|
437
|
:subject => 'This is the test_new issue',
|
|
437
|
:subject => 'This is the test_new issue',
|
|
438
|
:description => 'This is the description',
|
|
438
|
:description => 'This is the description',
|
|
439
|
:priority_id => 5}
|
|
439
|
:priority_id => 5}
|
|
440
|
assert_response :success
|
|
440
|
assert_response :success
|
|
441
|
assert_template 'new'
|
|
441
|
assert_template 'new'
|
|
442
|
issue = assigns(:issue)
|
|
442
|
issue = assigns(:issue)
|
|
443
|
assert_not_nil issue
|
|
443
|
assert_not_nil issue
|
|
444
|
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
|
444
|
assert_equal I18n.translate('activerecord.errors.messages.invalid'), issue.errors.on(:custom_values)
|
|
445
|
end
|
|
445
|
end
|
|
446
|
|
|
446
|
|
|
447
|
def test_post_create_with_watchers
|
|
447
|
def test_post_create_with_watchers
|
|
448
|
@request.session[:user_id] = 2
|
|
448
|
@request.session[:user_id] = 2
|
|
449
|
ActionMailer::Base.deliveries.clear
|
|
449
|
ActionMailer::Base.deliveries.clear
|
|
450
|
|
|
450
|
|
|
451
|
assert_difference 'Watcher.count', 2 do
|
|
451
|
assert_difference 'Watcher.count', 2 do
|
|
452
|
post :create, :project_id => 1,
|
|
452
|
post :create, :project_id => 1,
|
|
453
|
:issue => {:tracker_id => 1,
|
|
453
|
:issue => {:tracker_id => 1,
|
|
454
|
:subject => 'This is a new issue with watchers',
|
|
454
|
:subject => 'This is a new issue with watchers',
|
|
455
|
:description => 'This is the description',
|
|
455
|
:description => 'This is the description',
|
|
456
|
:priority_id => 5,
|
|
456
|
:priority_id => 5,
|
|
457
|
:watcher_user_ids => ['2', '3']}
|
|
457
|
:watcher_user_ids => ['2', '3']}
|
|
458
|
end
|
|
458
|
end
|
|
459
|
issue = Issue.find_by_subject('This is a new issue with watchers')
|
|
459
|
issue = Issue.find_by_subject('This is a new issue with watchers')
|
|
460
|
assert_not_nil issue
|
|
460
|
assert_not_nil issue
|
|
461
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
|
461
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
|
462
|
|
|
462
|
|
|
463
|
# Watchers added
|
|
463
|
# Watchers added
|
|
464
|
assert_equal [2, 3], issue.watcher_user_ids.sort
|
|
464
|
assert_equal [2, 3], issue.watcher_user_ids.sort
|
|
465
|
assert issue.watched_by?(User.find(3))
|
|
465
|
assert issue.watched_by?(User.find(3))
|
|
466
|
# Watchers notified
|
|
466
|
# Watchers notified
|
|
467
|
mail = ActionMailer::Base.deliveries.last
|
|
467
|
mail = ActionMailer::Base.deliveries.last
|
|
468
|
assert_kind_of TMail::Mail, mail
|
|
468
|
assert_kind_of TMail::Mail, mail
|
|
469
|
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
|
|
469
|
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
|
|
470
|
end
|
|
470
|
end
|
|
471
|
|
|
471
|
|
|
472
|
def test_post_create_subissue
|
|
472
|
def test_post_create_subissue
|
|
473
|
@request.session[:user_id] = 2
|
|
473
|
@request.session[:user_id] = 2
|
|
474
|
|
|
474
|
|
|
475
|
assert_difference 'Issue.count' do
|
|
475
|
assert_difference 'Issue.count' do
|
|
476
|
post :create, :project_id => 1,
|
|
476
|
post :create, :project_id => 1,
|
|
477
|
:issue => {:tracker_id => 1,
|
|
477
|
:issue => {:tracker_id => 1,
|
|
478
|
:subject => 'This is a child issue',
|
|
478
|
:subject => 'This is a child issue',
|
|
479
|
:parent_issue_id => 2}
|
|
479
|
:parent_issue_id => 2}
|
|
480
|
end
|
|
480
|
end
|
|
481
|
issue = Issue.find_by_subject('This is a child issue')
|
|
481
|
issue = Issue.find_by_subject('This is a child issue')
|
|
482
|
assert_not_nil issue
|
|
482
|
assert_not_nil issue
|
|
483
|
assert_equal Issue.find(2), issue.parent
|
|
483
|
assert_equal Issue.find(2), issue.parent
|
|
484
|
end
|
|
484
|
end
|
|
485
|
|
|
485
|
|
|
486
|
def test_post_create_should_send_a_notification
|
|
486
|
def test_post_create_should_send_a_notification
|
|
487
|
ActionMailer::Base.deliveries.clear
|
|
487
|
ActionMailer::Base.deliveries.clear
|
|
488
|
@request.session[:user_id] = 2
|
|
488
|
@request.session[:user_id] = 2
|
|
489
|
assert_difference 'Issue.count' do
|
|
489
|
assert_difference 'Issue.count' do
|
|
490
|
post :create, :project_id => 1,
|
|
490
|
post :create, :project_id => 1,
|
|
491
|
:issue => {:tracker_id => 3,
|
|
491
|
:issue => {:tracker_id => 3,
|
|
492
|
:subject => 'This is the test_new issue',
|
|
492
|
:subject => 'This is the test_new issue',
|
|
493
|
:description => 'This is the description',
|
|
493
|
:description => 'This is the description',
|
|
494
|
:priority_id => 5,
|
|
494
|
:priority_id => 5,
|
|
495
|
:estimated_hours => '',
|
|
495
|
:estimated_hours => '',
|
|
496
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
496
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
|
497
|
end
|
|
497
|
end
|
|
498
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
498
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
|
499
|
|
|
499
|
|
|
500
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
500
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
501
|
end
|
|
501
|
end
|
|
502
|
|
|
502
|
|
|
503
|
def test_post_create_should_preserve_fields_values_on_validation_failure
|
|
503
|
def test_post_create_should_preserve_fields_values_on_validation_failure
|
|
504
|
@request.session[:user_id] = 2
|
|
504
|
@request.session[:user_id] = 2
|
|
505
|
post :create, :project_id => 1,
|
|
505
|
post :create, :project_id => 1,
|
|
506
|
:issue => {:tracker_id => 1,
|
|
506
|
:issue => {:tracker_id => 1,
|
|
507
|
# empty subject
|
|
507
|
# empty subject
|
|
508
|
:subject => '',
|
|
508
|
:subject => '',
|
|
509
|
:description => 'This is a description',
|
|
509
|
:description => 'This is a description',
|
|
510
|
:priority_id => 6,
|
|
510
|
:priority_id => 6,
|
|
511
|
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
|
511
|
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
|
512
|
assert_response :success
|
|
512
|
assert_response :success
|
|
513
|
assert_template 'new'
|
|
513
|
assert_template 'new'
|
|
514
|
|
|
514
|
|
|
515
|
assert_tag :textarea, :attributes => { :name => 'issue[description]' },
|
|
515
|
assert_tag :textarea, :attributes => { :name => 'issue[description]' },
|
|
516
|
:content => 'This is a description'
|
|
516
|
:content => 'This is a description'
|
|
517
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
517
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
518
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
518
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
519
|
:value => '6' },
|
|
519
|
:value => '6' },
|
|
520
|
:content => 'High' }
|
|
520
|
:content => 'High' }
|
|
521
|
# Custom fields
|
|
521
|
# Custom fields
|
|
522
|
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
|
522
|
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
|
523
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
523
|
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
|
524
|
:value => 'Oracle' },
|
|
524
|
:value => 'Oracle' },
|
|
525
|
:content => 'Oracle' }
|
|
525
|
:content => 'Oracle' }
|
|
526
|
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
|
526
|
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
|
527
|
:value => 'Value for field 2'}
|
|
527
|
:value => 'Value for field 2'}
|
|
528
|
end
|
|
528
|
end
|
|
529
|
|
|
529
|
|
|
530
|
def test_post_create_should_ignore_non_safe_attributes
|
|
530
|
def test_post_create_should_ignore_non_safe_attributes
|
|
531
|
@request.session[:user_id] = 2
|
|
531
|
@request.session[:user_id] = 2
|
|
532
|
assert_nothing_raised do
|
|
532
|
assert_nothing_raised do
|
|
533
|
post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
|
|
533
|
post :create, :project_id => 1, :issue => { :tracker => "A param can not be a Tracker" }
|
|
534
|
end
|
|
534
|
end
|
|
535
|
end
|
|
535
|
end
|
|
536
|
|
|
536
|
|
|
537
|
context "without workflow privilege" do
|
|
537
|
context "without workflow privilege" do
|
|
538
|
setup do
|
|
538
|
setup do
|
|
539
|
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
|
539
|
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
|
540
|
Role.anonymous.add_permission! :add_issues
|
|
540
|
Role.anonymous.add_permission! :add_issues
|
|
541
|
end
|
|
541
|
end
|
|
542
|
|
|
542
|
|
|
543
|
context "#new" do
|
|
543
|
context "#new" do
|
|
544
|
should "propose default status only" do
|
|
544
|
should "propose default status only" do
|
|
545
|
get :new, :project_id => 1
|
|
545
|
get :new, :project_id => 1
|
|
546
|
assert_response :success
|
|
546
|
assert_response :success
|
|
547
|
assert_template 'new'
|
|
547
|
assert_template 'new'
|
|
548
|
assert_tag :tag => 'select',
|
|
548
|
assert_tag :tag => 'select',
|
|
549
|
:attributes => {:name => 'issue[status_id]'},
|
|
549
|
:attributes => {:name => 'issue[status_id]'},
|
|
550
|
:children => {:count => 1},
|
|
550
|
:children => {:count => 1},
|
|
551
|
:child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
|
|
551
|
:child => {:tag => 'option', :attributes => {:value => IssueStatus.default.id.to_s}}
|
|
552
|
end
|
|
552
|
end
|
|
553
|
|
|
553
|
|
|
554
|
should "accept default status" do
|
|
554
|
should "accept default status" do
|
|
555
|
assert_difference 'Issue.count' do
|
|
555
|
assert_difference 'Issue.count' do
|
|
556
|
post :create, :project_id => 1,
|
|
556
|
post :create, :project_id => 1,
|
|
557
|
:issue => {:tracker_id => 1,
|
|
557
|
:issue => {:tracker_id => 1,
|
|
558
|
:subject => 'This is an issue',
|
|
558
|
:subject => 'This is an issue',
|
|
559
|
:status_id => 1}
|
|
559
|
:status_id => 1}
|
|
560
|
end
|
|
560
|
end
|
|
561
|
issue = Issue.last(:order => 'id')
|
|
561
|
issue = Issue.last(:order => 'id')
|
|
562
|
assert_equal IssueStatus.default, issue.status
|
|
562
|
assert_equal IssueStatus.default, issue.status
|
|
563
|
end
|
|
563
|
end
|
|
564
|
|
|
564
|
|
|
565
|
should "ignore unauthorized status" do
|
|
565
|
should "ignore unauthorized status" do
|
|
566
|
assert_difference 'Issue.count' do
|
|
566
|
assert_difference 'Issue.count' do
|
|
567
|
post :create, :project_id => 1,
|
|
567
|
post :create, :project_id => 1,
|
|
568
|
:issue => {:tracker_id => 1,
|
|
568
|
:issue => {:tracker_id => 1,
|
|
569
|
:subject => 'This is an issue',
|
|
569
|
:subject => 'This is an issue',
|
|
570
|
:status_id => 3}
|
|
570
|
:status_id => 3}
|
|
571
|
end
|
|
571
|
end
|
|
572
|
issue = Issue.last(:order => 'id')
|
|
572
|
issue = Issue.last(:order => 'id')
|
|
573
|
assert_equal IssueStatus.default, issue.status
|
|
573
|
assert_equal IssueStatus.default, issue.status
|
|
574
|
end
|
|
574
|
end
|
|
575
|
end
|
|
575
|
end
|
|
576
|
end
|
|
576
|
end
|
|
577
|
|
|
577
|
|
|
578
|
def test_copy_issue
|
|
578
|
def test_copy_issue
|
|
579
|
@request.session[:user_id] = 2
|
|
579
|
@request.session[:user_id] = 2
|
|
580
|
get :new, :project_id => 1, :copy_from => 1
|
|
580
|
get :new, :project_id => 1, :copy_from => 1
|
|
581
|
assert_template 'new'
|
|
581
|
assert_template 'new'
|
|
582
|
assert_not_nil assigns(:issue)
|
|
582
|
assert_not_nil assigns(:issue)
|
|
583
|
orig = Issue.find(1)
|
|
583
|
orig = Issue.find(1)
|
|
584
|
assert_equal orig.subject, assigns(:issue).subject
|
|
584
|
assert_equal orig.subject, assigns(:issue).subject
|
|
585
|
end
|
|
585
|
end
|
|
586
|
|
|
586
|
|
|
587
|
def test_get_edit
|
|
587
|
def test_get_edit
|
|
588
|
@request.session[:user_id] = 2
|
|
588
|
@request.session[:user_id] = 2
|
|
589
|
get :edit, :id => 1
|
|
589
|
get :edit, :id => 1
|
|
590
|
assert_response :success
|
|
590
|
assert_response :success
|
|
591
|
assert_template 'edit'
|
|
591
|
assert_template 'edit'
|
|
592
|
assert_not_nil assigns(:issue)
|
|
592
|
assert_not_nil assigns(:issue)
|
|
593
|
assert_equal Issue.find(1), assigns(:issue)
|
|
593
|
assert_equal Issue.find(1), assigns(:issue)
|
|
594
|
end
|
|
594
|
end
|
|
595
|
|
|
595
|
|
|
596
|
def test_get_edit_with_params
|
|
596
|
def test_get_edit_with_params
|
|
597
|
@request.session[:user_id] = 2
|
|
597
|
@request.session[:user_id] = 2
|
|
598
|
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
|
598
|
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
|
599
|
assert_response :success
|
|
599
|
assert_response :success
|
|
600
|
assert_template 'edit'
|
|
600
|
assert_template 'edit'
|
|
601
|
|
|
601
|
|
|
602
|
issue = assigns(:issue)
|
|
602
|
issue = assigns(:issue)
|
|
603
|
assert_not_nil issue
|
|
603
|
assert_not_nil issue
|
|
604
|
|
|
604
|
|
|
605
|
assert_equal 5, issue.status_id
|
|
605
|
assert_equal 5, issue.status_id
|
|
606
|
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
|
606
|
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
|
607
|
:child => { :tag => 'option',
|
|
607
|
:child => { :tag => 'option',
|
|
608
|
:content => 'Closed',
|
|
608
|
:content => 'Closed',
|
|
609
|
:attributes => { :selected => 'selected' } }
|
|
609
|
:attributes => { :selected => 'selected' } }
|
|
610
|
|
|
610
|
|
|
611
|
assert_equal 7, issue.priority_id
|
|
611
|
assert_equal 7, issue.priority_id
|
|
612
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
612
|
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
|
613
|
:child => { :tag => 'option',
|
|
613
|
:child => { :tag => 'option',
|
|
614
|
:content => 'Urgent',
|
|
614
|
:content => 'Urgent',
|
|
615
|
:attributes => { :selected => 'selected' } }
|
|
615
|
:attributes => { :selected => 'selected' } }
|
|
616
|
end
|
|
616
|
end
|
|
617
|
|
|
617
|
|
|
618
|
def test_update_edit_form
|
|
618
|
def test_update_edit_form
|
|
619
|
@request.session[:user_id] = 2
|
|
619
|
@request.session[:user_id] = 2
|
|
620
|
xhr :post, :update_form, :project_id => 1,
|
|
620
|
xhr :post, :new, :project_id => 1,
|
|
621
|
:id => 1,
|
|
621
|
:id => 1,
|
|
622
|
:issue => {:tracker_id => 2,
|
|
622
|
:issue => {:tracker_id => 2,
|
|
623
|
:subject => 'This is the test_new issue',
|
|
623
|
:subject => 'This is the test_new issue',
|
|
624
|
:description => 'This is the description',
|
|
624
|
:description => 'This is the description',
|
|
625
|
:priority_id => 5}
|
|
625
|
:priority_id => 5}
|
|
626
|
assert_response :success
|
|
626
|
assert_response :success
|
|
627
|
assert_template 'attributes'
|
|
627
|
assert_template 'attributes'
|
|
628
|
|
|
628
|
|
|
629
|
issue = assigns(:issue)
|
|
629
|
issue = assigns(:issue)
|
|
630
|
assert_kind_of Issue, issue
|
|
630
|
assert_kind_of Issue, issue
|
|
631
|
assert_equal 1, issue.id
|
|
631
|
assert_equal 1, issue.id
|
|
632
|
assert_equal 1, issue.project_id
|
|
632
|
assert_equal 1, issue.project_id
|
|
633
|
assert_equal 2, issue.tracker_id
|
|
633
|
assert_equal 2, issue.tracker_id
|
|
634
|
assert_equal 'This is the test_new issue', issue.subject
|
|
634
|
assert_equal 'This is the test_new issue', issue.subject
|
|
635
|
end
|
|
635
|
end
|
|
636
|
|
|
636
|
|
|
637
|
def test_update_using_invalid_http_verbs
|
|
637
|
def test_update_using_invalid_http_verbs
|
|
638
|
@request.session[:user_id] = 2
|
|
638
|
@request.session[:user_id] = 2
|
|
639
|
subject = 'Updated by an invalid http verb'
|
|
639
|
subject = 'Updated by an invalid http verb'
|
|
640
|
|
|
640
|
|
|
641
|
get :update, :id => 1, :issue => {:subject => subject}
|
|
641
|
get :update, :id => 1, :issue => {:subject => subject}
|
|
642
|
assert_not_equal subject, Issue.find(1).subject
|
|
642
|
assert_not_equal subject, Issue.find(1).subject
|
|
643
|
|
|
643
|
|
|
644
|
post :update, :id => 1, :issue => {:subject => subject}
|
|
644
|
post :update, :id => 1, :issue => {:subject => subject}
|
|
645
|
assert_not_equal subject, Issue.find(1).subject
|
|
645
|
assert_not_equal subject, Issue.find(1).subject
|
|
646
|
|
|
646
|
|
|
647
|
delete :update, :id => 1, :issue => {:subject => subject}
|
|
647
|
delete :update, :id => 1, :issue => {:subject => subject}
|
|
648
|
assert_not_equal subject, Issue.find(1).subject
|
|
648
|
assert_not_equal subject, Issue.find(1).subject
|
|
649
|
end
|
|
649
|
end
|
|
650
|
|
|
650
|
|
|
651
|
def test_put_update_without_custom_fields_param
|
|
651
|
def test_put_update_without_custom_fields_param
|
|
652
|
@request.session[:user_id] = 2
|
|
652
|
@request.session[:user_id] = 2
|
|
653
|
ActionMailer::Base.deliveries.clear
|
|
653
|
ActionMailer::Base.deliveries.clear
|
|
654
|
|
|
654
|
|
|
655
|
issue = Issue.find(1)
|
|
655
|
issue = Issue.find(1)
|
|
656
|
assert_equal '125', issue.custom_value_for(2).value
|
|
656
|
assert_equal '125', issue.custom_value_for(2).value
|
|
657
|
old_subject = issue.subject
|
|
657
|
old_subject = issue.subject
|
|
658
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
658
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
659
|
|
|
659
|
|
|
660
|
assert_difference('Journal.count') do
|
|
660
|
assert_difference('Journal.count') do
|
|
661
|
assert_difference('JournalDetail.count', 2) do
|
|
661
|
assert_difference('JournalDetail.count', 2) do
|
|
662
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
|
662
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
|
663
|
:priority_id => '6',
|
|
663
|
:priority_id => '6',
|
|
664
|
:category_id => '1' # no change
|
|
664
|
:category_id => '1' # no change
|
|
665
|
}
|
|
665
|
}
|
|
666
|
end
|
|
666
|
end
|
|
667
|
end
|
|
667
|
end
|
|
668
|
assert_redirected_to :action => 'show', :id => '1'
|
|
668
|
assert_redirected_to :action => 'show', :id => '1'
|
|
669
|
issue.reload
|
|
669
|
issue.reload
|
|
670
|
assert_equal new_subject, issue.subject
|
|
670
|
assert_equal new_subject, issue.subject
|
|
671
|
# Make sure custom fields were not cleared
|
|
671
|
# Make sure custom fields were not cleared
|
|
672
|
assert_equal '125', issue.custom_value_for(2).value
|
|
672
|
assert_equal '125', issue.custom_value_for(2).value
|
|
673
|
|
|
673
|
|
|
674
|
mail = ActionMailer::Base.deliveries.last
|
|
674
|
mail = ActionMailer::Base.deliveries.last
|
|
675
|
assert_kind_of TMail::Mail, mail
|
|
675
|
assert_kind_of TMail::Mail, mail
|
|
676
|
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
|
676
|
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
|
677
|
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
|
677
|
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
|
678
|
end
|
|
678
|
end
|
|
679
|
|
|
679
|
|
|
680
|
def test_put_update_with_custom_field_change
|
|
680
|
def test_put_update_with_custom_field_change
|
|
681
|
@request.session[:user_id] = 2
|
|
681
|
@request.session[:user_id] = 2
|
|
682
|
issue = Issue.find(1)
|
|
682
|
issue = Issue.find(1)
|
|
683
|
assert_equal '125', issue.custom_value_for(2).value
|
|
683
|
assert_equal '125', issue.custom_value_for(2).value
|
|
684
|
|
|
684
|
|
|
685
|
assert_difference('Journal.count') do
|
|
685
|
assert_difference('Journal.count') do
|
|
686
|
assert_difference('JournalDetail.count', 3) do
|
|
686
|
assert_difference('JournalDetail.count', 3) do
|
|
687
|
put :update, :id => 1, :issue => {:subject => 'Custom field change',
|
|
687
|
put :update, :id => 1, :issue => {:subject => 'Custom field change',
|
|
688
|
:priority_id => '6',
|
|
688
|
:priority_id => '6',
|
|
689
|
:category_id => '1', # no change
|
|
689
|
:category_id => '1', # no change
|
|
690
|
:custom_field_values => { '2' => 'New custom value' }
|
|
690
|
:custom_field_values => { '2' => 'New custom value' }
|
|
691
|
}
|
|
691
|
}
|
|
692
|
end
|
|
692
|
end
|
|
693
|
end
|
|
693
|
end
|
|
694
|
assert_redirected_to :action => 'show', :id => '1'
|
|
694
|
assert_redirected_to :action => 'show', :id => '1'
|
|
695
|
issue.reload
|
|
695
|
issue.reload
|
|
696
|
assert_equal 'New custom value', issue.custom_value_for(2).value
|
|
696
|
assert_equal 'New custom value', issue.custom_value_for(2).value
|
|
697
|
|
|
697
|
|
|
698
|
mail = ActionMailer::Base.deliveries.last
|
|
698
|
mail = ActionMailer::Base.deliveries.last
|
|
699
|
assert_kind_of TMail::Mail, mail
|
|
699
|
assert_kind_of TMail::Mail, mail
|
|
700
|
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
|
700
|
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
|
701
|
end
|
|
701
|
end
|
|
702
|
|
|
702
|
|
|
703
|
def test_put_update_with_status_and_assignee_change
|
|
703
|
def test_put_update_with_status_and_assignee_change
|
|
704
|
issue = Issue.find(1)
|
|
704
|
issue = Issue.find(1)
|
|
705
|
assert_equal 1, issue.status_id
|
|
705
|
assert_equal 1, issue.status_id
|
|
706
|
@request.session[:user_id] = 2
|
|
706
|
@request.session[:user_id] = 2
|
|
707
|
assert_difference('TimeEntry.count', 0) do
|
|
707
|
assert_difference('TimeEntry.count', 0) do
|
|
708
|
put :update,
|
|
708
|
put :update,
|
|
709
|
:id => 1,
|
|
709
|
:id => 1,
|
|
710
|
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
|
710
|
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
|
711
|
:notes => 'Assigned to dlopper',
|
|
711
|
:notes => 'Assigned to dlopper',
|
|
712
|
:time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
|
|
712
|
:time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
|
|
713
|
end
|
|
713
|
end
|
|
714
|
assert_redirected_to :action => 'show', :id => '1'
|
|
714
|
assert_redirected_to :action => 'show', :id => '1'
|
|
715
|
issue.reload
|
|
715
|
issue.reload
|
|
716
|
assert_equal 2, issue.status_id
|
|
716
|
assert_equal 2, issue.status_id
|
|
717
|
j = Journal.find(:first, :order => 'id DESC')
|
|
717
|
j = Journal.find(:first, :order => 'id DESC')
|
|
718
|
assert_equal 'Assigned to dlopper', j.notes
|
|
718
|
assert_equal 'Assigned to dlopper', j.notes
|
|
719
|
assert_equal 2, j.details.size
|
|
719
|
assert_equal 2, j.details.size
|
|
720
|
|
|
720
|
|
|
721
|
mail = ActionMailer::Base.deliveries.last
|
|
721
|
mail = ActionMailer::Base.deliveries.last
|
|
722
|
assert mail.body.include?("Status changed from New to Assigned")
|
|
722
|
assert mail.body.include?("Status changed from New to Assigned")
|
|
723
|
# subject should contain the new status
|
|
723
|
# subject should contain the new status
|
|
724
|
assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
|
|
724
|
assert mail.subject.include?("(#{ IssueStatus.find(2).name })")
|
|
725
|
end
|
|
725
|
end
|
|
726
|
|
|
726
|
|
|
727
|
def test_put_update_with_note_only
|
|
727
|
def test_put_update_with_note_only
|
|
728
|
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
|
728
|
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
|
729
|
# anonymous user
|
|
729
|
# anonymous user
|
|
730
|
put :update,
|
|
730
|
put :update,
|
|
731
|
:id => 1,
|
|
731
|
:id => 1,
|
|
732
|
:notes => notes
|
|
732
|
:notes => notes
|
|
733
|
assert_redirected_to :action => 'show', :id => '1'
|
|
733
|
assert_redirected_to :action => 'show', :id => '1'
|
|
734
|
j = Journal.find(:first, :order => 'id DESC')
|
|
734
|
j = Journal.find(:first, :order => 'id DESC')
|
|
735
|
assert_equal notes, j.notes
|
|
735
|
assert_equal notes, j.notes
|
|
736
|
assert_equal 0, j.details.size
|
|
736
|
assert_equal 0, j.details.size
|
|
737
|
assert_equal User.anonymous, j.user
|
|
737
|
assert_equal User.anonymous, j.user
|
|
738
|
|
|
738
|
|
|
739
|
mail = ActionMailer::Base.deliveries.last
|
|
739
|
mail = ActionMailer::Base.deliveries.last
|
|
740
|
assert mail.body.include?(notes)
|
|
740
|
assert mail.body.include?(notes)
|
|
741
|
end
|
|
741
|
end
|
|
742
|
|
|
742
|
|
|
743
|
def test_put_update_with_note_and_spent_time
|
|
743
|
def test_put_update_with_note_and_spent_time
|
|
744
|
@request.session[:user_id] = 2
|
|
744
|
@request.session[:user_id] = 2
|
|
745
|
spent_hours_before = Issue.find(1).spent_hours
|
|
745
|
spent_hours_before = Issue.find(1).spent_hours
|
|
746
|
assert_difference('TimeEntry.count') do
|
|
746
|
assert_difference('TimeEntry.count') do
|
|
747
|
put :update,
|
|
747
|
put :update,
|
|
748
|
:id => 1,
|
|
748
|
:id => 1,
|
|
749
|
:notes => '2.5 hours added',
|
|
749
|
:notes => '2.5 hours added',
|
|
750
|
:time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
|
|
750
|
:time_entry => { :hours => '2.5', :comments => 'test_put_update_with_note_and_spent_time', :activity_id => TimeEntryActivity.first.id }
|
|
751
|
end
|
|
751
|
end
|
|
752
|
assert_redirected_to :action => 'show', :id => '1'
|
|
752
|
assert_redirected_to :action => 'show', :id => '1'
|
|
753
|
|
|
753
|
|
|
754
|
issue = Issue.find(1)
|
|
754
|
issue = Issue.find(1)
|
|
755
|
|
|
755
|
|
|
756
|
j = Journal.find(:first, :order => 'id DESC')
|
|
756
|
j = Journal.find(:first, :order => 'id DESC')
|
|
757
|
assert_equal '2.5 hours added', j.notes
|
|
757
|
assert_equal '2.5 hours added', j.notes
|
|
758
|
assert_equal 0, j.details.size
|
|
758
|
assert_equal 0, j.details.size
|
|
759
|
|
|
759
|
|
|
760
|
t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
|
|
760
|
t = issue.time_entries.find_by_comments('test_put_update_with_note_and_spent_time')
|
|
761
|
assert_not_nil t
|
|
761
|
assert_not_nil t
|
|
762
|
assert_equal 2.5, t.hours
|
|
762
|
assert_equal 2.5, t.hours
|
|
763
|
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
|
763
|
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
|
764
|
end
|
|
764
|
end
|
|
765
|
|
|
765
|
|
|
766
|
def test_put_update_with_attachment_only
|
|
766
|
def test_put_update_with_attachment_only
|
|
767
|
set_tmp_attachments_directory
|
|
767
|
set_tmp_attachments_directory
|
|
768
|
|
|
768
|
|
|
769
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
|
769
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
|
770
|
# journal to get fetched in the next find.
|
|
770
|
# journal to get fetched in the next find.
|
|
771
|
Journal.delete_all
|
|
771
|
Journal.delete_all
|
|
772
|
|
|
772
|
|
|
773
|
# anonymous user
|
|
773
|
# anonymous user
|
|
774
|
put :update,
|
|
774
|
put :update,
|
|
775
|
:id => 1,
|
|
775
|
:id => 1,
|
|
776
|
:notes => '',
|
|
776
|
:notes => '',
|
|
777
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
777
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
778
|
assert_redirected_to :action => 'show', :id => '1'
|
|
778
|
assert_redirected_to :action => 'show', :id => '1'
|
|
779
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
779
|
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
|
780
|
assert j.notes.blank?
|
|
780
|
assert j.notes.blank?
|
|
781
|
assert_equal 1, j.details.size
|
|
781
|
assert_equal 1, j.details.size
|
|
782
|
assert_equal 'testfile.txt', j.details.first.value
|
|
782
|
assert_equal 'testfile.txt', j.details.first.value
|
|
783
|
assert_equal User.anonymous, j.user
|
|
783
|
assert_equal User.anonymous, j.user
|
|
784
|
|
|
784
|
|
|
785
|
mail = ActionMailer::Base.deliveries.last
|
|
785
|
mail = ActionMailer::Base.deliveries.last
|
|
786
|
assert mail.body.include?('testfile.txt')
|
|
786
|
assert mail.body.include?('testfile.txt')
|
|
787
|
end
|
|
787
|
end
|
|
788
|
|
|
788
|
|
|
789
|
def test_put_update_with_attachment_that_fails_to_save
|
|
789
|
def test_put_update_with_attachment_that_fails_to_save
|
|
790
|
set_tmp_attachments_directory
|
|
790
|
set_tmp_attachments_directory
|
|
791
|
|
|
791
|
|
|
792
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
|
792
|
# Delete all fixtured journals, a race condition can occur causing the wrong
|
|
793
|
# journal to get fetched in the next find.
|
|
793
|
# journal to get fetched in the next find.
|
|
794
|
Journal.delete_all
|
|
794
|
Journal.delete_all
|
|
795
|
|
|
795
|
|
|
796
|
# Mock out the unsaved attachment
|
|
796
|
# Mock out the unsaved attachment
|
|
797
|
Attachment.any_instance.stubs(:create).returns(Attachment.new)
|
|
797
|
Attachment.any_instance.stubs(:create).returns(Attachment.new)
|
|
798
|
|
|
798
|
|
|
799
|
# anonymous user
|
|
799
|
# anonymous user
|
|
800
|
put :update,
|
|
800
|
put :update,
|
|
801
|
:id => 1,
|
|
801
|
:id => 1,
|
|
802
|
:notes => '',
|
|
802
|
:notes => '',
|
|
803
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
803
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
804
|
assert_redirected_to :action => 'show', :id => '1'
|
|
804
|
assert_redirected_to :action => 'show', :id => '1'
|
|
805
|
assert_equal '1 file(s) could not be saved.', flash[:warning]
|
|
805
|
assert_equal '1 file(s) could not be saved.', flash[:warning]
|
|
806
|
|
|
806
|
|
|
807
|
end if Object.const_defined?(:Mocha)
|
|
807
|
end if Object.const_defined?(:Mocha)
|
|
808
|
|
|
808
|
|
|
809
|
def test_put_update_with_no_change
|
|
809
|
def test_put_update_with_no_change
|
|
810
|
issue = Issue.find(1)
|
|
810
|
issue = Issue.find(1)
|
|
811
|
issue.journals.clear
|
|
811
|
issue.journals.clear
|
|
812
|
ActionMailer::Base.deliveries.clear
|
|
812
|
ActionMailer::Base.deliveries.clear
|
|
813
|
|
|
813
|
|
|
814
|
put :update,
|
|
814
|
put :update,
|
|
815
|
:id => 1,
|
|
815
|
:id => 1,
|
|
816
|
:notes => ''
|
|
816
|
:notes => ''
|
|
817
|
assert_redirected_to :action => 'show', :id => '1'
|
|
817
|
assert_redirected_to :action => 'show', :id => '1'
|
|
818
|
|
|
818
|
|
|
819
|
issue.reload
|
|
819
|
issue.reload
|
|
820
|
assert issue.journals.empty?
|
|
820
|
assert issue.journals.empty?
|
|
821
|
# No email should be sent
|
|
821
|
# No email should be sent
|
|
822
|
assert ActionMailer::Base.deliveries.empty?
|
|
822
|
assert ActionMailer::Base.deliveries.empty?
|
|
823
|
end
|
|
823
|
end
|
|
824
|
|
|
824
|
|
|
825
|
def test_put_update_should_send_a_notification
|
|
825
|
def test_put_update_should_send_a_notification
|
|
826
|
@request.session[:user_id] = 2
|
|
826
|
@request.session[:user_id] = 2
|
|
827
|
ActionMailer::Base.deliveries.clear
|
|
827
|
ActionMailer::Base.deliveries.clear
|
|
828
|
issue = Issue.find(1)
|
|
828
|
issue = Issue.find(1)
|
|
829
|
old_subject = issue.subject
|
|
829
|
old_subject = issue.subject
|
|
830
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
830
|
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
|
831
|
|
|
831
|
|
|
832
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
|
832
|
put :update, :id => 1, :issue => {:subject => new_subject,
|
|
833
|
:priority_id => '6',
|
|
833
|
:priority_id => '6',
|
|
834
|
:category_id => '1' # no change
|
|
834
|
:category_id => '1' # no change
|
|
835
|
}
|
|
835
|
}
|
|
836
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
836
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
837
|
end
|
|
837
|
end
|
|
838
|
|
|
838
|
|
|
839
|
def test_put_update_with_invalid_spent_time
|
|
839
|
def test_put_update_with_invalid_spent_time
|
|
840
|
@request.session[:user_id] = 2
|
|
840
|
@request.session[:user_id] = 2
|
|
841
|
notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
|
|
841
|
notes = 'Note added by IssuesControllerTest#test_post_edit_with_invalid_spent_time'
|
|
842
|
|
|
842
|
|
|
843
|
assert_no_difference('Journal.count') do
|
|
843
|
assert_no_difference('Journal.count') do
|
|
844
|
put :update,
|
|
844
|
put :update,
|
|
845
|
:id => 1,
|
|
845
|
:id => 1,
|
|
846
|
:notes => notes,
|
|
846
|
:notes => notes,
|
|
847
|
:time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
|
|
847
|
:time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"}
|
|
848
|
end
|
|
848
|
end
|
|
849
|
assert_response :success
|
|
849
|
assert_response :success
|
|
850
|
assert_template 'edit'
|
|
850
|
assert_template 'edit'
|
|
851
|
|
|
851
|
|
|
852
|
assert_tag :textarea, :attributes => { :name => 'notes' },
|
|
852
|
assert_tag :textarea, :attributes => { :name => 'notes' },
|
|
853
|
:content => notes
|
|
853
|
:content => notes
|
|
854
|
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
|
|
854
|
assert_tag :input, :attributes => { :name => 'time_entry[hours]', :value => "2z" }
|
|
855
|
end
|
|
855
|
end
|
|
856
|
|
|
856
|
|
|
857
|
def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
|
|
857
|
def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
|
|
858
|
issue = Issue.find(2)
|
|
858
|
issue = Issue.find(2)
|
|
859
|
@request.session[:user_id] = 2
|
|
859
|
@request.session[:user_id] = 2
|
|
860
|
|
|
860
|
|
|
861
|
put :update,
|
|
861
|
put :update,
|
|
862
|
:id => issue.id,
|
|
862
|
:id => issue.id,
|
|
863
|
:issue => {
|
|
863
|
:issue => {
|
|
864
|
:fixed_version_id => 4
|
|
864
|
:fixed_version_id => 4
|
|
865
|
}
|
|
865
|
}
|
|
866
|
|
|
866
|
|
|
867
|
assert_response :redirect
|
|
867
|
assert_response :redirect
|
|
868
|
issue.reload
|
|
868
|
issue.reload
|
|
869
|
assert_equal 4, issue.fixed_version_id
|
|
869
|
assert_equal 4, issue.fixed_version_id
|
|
870
|
assert_not_equal issue.project_id, issue.fixed_version.project_id
|
|
870
|
assert_not_equal issue.project_id, issue.fixed_version.project_id
|
|
871
|
end
|
|
871
|
end
|
|
872
|
|
|
872
|
|
|
873
|
def test_put_update_should_redirect_back_using_the_back_url_parameter
|
|
873
|
def test_put_update_should_redirect_back_using_the_back_url_parameter
|
|
874
|
issue = Issue.find(2)
|
|
874
|
issue = Issue.find(2)
|
|
875
|
@request.session[:user_id] = 2
|
|
875
|
@request.session[:user_id] = 2
|
|
876
|
|
|
876
|
|
|
877
|
put :update,
|
|
877
|
put :update,
|
|
878
|
:id => issue.id,
|
|
878
|
:id => issue.id,
|
|
879
|
:issue => {
|
|
879
|
:issue => {
|
|
880
|
:fixed_version_id => 4
|
|
880
|
:fixed_version_id => 4
|
|
881
|
},
|
|
881
|
},
|
|
882
|
:back_url => '/issues'
|
|
882
|
:back_url => '/issues'
|
|
883
|
|
|
883
|
|
|
884
|
assert_response :redirect
|
|
884
|
assert_response :redirect
|
|
885
|
assert_redirected_to '/issues'
|
|
885
|
assert_redirected_to '/issues'
|
|
886
|
end
|
|
886
|
end
|
|
887
|
|
|
887
|
|
|
888
|
def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
|
888
|
def test_put_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
|
889
|
issue = Issue.find(2)
|
|
889
|
issue = Issue.find(2)
|
|
890
|
@request.session[:user_id] = 2
|
|
890
|
@request.session[:user_id] = 2
|
|
891
|
|
|
891
|
|
|
892
|
put :update,
|
|
892
|
put :update,
|
|
893
|
:id => issue.id,
|
|
893
|
:id => issue.id,
|
|
894
|
:issue => {
|
|
894
|
:issue => {
|
|
895
|
:fixed_version_id => 4
|
|
895
|
:fixed_version_id => 4
|
|
896
|
},
|
|
896
|
},
|
|
897
|
:back_url => 'http://google.com'
|
|
897
|
:back_url => 'http://google.com'
|
|
898
|
|
|
898
|
|
|
899
|
assert_response :redirect
|
|
899
|
assert_response :redirect
|
|
900
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
|
900
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
|
901
|
end
|
|
901
|
end
|
|
902
|
|
|
902
|
|
|
903
|
def test_get_bulk_edit
|
|
903
|
def test_get_bulk_edit
|
|
904
|
@request.session[:user_id] = 2
|
|
904
|
@request.session[:user_id] = 2
|
|
905
|
get :bulk_edit, :ids => [1, 2]
|
|
905
|
get :bulk_edit, :ids => [1, 2]
|
|
906
|
assert_response :success
|
|
906
|
assert_response :success
|
|
907
|
assert_template 'bulk_edit'
|
|
907
|
assert_template 'bulk_edit'
|
|
908
|
|
|
908
|
|
|
909
|
# Project specific custom field, date type
|
|
909
|
# Project specific custom field, date type
|
|
910
|
field = CustomField.find(9)
|
|
910
|
field = CustomField.find(9)
|
|
911
|
assert !field.is_for_all?
|
|
911
|
assert !field.is_for_all?
|
|
912
|
assert_equal 'date', field.field_format
|
|
912
|
assert_equal 'date', field.field_format
|
|
913
|
assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
|
|
913
|
assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
|
|
914
|
|
|
914
|
|
|
915
|
# System wide custom field
|
|
915
|
# System wide custom field
|
|
916
|
assert CustomField.find(1).is_for_all?
|
|
916
|
assert CustomField.find(1).is_for_all?
|
|
917
|
assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
|
|
917
|
assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'}
|
|
918
|
end
|
|
918
|
end
|
|
919
|
|
|
919
|
|
|
920
|
def test_bulk_edit
|
|
920
|
def test_bulk_edit
|
|
921
|
@request.session[:user_id] = 2
|
|
921
|
@request.session[:user_id] = 2
|
|
922
|
# update issues priority
|
|
922
|
# update issues priority
|
|
923
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing',
|
|
923
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing',
|
|
924
|
:issue => {:priority_id => 7,
|
|
924
|
:issue => {:priority_id => 7,
|
|
925
|
:assigned_to_id => '',
|
|
925
|
:assigned_to_id => '',
|
|
926
|
:custom_field_values => {'2' => ''}}
|
|
926
|
:custom_field_values => {'2' => ''}}
|
|
927
|
|
|
927
|
|
|
928
|
assert_response 302
|
|
928
|
assert_response 302
|
|
929
|
# check that the issues were updated
|
|
929
|
# check that the issues were updated
|
|
930
|
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
|
930
|
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
|
931
|
|
|
931
|
|
|
932
|
issue = Issue.find(1)
|
|
932
|
issue = Issue.find(1)
|
|
933
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
|
933
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
|
934
|
assert_equal '125', issue.custom_value_for(2).value
|
|
934
|
assert_equal '125', issue.custom_value_for(2).value
|
|
935
|
assert_equal 'Bulk editing', journal.notes
|
|
935
|
assert_equal 'Bulk editing', journal.notes
|
|
936
|
assert_equal 1, journal.details.size
|
|
936
|
assert_equal 1, journal.details.size
|
|
937
|
end
|
|
937
|
end
|
|
938
|
|
|
938
|
|
|
939
|
def test_bullk_edit_should_send_a_notification
|
|
939
|
def test_bullk_edit_should_send_a_notification
|
|
940
|
@request.session[:user_id] = 2
|
|
940
|
@request.session[:user_id] = 2
|
|
941
|
ActionMailer::Base.deliveries.clear
|
|
941
|
ActionMailer::Base.deliveries.clear
|
|
942
|
post(:bulk_edit,
|
|
942
|
post(:bulk_edit,
|
|
943
|
{
|
|
943
|
{
|
|
944
|
:ids => [1, 2],
|
|
944
|
:ids => [1, 2],
|
|
945
|
:notes => 'Bulk editing',
|
|
945
|
:notes => 'Bulk editing',
|
|
946
|
:issue => {
|
|
946
|
:issue => {
|
|
947
|
:priority_id => 7,
|
|
947
|
:priority_id => 7,
|
|
948
|
:assigned_to_id => '',
|
|
948
|
:assigned_to_id => '',
|
|
949
|
:custom_field_values => {'2' => ''}
|
|
949
|
:custom_field_values => {'2' => ''}
|
|
950
|
}
|
|
950
|
}
|
|
951
|
})
|
|
951
|
})
|
|
952
|
|
|
952
|
|
|
953
|
assert_response 302
|
|
953
|
assert_response 302
|
|
954
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
954
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
|
955
|
end
|
|
955
|
end
|
|
956
|
|
|
956
|
|
|
957
|
def test_bulk_edit_status
|
|
957
|
def test_bulk_edit_status
|
|
958
|
@request.session[:user_id] = 2
|
|
958
|
@request.session[:user_id] = 2
|
|
959
|
# update issues priority
|
|
959
|
# update issues priority
|
|
960
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing status',
|
|
960
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing status',
|
|
961
|
:issue => {:priority_id => '',
|
|
961
|
:issue => {:priority_id => '',
|
|
962
|
:assigned_to_id => '',
|
|
962
|
:assigned_to_id => '',
|
|
963
|
:status_id => '5'}
|
|
963
|
:status_id => '5'}
|
|
964
|
|
|
964
|
|
|
965
|
assert_response 302
|
|
965
|
assert_response 302
|
|
966
|
issue = Issue.find(1)
|
|
966
|
issue = Issue.find(1)
|
|
967
|
assert issue.closed?
|
|
967
|
assert issue.closed?
|
|
968
|
end
|
|
968
|
end
|
|
969
|
|
|
969
|
|
|
970
|
def test_bulk_edit_custom_field
|
|
970
|
def test_bulk_edit_custom_field
|
|
971
|
@request.session[:user_id] = 2
|
|
971
|
@request.session[:user_id] = 2
|
|
972
|
# update issues priority
|
|
972
|
# update issues priority
|
|
973
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing custom field',
|
|
973
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk editing custom field',
|
|
974
|
:issue => {:priority_id => '',
|
|
974
|
:issue => {:priority_id => '',
|
|
975
|
:assigned_to_id => '',
|
|
975
|
:assigned_to_id => '',
|
|
976
|
:custom_field_values => {'2' => '777'}}
|
|
976
|
:custom_field_values => {'2' => '777'}}
|
|
977
|
|
|
977
|
|
|
978
|
assert_response 302
|
|
978
|
assert_response 302
|
|
979
|
|
|
979
|
|
|
980
|
issue = Issue.find(1)
|
|
980
|
issue = Issue.find(1)
|
|
981
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
|
981
|
journal = issue.journals.find(:first, :order => 'created_on DESC')
|
|
982
|
assert_equal '777', issue.custom_value_for(2).value
|
|
982
|
assert_equal '777', issue.custom_value_for(2).value
|
|
983
|
assert_equal 1, journal.details.size
|
|
983
|
assert_equal 1, journal.details.size
|
|
984
|
assert_equal '125', journal.details.first.old_value
|
|
984
|
assert_equal '125', journal.details.first.old_value
|
|
985
|
assert_equal '777', journal.details.first.value
|
|
985
|
assert_equal '777', journal.details.first.value
|
|
986
|
end
|
|
986
|
end
|
|
987
|
|
|
987
|
|
|
988
|
def test_bulk_unassign
|
|
988
|
def test_bulk_unassign
|
|
989
|
assert_not_nil Issue.find(2).assigned_to
|
|
989
|
assert_not_nil Issue.find(2).assigned_to
|
|
990
|
@request.session[:user_id] = 2
|
|
990
|
@request.session[:user_id] = 2
|
|
991
|
# unassign issues
|
|
991
|
# unassign issues
|
|
992
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
|
|
992
|
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'}
|
|
993
|
assert_response 302
|
|
993
|
assert_response 302
|
|
994
|
# check that the issues were updated
|
|
994
|
# check that the issues were updated
|
|
995
|
assert_nil Issue.find(2).assigned_to
|
|
995
|
assert_nil Issue.find(2).assigned_to
|
|
996
|
end
|
|
996
|
end
|
|
997
|
|
|
997
|
|
|
998
|
def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
|
|
998
|
def test_post_bulk_edit_should_allow_fixed_version_to_be_set_to_a_subproject
|
|
999
|
@request.session[:user_id] = 2
|
|
999
|
@request.session[:user_id] = 2
|
|
1000
|
|
|
1000
|
|
|
1001
|
post :bulk_edit, :ids => [1,2], :issue => {:fixed_version_id => 4}
|
|
1001
|
post :bulk_edit, :ids => [1,2], :issue => {:fixed_version_id => 4}
|
|
1002
|
|
|
1002
|
|
|
1003
|
assert_response :redirect
|
|
1003
|
assert_response :redirect
|
|
1004
|
issues = Issue.find([1,2])
|
|
1004
|
issues = Issue.find([1,2])
|
|
1005
|
issues.each do |issue|
|
|
1005
|
issues.each do |issue|
|
|
1006
|
assert_equal 4, issue.fixed_version_id
|
|
1006
|
assert_equal 4, issue.fixed_version_id
|
|
1007
|
assert_not_equal issue.project_id, issue.fixed_version.project_id
|
|
1007
|
assert_not_equal issue.project_id, issue.fixed_version.project_id
|
|
1008
|
end
|
|
1008
|
end
|
|
1009
|
end
|
|
1009
|
end
|
|
1010
|
|
|
1010
|
|
|
1011
|
def test_post_bulk_edit_should_redirect_back_using_the_back_url_parameter
|
|
1011
|
def test_post_bulk_edit_should_redirect_back_using_the_back_url_parameter
|
|
1012
|
@request.session[:user_id] = 2
|
|
1012
|
@request.session[:user_id] = 2
|
|
1013
|
post :bulk_edit, :ids => [1,2], :back_url => '/issues'
|
|
1013
|
post :bulk_edit, :ids => [1,2], :back_url => '/issues'
|
|
1014
|
|
|
1014
|
|
|
1015
|
assert_response :redirect
|
|
1015
|
assert_response :redirect
|
|
1016
|
assert_redirected_to '/issues'
|
|
1016
|
assert_redirected_to '/issues'
|
|
1017
|
end
|
|
1017
|
end
|
|
1018
|
|
|
1018
|
|
|
1019
|
def test_post_bulk_edit_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
|
1019
|
def test_post_bulk_edit_should_not_redirect_back_using_the_back_url_parameter_off_the_host
|
|
1020
|
@request.session[:user_id] = 2
|
|
1020
|
@request.session[:user_id] = 2
|
|
1021
|
post :bulk_edit, :ids => [1,2], :back_url => 'http://google.com'
|
|
1021
|
post :bulk_edit, :ids => [1,2], :back_url => 'http://google.com'
|
|
1022
|
|
|
1022
|
|
|
1023
|
assert_response :redirect
|
|
1023
|
assert_response :redirect
|
|
1024
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
|
|
1024
|
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
|
|
1025
|
end
|
|
1025
|
end
|
|
1026
|
|
|
1026
|
|
|
1027
|
def test_destroy_issue_with_no_time_entries
|
|
1027
|
def test_destroy_issue_with_no_time_entries
|
|
1028
|
assert_nil TimeEntry.find_by_issue_id(2)
|
|
1028
|
assert_nil TimeEntry.find_by_issue_id(2)
|
|
1029
|
@request.session[:user_id] = 2
|
|
1029
|
@request.session[:user_id] = 2
|
|
1030
|
post :destroy, :id => 2
|
|
1030
|
post :destroy, :id => 2
|
|
1031
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1031
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1032
|
assert_nil Issue.find_by_id(2)
|
|
1032
|
assert_nil Issue.find_by_id(2)
|
|
1033
|
end
|
|
1033
|
end
|
|
1034
|
|
|
1034
|
|
|
1035
|
def test_destroy_issues_with_time_entries
|
|
1035
|
def test_destroy_issues_with_time_entries
|
|
1036
|
@request.session[:user_id] = 2
|
|
1036
|
@request.session[:user_id] = 2
|
|
1037
|
post :destroy, :ids => [1, 3]
|
|
1037
|
post :destroy, :ids => [1, 3]
|
|
1038
|
assert_response :success
|
|
1038
|
assert_response :success
|
|
1039
|
assert_template 'destroy'
|
|
1039
|
assert_template 'destroy'
|
|
1040
|
assert_not_nil assigns(:hours)
|
|
1040
|
assert_not_nil assigns(:hours)
|
|
1041
|
assert Issue.find_by_id(1) && Issue.find_by_id(3)
|
|
1041
|
assert Issue.find_by_id(1) && Issue.find_by_id(3)
|
|
1042
|
end
|
|
1042
|
end
|
|
1043
|
|
|
1043
|
|
|
1044
|
def test_destroy_issues_and_destroy_time_entries
|
|
1044
|
def test_destroy_issues_and_destroy_time_entries
|
|
1045
|
@request.session[:user_id] = 2
|
|
1045
|
@request.session[:user_id] = 2
|
|
1046
|
post :destroy, :ids => [1, 3], :todo => 'destroy'
|
|
1046
|
post :destroy, :ids => [1, 3], :todo => 'destroy'
|
|
1047
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1047
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1048
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1048
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1049
|
assert_nil TimeEntry.find_by_id([1, 2])
|
|
1049
|
assert_nil TimeEntry.find_by_id([1, 2])
|
|
1050
|
end
|
|
1050
|
end
|
|
1051
|
|
|
1051
|
|
|
1052
|
def test_destroy_issues_and_assign_time_entries_to_project
|
|
1052
|
def test_destroy_issues_and_assign_time_entries_to_project
|
|
1053
|
@request.session[:user_id] = 2
|
|
1053
|
@request.session[:user_id] = 2
|
|
1054
|
post :destroy, :ids => [1, 3], :todo => 'nullify'
|
|
1054
|
post :destroy, :ids => [1, 3], :todo => 'nullify'
|
|
1055
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1055
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1056
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1056
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1057
|
assert_nil TimeEntry.find(1).issue_id
|
|
1057
|
assert_nil TimeEntry.find(1).issue_id
|
|
1058
|
assert_nil TimeEntry.find(2).issue_id
|
|
1058
|
assert_nil TimeEntry.find(2).issue_id
|
|
1059
|
end
|
|
1059
|
end
|
|
1060
|
|
|
1060
|
|
|
1061
|
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
|
1061
|
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
|
1062
|
@request.session[:user_id] = 2
|
|
1062
|
@request.session[:user_id] = 2
|
|
1063
|
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
|
1063
|
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
|
1064
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1064
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
1065
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1065
|
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
|
1066
|
assert_equal 2, TimeEntry.find(1).issue_id
|
|
1066
|
assert_equal 2, TimeEntry.find(1).issue_id
|
|
1067
|
assert_equal 2, TimeEntry.find(2).issue_id
|
|
1067
|
assert_equal 2, TimeEntry.find(2).issue_id
|
|
1068
|
end
|
|
1068
|
end
|
|
1069
|
|
|
1069
|
|
|
1070
|
def test_default_search_scope
|
|
1070
|
def test_default_search_scope
|
|
1071
|
get :index
|
|
1071
|
get :index
|
|
1072
|
assert_tag :div, :attributes => {:id => 'quick-search'},
|
|
1072
|
assert_tag :div, :attributes => {:id => 'quick-search'},
|
|
1073
|
:child => {:tag => 'form',
|
|
1073
|
:child => {:tag => 'form',
|
|
1074
|
:child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
|
|
1074
|
:child => {:tag => 'input', :attributes => {:name => 'issues', :type => 'hidden', :value => '1'}}}
|
|
1075
|
end
|
|
1075
|
end
|
|
1076
|
end
|
|
1076
|
end
|