272 |
272 |
end
|
273 |
273 |
|
274 |
274 |
def test_destroy_tracker_in_use
|
275 |
|
tracker = Tracker.generate!(name: 'In use')
|
276 |
|
projects = Array.new(2) do
|
277 |
|
project = Project.generate!
|
278 |
|
Issue.generate!(project: project, tracker: tracker)
|
279 |
|
project
|
280 |
|
end
|
|
275 |
tracker = Tracker.find_by(name: 'Bug')
|
|
276 |
# A project where the tracker is explicitly enabled
|
|
277 |
project_with_tracker = Project.find_by(identifier: 'private-child')
|
|
278 |
# A project where the tracker is disabled, but rolled up from subprojects
|
|
279 |
project_with_rolled_up_tracker = Project.find_by(identifier: 'ecookbook')
|
|
280 |
project_with_rolled_up_tracker.trackers.delete(tracker)
|
|
281 |
# A project where the tracker is completely disabled
|
|
282 |
project_without_tracker = Project.find_by(identifier: 'onlinestore')
|
|
283 |
project_without_tracker.trackers.delete(tracker)
|
281 |
284 |
|
282 |
285 |
assert_no_difference 'Tracker.count' do
|
283 |
286 |
delete :destroy, params: {id: tracker.id}
|
284 |
287 |
end
|
285 |
288 |
assert_redirected_to action: 'index'
|
286 |
|
assert_match /The following projects have issues with this tracker:/, flash[:error]
|
287 |
|
projects.each do |project|
|
288 |
|
assert_match /#{project.name}/, flash[:error]
|
289 |
|
end
|
|
289 |
assert_includes flash[:error], 'The following projects have issues with this tracker:'
|
|
290 |
|
|
291 |
# projects with the tracker enabled or rolled up have a link in the error message
|
|
292 |
assert_includes flash[:error], project_with_tracker.name
|
|
293 |
assert_match %r{<a href=".*#{project_with_tracker.identifier}.*">}, flash[:error]
|
|
294 |
assert_includes flash[:error], project_with_rolled_up_tracker.name
|
|
295 |
assert_match %r{<a href=".*#{project_with_rolled_up_tracker.identifier}.*">}, flash[:error]
|
|
296 |
|
|
297 |
# projects without the tracker appear as text in the error message, without a link
|
|
298 |
assert_includes flash[:error], project_without_tracker.name
|
|
299 |
assert_no_match %r{<a href=".*#{project_without_tracker.identifier}.*">}, flash[:error]
|
290 |
300 |
end
|
291 |
301 |
|
292 |
302 |
def test_get_fields
|