This diff has been collapsed as it changes many lines, (1144 lines changed)
Show them
Hide them
|
|
@@
-1,567
+1,577
|
|
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 'projects_controller'
|
|
19
|
require 'projects_controller'
|
|
20
|
|
|
20
|
|
|
21
|
# Re-raise errors caught by the controller.
|
|
21
|
# Re-raise errors caught by the controller.
|
|
22
|
class ProjectsController; def rescue_action(e) raise e end; end
|
|
22
|
class ProjectsController; def rescue_action(e) raise e end; end
|
|
23
|
|
|
23
|
|
|
24
|
class ProjectsControllerTest < ActionController::TestCase
|
|
24
|
class ProjectsControllerTest < ActionController::TestCase
|
|
25
|
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
|
|
25
|
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
|
|
26
|
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
|
26
|
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
|
27
|
:attachments
|
|
27
|
:attachments
|
|
28
|
|
|
28
|
|
|
29
|
def setup
|
|
29
|
def setup
|
|
30
|
@controller = ProjectsController.new
|
|
30
|
@controller = ProjectsController.new
|
|
31
|
@request = ActionController::TestRequest.new
|
|
31
|
@request = ActionController::TestRequest.new
|
|
32
|
@response = ActionController::TestResponse.new
|
|
32
|
@response = ActionController::TestResponse.new
|
|
33
|
@request.session[:user_id] = nil
|
|
33
|
@request.session[:user_id] = nil
|
|
34
|
Setting.default_language = 'en'
|
|
34
|
Setting.default_language = 'en'
|
|
35
|
end
|
|
35
|
end
|
|
36
|
|
|
36
|
|
|
37
|
def test_index_routing
|
|
37
|
def test_index_routing
|
|
38
|
assert_routing(
|
|
38
|
assert_routing(
|
|
39
|
{:method => :get, :path => '/projects'},
|
|
39
|
{:method => :get, :path => '/projects'},
|
|
40
|
:controller => 'projects', :action => 'index'
|
|
40
|
:controller => 'projects', :action => 'index'
|
|
41
|
)
|
|
41
|
)
|
|
42
|
end
|
|
42
|
end
|
|
43
|
|
|
43
|
|
|
44
|
def test_index
|
|
44
|
def test_index
|
|
45
|
get :index
|
|
45
|
get :index
|
|
46
|
assert_response :success
|
|
46
|
assert_response :success
|
|
47
|
assert_template 'index'
|
|
47
|
assert_template 'index'
|
|
48
|
assert_not_nil assigns(:projects)
|
|
48
|
assert_not_nil assigns(:projects)
|
|
49
|
|
|
49
|
|
|
50
|
assert_tag :ul, :child => {:tag => 'li',
|
|
50
|
assert_tag :ul, :child => {:tag => 'li',
|
|
51
|
:descendant => {:tag => 'a', :content => 'eCookbook'},
|
|
51
|
:descendant => {:tag => 'a', :content => 'eCookbook'},
|
|
52
|
:child => { :tag => 'ul',
|
|
52
|
:child => { :tag => 'ul',
|
|
53
|
:descendant => { :tag => 'a',
|
|
53
|
:descendant => { :tag => 'a',
|
|
54
|
:content => 'Child of private child'
|
|
54
|
:content => 'Child of private child'
|
|
55
|
}
|
|
55
|
}
|
|
56
|
}
|
|
56
|
}
|
|
57
|
}
|
|
57
|
}
|
|
58
|
|
|
58
|
|
|
59
|
assert_no_tag :a, :content => /Private child of eCookbook/
|
|
59
|
assert_no_tag :a, :content => /Private child of eCookbook/
|
|
60
|
end
|
|
60
|
end
|
|
61
|
|
|
61
|
|
|
62
|
def test_index_atom_routing
|
|
62
|
def test_index_atom_routing
|
|
63
|
assert_routing(
|
|
63
|
assert_routing(
|
|
64
|
{:method => :get, :path => '/projects.atom'},
|
|
64
|
{:method => :get, :path => '/projects.atom'},
|
|
65
|
:controller => 'projects', :action => 'index', :format => 'atom'
|
|
65
|
:controller => 'projects', :action => 'index', :format => 'atom'
|
|
66
|
)
|
|
66
|
)
|
|
67
|
end
|
|
67
|
end
|
|
68
|
|
|
68
|
|
|
69
|
def test_index_atom
|
|
69
|
def test_index_atom
|
|
70
|
get :index, :format => 'atom'
|
|
70
|
get :index, :format => 'atom'
|
|
71
|
assert_response :success
|
|
71
|
assert_response :success
|
|
72
|
assert_template 'common/feed.atom.rxml'
|
|
72
|
assert_template 'common/feed.atom.rxml'
|
|
73
|
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
|
73
|
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
|
74
|
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
|
|
74
|
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
|
|
75
|
end
|
|
75
|
end
|
|
76
|
|
|
76
|
|
|
77
|
def test_add_routing
|
|
77
|
def test_add_routing
|
|
78
|
assert_routing(
|
|
78
|
assert_routing(
|
|
79
|
{:method => :get, :path => '/projects/new'},
|
|
79
|
{:method => :get, :path => '/projects/new'},
|
|
80
|
:controller => 'projects', :action => 'add'
|
|
80
|
:controller => 'projects', :action => 'add'
|
|
81
|
)
|
|
81
|
)
|
|
82
|
assert_recognizes(
|
|
82
|
assert_recognizes(
|
|
83
|
{:controller => 'projects', :action => 'add'},
|
|
83
|
{:controller => 'projects', :action => 'add'},
|
|
84
|
{:method => :post, :path => '/projects/new'}
|
|
84
|
{:method => :post, :path => '/projects/new'}
|
|
85
|
)
|
|
85
|
)
|
|
86
|
assert_recognizes(
|
|
86
|
assert_recognizes(
|
|
87
|
{:controller => 'projects', :action => 'add'},
|
|
87
|
{:controller => 'projects', :action => 'add'},
|
|
88
|
{:method => :post, :path => '/projects'}
|
|
88
|
{:method => :post, :path => '/projects'}
|
|
89
|
)
|
|
89
|
)
|
|
90
|
end
|
|
90
|
end
|
|
91
|
|
|
91
|
|
|
92
|
def test_get_add
|
|
92
|
def test_get_add
|
|
93
|
@request.session[:user_id] = 1
|
|
93
|
@request.session[:user_id] = 1
|
|
94
|
get :add
|
|
94
|
get :add
|
|
95
|
assert_response :success
|
|
95
|
assert_response :success
|
|
96
|
assert_template 'add'
|
|
96
|
assert_template 'add'
|
|
97
|
end
|
|
97
|
end
|
|
98
|
|
|
98
|
|
|
99
|
def test_get_add_by_non_admin
|
|
99
|
def test_get_add_by_non_admin
|
|
100
|
@request.session[:user_id] = 2
|
|
100
|
@request.session[:user_id] = 2
|
|
101
|
get :add
|
|
101
|
get :add
|
|
102
|
assert_response :success
|
|
102
|
assert_response :success
|
|
103
|
assert_template 'add'
|
|
103
|
assert_template 'add'
|
|
104
|
end
|
|
104
|
end
|
|
105
|
|
|
105
|
|
|
106
|
def test_post_add
|
|
106
|
def test_post_add
|
|
107
|
@request.session[:user_id] = 1
|
|
107
|
@request.session[:user_id] = 1
|
|
108
|
post :add, :project => { :name => "blog",
|
|
108
|
post :add, :project => { :name => "blog",
|
|
109
|
:description => "weblog",
|
|
109
|
:description => "weblog",
|
|
110
|
:identifier => "blog",
|
|
110
|
:identifier => "blog",
|
|
111
|
:is_public => 1,
|
|
111
|
:is_public => 1,
|
|
112
|
:custom_field_values => { '3' => 'Beta' }
|
|
112
|
:custom_field_values => { '3' => 'Beta' }
|
|
113
|
}
|
|
113
|
}
|
|
114
|
assert_redirected_to '/projects/blog/settings'
|
|
114
|
assert_redirected_to '/projects/blog/settings'
|
|
115
|
|
|
115
|
|
|
116
|
project = Project.find_by_name('blog')
|
|
116
|
project = Project.find_by_name('blog')
|
|
117
|
assert_kind_of Project, project
|
|
117
|
assert_kind_of Project, project
|
|
118
|
assert_equal 'weblog', project.description
|
|
118
|
assert_equal 'weblog', project.description
|
|
119
|
assert_equal true, project.is_public?
|
|
119
|
assert_equal true, project.is_public?
|
|
120
|
end
|
|
120
|
end
|
|
121
|
|
|
121
|
|
|
122
|
def test_post_add_by_non_admin
|
|
122
|
def test_post_add_by_non_admin
|
|
123
|
@request.session[:user_id] = 2
|
|
123
|
@request.session[:user_id] = 2
|
|
124
|
post :add, :project => { :name => "blog",
|
|
124
|
post :add, :project => { :name => "blog",
|
|
125
|
:description => "weblog",
|
|
125
|
:description => "weblog",
|
|
126
|
:identifier => "blog",
|
|
126
|
:identifier => "blog",
|
|
127
|
:is_public => 1,
|
|
127
|
:is_public => 1,
|
|
128
|
:custom_field_values => { '3' => 'Beta' }
|
|
128
|
:custom_field_values => { '3' => 'Beta' }
|
|
129
|
}
|
|
129
|
}
|
|
130
|
assert_redirected_to '/projects/blog/settings'
|
|
130
|
assert_redirected_to '/projects/blog/settings'
|
|
131
|
|
|
131
|
|
|
132
|
project = Project.find_by_name('blog')
|
|
132
|
project = Project.find_by_name('blog')
|
|
133
|
assert_kind_of Project, project
|
|
133
|
assert_kind_of Project, project
|
|
134
|
assert_equal 'weblog', project.description
|
|
134
|
assert_equal 'weblog', project.description
|
|
135
|
assert_equal true, project.is_public?
|
|
135
|
assert_equal true, project.is_public?
|
|
136
|
|
|
136
|
|
|
137
|
# User should be added as a project member
|
|
137
|
# User should be added as a project member
|
|
138
|
assert User.find(2).member_of?(project)
|
|
138
|
assert User.find(2).member_of?(project)
|
|
139
|
assert_equal 1, project.members.size
|
|
139
|
assert_equal 1, project.members.size
|
|
140
|
end
|
|
140
|
end
|
|
141
|
|
|
141
|
|
|
142
|
def test_show_routing
|
|
142
|
def test_show_routing
|
|
143
|
assert_routing(
|
|
143
|
assert_routing(
|
|
144
|
{:method => :get, :path => '/projects/test'},
|
|
144
|
{:method => :get, :path => '/projects/test'},
|
|
145
|
:controller => 'projects', :action => 'show', :id => 'test'
|
|
145
|
:controller => 'projects', :action => 'show', :id => 'test'
|
|
146
|
)
|
|
146
|
)
|
|
147
|
end
|
|
147
|
end
|
|
148
|
|
|
148
|
|
|
149
|
def test_show_by_id
|
|
149
|
def test_show_by_id
|
|
150
|
get :show, :id => 1
|
|
150
|
get :show, :id => 1
|
|
151
|
assert_response :success
|
|
151
|
assert_response :success
|
|
152
|
assert_template 'show'
|
|
152
|
assert_template 'show'
|
|
153
|
assert_not_nil assigns(:project)
|
|
153
|
assert_not_nil assigns(:project)
|
|
154
|
end
|
|
154
|
end
|
|
155
|
|
|
155
|
|
|
156
|
def test_show_by_identifier
|
|
156
|
def test_show_by_identifier
|
|
157
|
get :show, :id => 'ecookbook'
|
|
157
|
get :show, :id => 'ecookbook'
|
|
158
|
assert_response :success
|
|
158
|
assert_response :success
|
|
159
|
assert_template 'show'
|
|
159
|
assert_template 'show'
|
|
160
|
assert_not_nil assigns(:project)
|
|
160
|
assert_not_nil assigns(:project)
|
|
161
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
|
161
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
|
162
|
end
|
|
162
|
end
|
|
163
|
|
|
163
|
|
|
164
|
def test_private_subprojects_hidden
|
|
164
|
def test_show_should_not_fail_when_custom_values_are_nil
|
|
165
|
get :show, :id => 'ecookbook'
|
|
165
|
project = Project.find_by_identifier('ecookbook')
|
|
166
|
assert_response :success
|
|
166
|
project.custom_values.first.update_attribute(:value, nil)
|
|
167
|
assert_template 'show'
|
|
167
|
get :show, :id => 'ecookbook'
|
|
168
|
assert_no_tag :tag => 'a', :content => /Private child/
|
|
168
|
assert_response :success
|
|
169
|
end
|
|
169
|
assert_template 'show'
|
|
170
|
|
|
170
|
assert_not_nil assigns(:project)
|
|
171
|
def test_private_subprojects_visible
|
|
171
|
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
|
172
|
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
|
172
|
end
|
|
173
|
get :show, :id => 'ecookbook'
|
|
173
|
|
|
174
|
assert_response :success
|
|
174
|
def test_private_subprojects_hidden
|
|
175
|
assert_template 'show'
|
|
175
|
get :show, :id => 'ecookbook'
|
|
176
|
assert_tag :tag => 'a', :content => /Private child/
|
|
176
|
assert_response :success
|
|
177
|
end
|
|
177
|
assert_template 'show'
|
|
178
|
|
|
178
|
assert_no_tag :tag => 'a', :content => /Private child/
|
|
179
|
def test_settings_routing
|
|
179
|
end
|
|
180
|
assert_routing(
|
|
180
|
|
|
181
|
{:method => :get, :path => '/projects/4223/settings'},
|
|
181
|
def test_private_subprojects_visible
|
|
182
|
:controller => 'projects', :action => 'settings', :id => '4223'
|
|
182
|
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
|
183
|
)
|
|
183
|
get :show, :id => 'ecookbook'
|
|
184
|
assert_routing(
|
|
184
|
assert_response :success
|
|
185
|
{:method => :get, :path => '/projects/4223/settings/members'},
|
|
185
|
assert_template 'show'
|
|
186
|
:controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
|
|
186
|
assert_tag :tag => 'a', :content => /Private child/
|
|
187
|
)
|
|
187
|
end
|
|
188
|
end
|
|
188
|
|
|
189
|
|
|
189
|
def test_settings_routing
|
|
190
|
def test_settings
|
|
190
|
assert_routing(
|
|
191
|
@request.session[:user_id] = 2 # manager
|
|
191
|
{:method => :get, :path => '/projects/4223/settings'},
|
|
192
|
get :settings, :id => 1
|
|
192
|
:controller => 'projects', :action => 'settings', :id => '4223'
|
|
193
|
assert_response :success
|
|
193
|
)
|
|
194
|
assert_template 'settings'
|
|
194
|
assert_routing(
|
|
195
|
end
|
|
195
|
{:method => :get, :path => '/projects/4223/settings/members'},
|
|
196
|
|
|
196
|
:controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
|
|
197
|
def test_edit
|
|
197
|
)
|
|
198
|
@request.session[:user_id] = 2 # manager
|
|
198
|
end
|
|
199
|
post :edit, :id => 1, :project => {:name => 'Test changed name',
|
|
199
|
|
|
200
|
:issue_custom_field_ids => ['']}
|
|
200
|
def test_settings
|
|
201
|
assert_redirected_to 'projects/ecookbook/settings'
|
|
201
|
@request.session[:user_id] = 2 # manager
|
|
202
|
project = Project.find(1)
|
|
202
|
get :settings, :id => 1
|
|
203
|
assert_equal 'Test changed name', project.name
|
|
203
|
assert_response :success
|
|
204
|
end
|
|
204
|
assert_template 'settings'
|
|
205
|
|
|
205
|
end
|
|
206
|
def test_add_version_routing
|
|
206
|
|
|
207
|
assert_routing(
|
|
207
|
def test_edit
|
|
208
|
{:method => :get, :path => 'projects/64/versions/new'},
|
|
208
|
@request.session[:user_id] = 2 # manager
|
|
209
|
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
209
|
post :edit, :id => 1, :project => {:name => 'Test changed name',
|
|
210
|
)
|
|
210
|
:issue_custom_field_ids => ['']}
|
|
211
|
assert_routing(
|
|
211
|
assert_redirected_to 'projects/ecookbook/settings'
|
|
212
|
#TODO: use PUT
|
|
212
|
project = Project.find(1)
|
|
213
|
{:method => :post, :path => 'projects/64/versions/new'},
|
|
213
|
assert_equal 'Test changed name', project.name
|
|
214
|
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
214
|
end
|
|
215
|
)
|
|
215
|
|
|
216
|
end
|
|
216
|
def test_add_version_routing
|
|
217
|
|
|
217
|
assert_routing(
|
|
218
|
def test_add_issue_category_routing
|
|
218
|
{:method => :get, :path => 'projects/64/versions/new'},
|
|
219
|
assert_routing(
|
|
219
|
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
220
|
{:method => :get, :path => 'projects/test/categories/new'},
|
|
220
|
)
|
|
221
|
:controller => 'projects', :action => 'add_issue_category', :id => 'test'
|
|
221
|
assert_routing(
|
|
222
|
)
|
|
222
|
#TODO: use PUT
|
|
223
|
assert_routing(
|
|
223
|
{:method => :post, :path => 'projects/64/versions/new'},
|
|
224
|
#TODO: use PUT and update form
|
|
224
|
:controller => 'projects', :action => 'add_version', :id => '64'
|
|
225
|
{:method => :post, :path => 'projects/64/categories/new'},
|
|
225
|
)
|
|
226
|
:controller => 'projects', :action => 'add_issue_category', :id => '64'
|
|
226
|
end
|
|
227
|
)
|
|
227
|
|
|
228
|
end
|
|
228
|
def test_add_issue_category_routing
|
|
229
|
|
|
229
|
assert_routing(
|
|
230
|
def test_destroy_routing
|
|
230
|
{:method => :get, :path => 'projects/test/categories/new'},
|
|
231
|
assert_routing(
|
|
231
|
:controller => 'projects', :action => 'add_issue_category', :id => 'test'
|
|
232
|
{:method => :get, :path => '/projects/567/destroy'},
|
|
232
|
)
|
|
233
|
:controller => 'projects', :action => 'destroy', :id => '567'
|
|
233
|
assert_routing(
|
|
234
|
)
|
|
234
|
#TODO: use PUT and update form
|
|
235
|
assert_routing(
|
|
235
|
{:method => :post, :path => 'projects/64/categories/new'},
|
|
236
|
#TODO: use DELETE and update form
|
|
236
|
:controller => 'projects', :action => 'add_issue_category', :id => '64'
|
|
237
|
{:method => :post, :path => 'projects/64/destroy'},
|
|
237
|
)
|
|
238
|
:controller => 'projects', :action => 'destroy', :id => '64'
|
|
238
|
end
|
|
239
|
)
|
|
239
|
|
|
240
|
end
|
|
240
|
def test_destroy_routing
|
|
241
|
|
|
241
|
assert_routing(
|
|
242
|
def test_get_destroy
|
|
242
|
{:method => :get, :path => '/projects/567/destroy'},
|
|
243
|
@request.session[:user_id] = 1 # admin
|
|
243
|
:controller => 'projects', :action => 'destroy', :id => '567'
|
|
244
|
get :destroy, :id => 1
|
|
244
|
)
|
|
245
|
assert_response :success
|
|
245
|
assert_routing(
|
|
246
|
assert_template 'destroy'
|
|
246
|
#TODO: use DELETE and update form
|
|
247
|
assert_not_nil Project.find_by_id(1)
|
|
247
|
{:method => :post, :path => 'projects/64/destroy'},
|
|
248
|
end
|
|
248
|
:controller => 'projects', :action => 'destroy', :id => '64'
|
|
249
|
|
|
249
|
)
|
|
250
|
def test_post_destroy
|
|
250
|
end
|
|
251
|
@request.session[:user_id] = 1 # admin
|
|
251
|
|
|
252
|
post :destroy, :id => 1, :confirm => 1
|
|
252
|
def test_get_destroy
|
|
253
|
assert_redirected_to 'admin/projects'
|
|
253
|
@request.session[:user_id] = 1 # admin
|
|
254
|
assert_nil Project.find_by_id(1)
|
|
254
|
get :destroy, :id => 1
|
|
255
|
end
|
|
255
|
assert_response :success
|
|
256
|
|
|
256
|
assert_template 'destroy'
|
|
257
|
def test_add_file
|
|
257
|
assert_not_nil Project.find_by_id(1)
|
|
258
|
set_tmp_attachments_directory
|
|
258
|
end
|
|
259
|
@request.session[:user_id] = 2
|
|
259
|
|
|
260
|
Setting.notified_events = ['file_added']
|
|
260
|
def test_post_destroy
|
|
261
|
ActionMailer::Base.deliveries.clear
|
|
261
|
@request.session[:user_id] = 1 # admin
|
|
262
|
|
|
262
|
post :destroy, :id => 1, :confirm => 1
|
|
263
|
assert_difference 'Attachment.count' do
|
|
263
|
assert_redirected_to 'admin/projects'
|
|
264
|
post :add_file, :id => 1, :version_id => '',
|
|
264
|
assert_nil Project.find_by_id(1)
|
|
265
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
265
|
end
|
|
266
|
end
|
|
266
|
|
|
267
|
assert_redirected_to 'projects/ecookbook/files'
|
|
267
|
def test_add_file
|
|
268
|
a = Attachment.find(:first, :order => 'created_on DESC')
|
|
268
|
set_tmp_attachments_directory
|
|
269
|
assert_equal 'testfile.txt', a.filename
|
|
269
|
@request.session[:user_id] = 2
|
|
270
|
assert_equal Project.find(1), a.container
|
|
270
|
Setting.notified_events = ['file_added']
|
|
271
|
|
|
271
|
ActionMailer::Base.deliveries.clear
|
|
272
|
mail = ActionMailer::Base.deliveries.last
|
|
272
|
|
|
273
|
assert_kind_of TMail::Mail, mail
|
|
273
|
assert_difference 'Attachment.count' do
|
|
274
|
assert_equal "[eCookbook] New file", mail.subject
|
|
274
|
post :add_file, :id => 1, :version_id => '',
|
|
275
|
assert mail.body.include?('testfile.txt')
|
|
275
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
276
|
end
|
|
276
|
end
|
|
277
|
|
|
277
|
assert_redirected_to 'projects/ecookbook/files'
|
|
278
|
def test_add_file_routing
|
|
278
|
a = Attachment.find(:first, :order => 'created_on DESC')
|
|
279
|
assert_routing(
|
|
279
|
assert_equal 'testfile.txt', a.filename
|
|
280
|
{:method => :get, :path => '/projects/33/files/new'},
|
|
280
|
assert_equal Project.find(1), a.container
|
|
281
|
:controller => 'projects', :action => 'add_file', :id => '33'
|
|
281
|
|
|
282
|
)
|
|
282
|
mail = ActionMailer::Base.deliveries.last
|
|
283
|
assert_routing(
|
|
283
|
assert_kind_of TMail::Mail, mail
|
|
284
|
{:method => :post, :path => '/projects/33/files/new'},
|
|
284
|
assert_equal "[eCookbook] New file", mail.subject
|
|
285
|
:controller => 'projects', :action => 'add_file', :id => '33'
|
|
285
|
assert mail.body.include?('testfile.txt')
|
|
286
|
)
|
|
286
|
end
|
|
287
|
end
|
|
287
|
|
|
288
|
|
|
288
|
def test_add_file_routing
|
|
289
|
def test_add_version_file
|
|
289
|
assert_routing(
|
|
290
|
set_tmp_attachments_directory
|
|
290
|
{:method => :get, :path => '/projects/33/files/new'},
|
|
291
|
@request.session[:user_id] = 2
|
|
291
|
:controller => 'projects', :action => 'add_file', :id => '33'
|
|
292
|
Setting.notified_events = ['file_added']
|
|
292
|
)
|
|
293
|
|
|
293
|
assert_routing(
|
|
294
|
assert_difference 'Attachment.count' do
|
|
294
|
{:method => :post, :path => '/projects/33/files/new'},
|
|
295
|
post :add_file, :id => 1, :version_id => '2',
|
|
295
|
:controller => 'projects', :action => 'add_file', :id => '33'
|
|
296
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
296
|
)
|
|
297
|
end
|
|
297
|
end
|
|
298
|
assert_redirected_to 'projects/ecookbook/files'
|
|
298
|
|
|
299
|
a = Attachment.find(:first, :order => 'created_on DESC')
|
|
299
|
def test_add_version_file
|
|
300
|
assert_equal 'testfile.txt', a.filename
|
|
300
|
set_tmp_attachments_directory
|
|
301
|
assert_equal Version.find(2), a.container
|
|
301
|
@request.session[:user_id] = 2
|
|
302
|
end
|
|
302
|
Setting.notified_events = ['file_added']
|
|
303
|
|
|
303
|
|
|
304
|
def test_list_files
|
|
304
|
assert_difference 'Attachment.count' do
|
|
305
|
get :list_files, :id => 1
|
|
305
|
post :add_file, :id => 1, :version_id => '2',
|
|
306
|
assert_response :success
|
|
306
|
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
|
307
|
assert_template 'list_files'
|
|
307
|
end
|
|
308
|
assert_not_nil assigns(:containers)
|
|
308
|
assert_redirected_to 'projects/ecookbook/files'
|
|
309
|
|
|
309
|
a = Attachment.find(:first, :order => 'created_on DESC')
|
|
310
|
# file attached to the project
|
|
310
|
assert_equal 'testfile.txt', a.filename
|
|
311
|
assert_tag :a, :content => 'project_file.zip',
|
|
311
|
assert_equal Version.find(2), a.container
|
|
312
|
:attributes => { :href => '/attachments/download/8/project_file.zip' }
|
|
312
|
end
|
|
313
|
|
|
313
|
|
|
314
|
# file attached to a project's version
|
|
314
|
def test_list_files
|
|
315
|
assert_tag :a, :content => 'version_file.zip',
|
|
315
|
get :list_files, :id => 1
|
|
316
|
:attributes => { :href => '/attachments/download/9/version_file.zip' }
|
|
316
|
assert_response :success
|
|
317
|
end
|
|
317
|
assert_template 'list_files'
|
|
318
|
|
|
318
|
assert_not_nil assigns(:containers)
|
|
319
|
def test_list_files_routing
|
|
319
|
|
|
320
|
assert_routing(
|
|
320
|
# file attached to the project
|
|
321
|
{:method => :get, :path => '/projects/33/files'},
|
|
321
|
assert_tag :a, :content => 'project_file.zip',
|
|
322
|
:controller => 'projects', :action => 'list_files', :id => '33'
|
|
322
|
:attributes => { :href => '/attachments/download/8/project_file.zip' }
|
|
323
|
)
|
|
323
|
|
|
324
|
end
|
|
324
|
# file attached to a project's version
|
|
325
|
|
|
325
|
assert_tag :a, :content => 'version_file.zip',
|
|
326
|
def test_changelog_routing
|
|
326
|
:attributes => { :href => '/attachments/download/9/version_file.zip' }
|
|
327
|
assert_routing(
|
|
327
|
end
|
|
328
|
{:method => :get, :path => '/projects/44/changelog'},
|
|
328
|
|
|
329
|
:controller => 'projects', :action => 'changelog', :id => '44'
|
|
329
|
def test_list_files_routing
|
|
330
|
)
|
|
330
|
assert_routing(
|
|
331
|
end
|
|
331
|
{:method => :get, :path => '/projects/33/files'},
|
|
332
|
|
|
332
|
:controller => 'projects', :action => 'list_files', :id => '33'
|
|
333
|
def test_changelog
|
|
333
|
)
|
|
334
|
get :changelog, :id => 1
|
|
334
|
end
|
|
335
|
assert_response :success
|
|
335
|
|
|
336
|
assert_template 'changelog'
|
|
336
|
def test_changelog_routing
|
|
337
|
assert_not_nil assigns(:versions)
|
|
337
|
assert_routing(
|
|
338
|
end
|
|
338
|
{:method => :get, :path => '/projects/44/changelog'},
|
|
339
|
|
|
339
|
:controller => 'projects', :action => 'changelog', :id => '44'
|
|
340
|
def test_roadmap_routing
|
|
340
|
)
|
|
341
|
assert_routing(
|
|
341
|
end
|
|
342
|
{:method => :get, :path => 'projects/33/roadmap'},
|
|
342
|
|
|
343
|
:controller => 'projects', :action => 'roadmap', :id => '33'
|
|
343
|
def test_changelog
|
|
344
|
)
|
|
344
|
get :changelog, :id => 1
|
|
345
|
end
|
|
345
|
assert_response :success
|
|
346
|
|
|
346
|
assert_template 'changelog'
|
|
347
|
def test_roadmap
|
|
347
|
assert_not_nil assigns(:versions)
|
|
348
|
get :roadmap, :id => 1
|
|
348
|
end
|
|
349
|
assert_response :success
|
|
349
|
|
|
350
|
assert_template 'roadmap'
|
|
350
|
def test_roadmap_routing
|
|
351
|
assert_not_nil assigns(:versions)
|
|
351
|
assert_routing(
|
|
352
|
# Version with no date set appears
|
|
352
|
{:method => :get, :path => 'projects/33/roadmap'},
|
|
353
|
assert assigns(:versions).include?(Version.find(3))
|
|
353
|
:controller => 'projects', :action => 'roadmap', :id => '33'
|
|
354
|
# Completed version doesn't appear
|
|
354
|
)
|
|
355
|
assert !assigns(:versions).include?(Version.find(1))
|
|
355
|
end
|
|
356
|
end
|
|
356
|
|
|
357
|
|
|
357
|
def test_roadmap
|
|
358
|
def test_roadmap_with_completed_versions
|
|
358
|
get :roadmap, :id => 1
|
|
359
|
get :roadmap, :id => 1, :completed => 1
|
|
359
|
assert_response :success
|
|
360
|
assert_response :success
|
|
360
|
assert_template 'roadmap'
|
|
361
|
assert_template 'roadmap'
|
|
361
|
assert_not_nil assigns(:versions)
|
|
362
|
assert_not_nil assigns(:versions)
|
|
362
|
# Version with no date set appears
|
|
363
|
# Version with no date set appears
|
|
363
|
assert assigns(:versions).include?(Version.find(3))
|
|
364
|
assert assigns(:versions).include?(Version.find(3))
|
|
364
|
# Completed version doesn't appear
|
|
365
|
# Completed version appears
|
|
365
|
assert !assigns(:versions).include?(Version.find(1))
|
|
366
|
assert assigns(:versions).include?(Version.find(1))
|
|
366
|
end
|
|
367
|
end
|
|
367
|
|
|
368
|
|
|
368
|
def test_roadmap_with_completed_versions
|
|
369
|
def test_project_activity_routing
|
|
369
|
get :roadmap, :id => 1, :completed => 1
|
|
370
|
assert_routing(
|
|
370
|
assert_response :success
|
|
371
|
{:method => :get, :path => '/projects/1/activity'},
|
|
371
|
assert_template 'roadmap'
|
|
372
|
:controller => 'projects', :action => 'activity', :id => '1'
|
|
372
|
assert_not_nil assigns(:versions)
|
|
373
|
)
|
|
373
|
# Version with no date set appears
|
|
374
|
end
|
|
374
|
assert assigns(:versions).include?(Version.find(3))
|
|
375
|
|
|
375
|
# Completed version appears
|
|
376
|
def test_project_activity_atom_routing
|
|
376
|
assert assigns(:versions).include?(Version.find(1))
|
|
377
|
assert_routing(
|
|
377
|
end
|
|
378
|
{:method => :get, :path => '/projects/1/activity.atom'},
|
|
378
|
|
|
379
|
:controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
|
|
379
|
def test_project_activity_routing
|
|
380
|
)
|
|
380
|
assert_routing(
|
|
381
|
end
|
|
381
|
{:method => :get, :path => '/projects/1/activity'},
|
|
382
|
|
|
382
|
:controller => 'projects', :action => 'activity', :id => '1'
|
|
383
|
def test_project_activity
|
|
383
|
)
|
|
384
|
get :activity, :id => 1, :with_subprojects => 0
|
|
384
|
end
|
|
385
|
assert_response :success
|
|
385
|
|
|
386
|
assert_template 'activity'
|
|
386
|
def test_project_activity_atom_routing
|
|
387
|
assert_not_nil assigns(:events_by_day)
|
|
387
|
assert_routing(
|
|
388
|
|
|
388
|
{:method => :get, :path => '/projects/1/activity.atom'},
|
|
389
|
assert_tag :tag => "h3",
|
|
389
|
:controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
|
|
390
|
:content => /#{2.days.ago.to_date.day}/,
|
|
390
|
)
|
|
391
|
:sibling => { :tag => "dl",
|
|
391
|
end
|
|
392
|
:child => { :tag => "dt",
|
|
392
|
|
|
393
|
:attributes => { :class => /issue-edit/ },
|
|
393
|
def test_project_activity
|
|
394
|
:child => { :tag => "a",
|
|
394
|
get :activity, :id => 1, :with_subprojects => 0
|
|
395
|
:content => /(#{IssueStatus.find(2).name})/,
|
|
395
|
assert_response :success
|
|
396
|
}
|
|
396
|
assert_template 'activity'
|
|
397
|
}
|
|
397
|
assert_not_nil assigns(:events_by_day)
|
|
398
|
}
|
|
398
|
|
|
399
|
end
|
|
399
|
assert_tag :tag => "h3",
|
|
400
|
|
|
400
|
:content => /#{2.days.ago.to_date.day}/,
|
|
401
|
def test_previous_project_activity
|
|
401
|
:sibling => { :tag => "dl",
|
|
402
|
get :activity, :id => 1, :from => 3.days.ago.to_date
|
|
402
|
:child => { :tag => "dt",
|
|
403
|
assert_response :success
|
|
403
|
:attributes => { :class => /issue-edit/ },
|
|
404
|
assert_template 'activity'
|
|
404
|
:child => { :tag => "a",
|
|
405
|
assert_not_nil assigns(:events_by_day)
|
|
405
|
:content => /(#{IssueStatus.find(2).name})/,
|
|
406
|
|
|
406
|
}
|
|
407
|
assert_tag :tag => "h3",
|
|
407
|
}
|
|
408
|
:content => /#{3.day.ago.to_date.day}/,
|
|
408
|
}
|
|
409
|
:sibling => { :tag => "dl",
|
|
409
|
end
|
|
410
|
:child => { :tag => "dt",
|
|
410
|
|
|
411
|
:attributes => { :class => /issue/ },
|
|
411
|
def test_previous_project_activity
|
|
412
|
:child => { :tag => "a",
|
|
412
|
get :activity, :id => 1, :from => 3.days.ago.to_date
|
|
413
|
:content => /#{Issue.find(1).subject}/,
|
|
413
|
assert_response :success
|
|
414
|
}
|
|
414
|
assert_template 'activity'
|
|
415
|
}
|
|
415
|
assert_not_nil assigns(:events_by_day)
|
|
416
|
}
|
|
416
|
|
|
417
|
end
|
|
417
|
assert_tag :tag => "h3",
|
|
418
|
|
|
418
|
:content => /#{3.day.ago.to_date.day}/,
|
|
419
|
def test_global_activity_routing
|
|
419
|
:sibling => { :tag => "dl",
|
|
420
|
assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity', :id => nil)
|
|
420
|
:child => { :tag => "dt",
|
|
421
|
end
|
|
421
|
:attributes => { :class => /issue/ },
|
|
422
|
|
|
422
|
:child => { :tag => "a",
|
|
423
|
def test_global_activity
|
|
423
|
:content => /#{Issue.find(1).subject}/,
|
|
424
|
get :activity
|
|
424
|
}
|
|
425
|
assert_response :success
|
|
425
|
}
|
|
426
|
assert_template 'activity'
|
|
426
|
}
|
|
427
|
assert_not_nil assigns(:events_by_day)
|
|
427
|
end
|
|
428
|
|
|
428
|
|
|
429
|
assert_tag :tag => "h3",
|
|
429
|
def test_global_activity_routing
|
|
430
|
:content => /#{5.day.ago.to_date.day}/,
|
|
430
|
assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity', :id => nil)
|
|
431
|
:sibling => { :tag => "dl",
|
|
431
|
end
|
|
432
|
:child => { :tag => "dt",
|
|
432
|
|
|
433
|
:attributes => { :class => /issue/ },
|
|
433
|
def test_global_activity
|
|
434
|
:child => { :tag => "a",
|
|
434
|
get :activity
|
|
435
|
:content => /#{Issue.find(5).subject}/,
|
|
435
|
assert_response :success
|
|
436
|
}
|
|
436
|
assert_template 'activity'
|
|
437
|
}
|
|
437
|
assert_not_nil assigns(:events_by_day)
|
|
438
|
}
|
|
438
|
|
|
439
|
end
|
|
439
|
assert_tag :tag => "h3",
|
|
440
|
|
|
440
|
:content => /#{5.day.ago.to_date.day}/,
|
|
441
|
def test_user_activity
|
|
441
|
:sibling => { :tag => "dl",
|
|
442
|
get :activity, :user_id => 2
|
|
442
|
:child => { :tag => "dt",
|
|
443
|
assert_response :success
|
|
443
|
:attributes => { :class => /issue/ },
|
|
444
|
assert_template 'activity'
|
|
444
|
:child => { :tag => "a",
|
|
445
|
assert_not_nil assigns(:events_by_day)
|
|
445
|
:content => /#{Issue.find(5).subject}/,
|
|
446
|
|
|
446
|
}
|
|
447
|
assert_tag :tag => "h3",
|
|
447
|
}
|
|
448
|
:content => /#{3.day.ago.to_date.day}/,
|
|
448
|
}
|
|
449
|
:sibling => { :tag => "dl",
|
|
449
|
end
|
|
450
|
:child => { :tag => "dt",
|
|
450
|
|
|
451
|
:attributes => { :class => /issue/ },
|
|
451
|
def test_user_activity
|
|
452
|
:child => { :tag => "a",
|
|
452
|
get :activity, :user_id => 2
|
|
453
|
:content => /#{Issue.find(1).subject}/,
|
|
453
|
assert_response :success
|
|
454
|
}
|
|
454
|
assert_template 'activity'
|
|
455
|
}
|
|
455
|
assert_not_nil assigns(:events_by_day)
|
|
456
|
}
|
|
456
|
|
|
457
|
end
|
|
457
|
assert_tag :tag => "h3",
|
|
458
|
|
|
458
|
:content => /#{3.day.ago.to_date.day}/,
|
|
459
|
def test_global_activity_atom_routing
|
|
459
|
:sibling => { :tag => "dl",
|
|
460
|
assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :id => nil, :format => 'atom')
|
|
460
|
:child => { :tag => "dt",
|
|
461
|
end
|
|
461
|
:attributes => { :class => /issue/ },
|
|
462
|
|
|
462
|
:child => { :tag => "a",
|
|
463
|
def test_activity_atom_feed
|
|
463
|
:content => /#{Issue.find(1).subject}/,
|
|
464
|
get :activity, :format => 'atom'
|
|
464
|
}
|
|
465
|
assert_response :success
|
|
465
|
}
|
|
466
|
assert_template 'common/feed.atom.rxml'
|
|
466
|
}
|
|
467
|
end
|
|
467
|
end
|
|
468
|
|
|
468
|
|
|
469
|
def test_archive_routing
|
|
469
|
def test_global_activity_atom_routing
|
|
470
|
assert_routing(
|
|
470
|
assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :id => nil, :format => 'atom')
|
|
471
|
#TODO: use PUT to project path and modify form
|
|
471
|
end
|
|
472
|
{:method => :post, :path => 'projects/64/archive'},
|
|
472
|
|
|
473
|
:controller => 'projects', :action => 'archive', :id => '64'
|
|
473
|
def test_activity_atom_feed
|
|
474
|
)
|
|
474
|
get :activity, :format => 'atom'
|
|
475
|
end
|
|
475
|
assert_response :success
|
|
476
|
|
|
476
|
assert_template 'common/feed.atom.rxml'
|
|
477
|
def test_archive
|
|
477
|
end
|
|
478
|
@request.session[:user_id] = 1 # admin
|
|
478
|
|
|
479
|
post :archive, :id => 1
|
|
479
|
def test_archive_routing
|
|
480
|
assert_redirected_to 'admin/projects'
|
|
480
|
assert_routing(
|
|
481
|
assert !Project.find(1).active?
|
|
481
|
#TODO: use PUT to project path and modify form
|
|
482
|
end
|
|
482
|
{:method => :post, :path => 'projects/64/archive'},
|
|
483
|
|
|
483
|
:controller => 'projects', :action => 'archive', :id => '64'
|
|
484
|
def test_unarchive_routing
|
|
484
|
)
|
|
485
|
assert_routing(
|
|
485
|
end
|
|
486
|
#TODO: use PUT to project path and modify form
|
|
486
|
|
|
487
|
{:method => :post, :path => '/projects/567/unarchive'},
|
|
487
|
def test_archive
|
|
488
|
:controller => 'projects', :action => 'unarchive', :id => '567'
|
|
488
|
@request.session[:user_id] = 1 # admin
|
|
489
|
)
|
|
489
|
post :archive, :id => 1
|
|
490
|
end
|
|
490
|
assert_redirected_to 'admin/projects'
|
|
491
|
|
|
491
|
assert !Project.find(1).active?
|
|
492
|
def test_unarchive
|
|
492
|
end
|
|
493
|
@request.session[:user_id] = 1 # admin
|
|
493
|
|
|
494
|
Project.find(1).archive
|
|
494
|
def test_unarchive_routing
|
|
495
|
post :unarchive, :id => 1
|
|
495
|
assert_routing(
|
|
496
|
assert_redirected_to 'admin/projects'
|
|
496
|
#TODO: use PUT to project path and modify form
|
|
497
|
assert Project.find(1).active?
|
|
497
|
{:method => :post, :path => '/projects/567/unarchive'},
|
|
498
|
end
|
|
498
|
:controller => 'projects', :action => 'unarchive', :id => '567'
|
|
499
|
|
|
499
|
)
|
|
500
|
def test_project_breadcrumbs_should_be_limited_to_3_ancestors
|
|
500
|
end
|
|
501
|
CustomField.delete_all
|
|
501
|
|
|
502
|
parent = nil
|
|
502
|
def test_unarchive
|
|
503
|
6.times do |i|
|
|
503
|
@request.session[:user_id] = 1 # admin
|
|
504
|
p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
|
|
504
|
Project.find(1).archive
|
|
505
|
p.set_parent!(parent)
|
|
505
|
post :unarchive, :id => 1
|
|
506
|
get :show, :id => p
|
|
506
|
assert_redirected_to 'admin/projects'
|
|
507
|
assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
|
|
507
|
assert Project.find(1).active?
|
|
508
|
:children => { :count => [i, 3].min,
|
|
508
|
end
|
|
509
|
:only => { :tag => 'a' } }
|
|
509
|
|
|
510
|
|
|
510
|
def test_project_breadcrumbs_should_be_limited_to_3_ancestors
|
|
511
|
parent = p
|
|
511
|
CustomField.delete_all
|
|
512
|
end
|
|
512
|
parent = nil
|
|
513
|
end
|
|
513
|
6.times do |i|
|
|
514
|
|
|
514
|
p = Project.create!(:name => "Breadcrumbs #{i}", :identifier => "breadcrumbs-#{i}")
|
|
515
|
def test_copy_with_project
|
|
515
|
p.set_parent!(parent)
|
|
516
|
@request.session[:user_id] = 1 # admin
|
|
516
|
get :show, :id => p
|
|
517
|
get :copy, :id => 1
|
|
517
|
assert_tag :h1, :parent => { :attributes => {:id => 'header'}},
|
|
518
|
assert_response :success
|
|
518
|
:children => { :count => [i, 3].min,
|
|
519
|
assert_template 'copy'
|
|
519
|
:only => { :tag => 'a' } }
|
|
520
|
assert assigns(:project)
|
|
520
|
|
|
521
|
assert_equal Project.find(1).description, assigns(:project).description
|
|
521
|
parent = p
|
|
522
|
assert_nil assigns(:project).id
|
|
522
|
end
|
|
523
|
end
|
|
523
|
end
|
|
524
|
|
|
524
|
|
|
525
|
def test_copy_without_project
|
|
525
|
def test_copy_with_project
|
|
526
|
@request.session[:user_id] = 1 # admin
|
|
526
|
@request.session[:user_id] = 1 # admin
|
|
527
|
get :copy
|
|
527
|
get :copy, :id => 1
|
|
528
|
assert_response :redirect
|
|
528
|
assert_response :success
|
|
529
|
assert_redirected_to :controller => 'admin', :action => 'projects'
|
|
529
|
assert_template 'copy'
|
|
530
|
end
|
|
530
|
assert assigns(:project)
|
|
531
|
|
|
531
|
assert_equal Project.find(1).description, assigns(:project).description
|
|
532
|
def test_jump_should_redirect_to_active_tab
|
|
532
|
assert_nil assigns(:project).id
|
|
533
|
get :show, :id => 1, :jump => 'issues'
|
|
533
|
end
|
|
534
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
534
|
|
|
535
|
end
|
|
535
|
def test_copy_without_project
|
|
536
|
|
|
536
|
@request.session[:user_id] = 1 # admin
|
|
537
|
def test_jump_should_not_redirect_to_inactive_tab
|
|
537
|
get :copy
|
|
538
|
get :show, :id => 3, :jump => 'documents'
|
|
538
|
assert_response :redirect
|
|
539
|
assert_response :success
|
|
539
|
assert_redirected_to :controller => 'admin', :action => 'projects'
|
|
540
|
assert_template 'show'
|
|
540
|
end
|
|
541
|
end
|
|
541
|
|
|
542
|
|
|
542
|
def test_jump_should_redirect_to_active_tab
|
|
543
|
def test_jump_should_not_redirect_to_unknown_tab
|
|
543
|
get :show, :id => 1, :jump => 'issues'
|
|
544
|
get :show, :id => 3, :jump => 'foobar'
|
|
544
|
assert_redirected_to 'projects/ecookbook/issues'
|
|
545
|
assert_response :success
|
|
545
|
end
|
|
546
|
assert_template 'show'
|
|
546
|
|
|
547
|
end
|
|
547
|
def test_jump_should_not_redirect_to_inactive_tab
|
|
548
|
|
|
548
|
get :show, :id => 3, :jump => 'documents'
|
|
549
|
# A hook that is manually registered later
|
|
549
|
assert_response :success
|
|
550
|
class ProjectBasedTemplate < Redmine::Hook::ViewListener
|
|
550
|
assert_template 'show'
|
|
551
|
def view_layouts_base_html_head(context)
|
|
551
|
end
|
|
552
|
# Adds a project stylesheet
|
|
552
|
|
|
553
|
stylesheet_link_tag(context[:project].identifier) if context[:project]
|
|
553
|
def test_jump_should_not_redirect_to_unknown_tab
|
|
554
|
end
|
|
554
|
get :show, :id => 3, :jump => 'foobar'
|
|
555
|
end
|
|
555
|
assert_response :success
|
|
556
|
# Don't use this hook now
|
|
556
|
assert_template 'show'
|
|
557
|
Redmine::Hook.clear_listeners
|
|
557
|
end
|
|
558
|
|
|
558
|
|
|
559
|
def test_hook_response
|
|
559
|
# A hook that is manually registered later
|
|
560
|
Redmine::Hook.add_listener(ProjectBasedTemplate)
|
|
560
|
class ProjectBasedTemplate < Redmine::Hook::ViewListener
|
|
561
|
get :show, :id => 1
|
|
561
|
def view_layouts_base_html_head(context)
|
|
562
|
assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
|
|
562
|
# Adds a project stylesheet
|
|
563
|
:parent => {:tag => 'head'}
|
|
563
|
stylesheet_link_tag(context[:project].identifier) if context[:project]
|
|
564
|
|
|
564
|
end
|
|
565
|
Redmine::Hook.clear_listeners
|
|
565
|
end
|
|
566
|
end
|
|
566
|
# Don't use this hook now
|
|
567
|
end
|
|
567
|
Redmine::Hook.clear_listeners
|
|
|
|
|
568
|
|
|
|
|
|
569
|
def test_hook_response
|
|
|
|
|
570
|
Redmine::Hook.add_listener(ProjectBasedTemplate)
|
|
|
|
|
571
|
get :show, :id => 1
|
|
|
|
|
572
|
assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
|
|
|
|
|
573
|
:parent => {:tag => 'head'}
|
|
|
|
|
574
|
|
|
|
|
|
575
|
Redmine::Hook.clear_listeners
|
|
|
|
|
576
|
end
|
|
|
|
|
577
|
end
|