@@ -265,7 +265,7 class Query < ActiveRecord::Base | |||
|
265 | 265 | |
|
266 | 266 | def statement |
|
267 | 267 | # project/subprojects clause |
|
268 |
clause = |
|
|
268 | project_clauses = [] | |
|
269 | 269 | if project && !@project.active_children.empty? |
|
270 | 270 | ids = [project.id] |
|
271 | 271 | if has_filter?("subproject_id") |
@@ -277,17 +277,16 class Query < ActiveRecord::Base | |||
|
277 | 277 | # main project only |
|
278 | 278 | else |
|
279 | 279 | # all subprojects |
|
280 |
ids += project. |
|
|
280 | ids += project.child_ids | |
|
281 | 281 | end |
|
282 | 282 | elsif Setting.display_subprojects_issues? |
|
283 |
ids += project. |
|
|
283 | ids += project.child_ids | |
|
284 | 284 | end |
|
285 | clause << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',') | |
|
285 | project_clauses << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',') | |
|
286 | 286 | elsif project |
|
287 | clause << "#{Issue.table_name}.project_id = %d" % project.id | |
|
288 | else | |
|
289 | clause << Project.visible_by(User.current) | |
|
287 | project_clauses << "#{Issue.table_name}.project_id = %d" % project.id | |
|
290 | 288 | end |
|
289 | project_clauses << Project.visible_by(User.current) | |
|
291 | 290 | |
|
292 | 291 | # filters clauses |
|
293 | 292 | filters_clauses = [] |
@@ -365,8 +364,6 class Query < ActiveRecord::Base | |||
|
365 | 364 | filters_clauses << sql |
|
366 | 365 | end if filters and valid? |
|
367 | 366 | |
|
368 | clause << ' AND ' unless clause.empty? | |
|
369 | clause << filters_clauses.join(' AND ') unless filters_clauses.empty? | |
|
370 | clause | |
|
367 | (project_clauses + filters_clauses).join(' AND ') | |
|
371 | 368 | end |
|
372 | 369 | end |
@@ -53,13 +53,44 class IssuesControllerTest < Test::Unit::TestCase | |||
|
53 | 53 | assert_template 'index.rhtml' |
|
54 | 54 | assert_not_nil assigns(:issues) |
|
55 | 55 | assert_nil assigns(:project) |
|
56 | assert_tag :tag => 'a', :content => /Can't print recipes/ | |
|
57 | assert_tag :tag => 'a', :content => /Subproject issue/ | |
|
58 | # private projects hidden | |
|
59 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ | |
|
60 | assert_no_tag :tag => 'a', :content => /Issue on project 2/ | |
|
56 | 61 | end |
|
57 | 62 | |
|
58 | 63 | def test_index_with_project |
|
64 | Setting.display_subprojects_issues = 0 | |
|
59 | 65 | get :index, :project_id => 1 |
|
60 | 66 | assert_response :success |
|
61 | 67 | assert_template 'index.rhtml' |
|
62 | 68 | assert_not_nil assigns(:issues) |
|
69 | assert_tag :tag => 'a', :content => /Can't print recipes/ | |
|
70 | assert_no_tag :tag => 'a', :content => /Subproject issue/ | |
|
71 | end | |
|
72 | ||
|
73 | def test_index_with_project_and_subprojects | |
|
74 | Setting.display_subprojects_issues = 1 | |
|
75 | get :index, :project_id => 1 | |
|
76 | assert_response :success | |
|
77 | assert_template 'index.rhtml' | |
|
78 | assert_not_nil assigns(:issues) | |
|
79 | assert_tag :tag => 'a', :content => /Can't print recipes/ | |
|
80 | assert_tag :tag => 'a', :content => /Subproject issue/ | |
|
81 | assert_no_tag :tag => 'a', :content => /Issue of a private subproject/ | |
|
82 | end | |
|
83 | ||
|
84 | def test_index_with_project_and_subprojects_should_show_private_subprojects | |
|
85 | @request.session[:user_id] = 2 | |
|
86 | Setting.display_subprojects_issues = 1 | |
|
87 | get :index, :project_id => 1 | |
|
88 | assert_response :success | |
|
89 | assert_template 'index.rhtml' | |
|
90 | assert_not_nil assigns(:issues) | |
|
91 | assert_tag :tag => 'a', :content => /Can't print recipes/ | |
|
92 | assert_tag :tag => 'a', :content => /Subproject issue/ | |
|
93 | assert_tag :tag => 'a', :content => /Issue of a private subproject/ | |
|
63 | 94 | end |
|
64 | 95 | |
|
65 | 96 | def test_index_with_project_and_filter |
General Comments 0
You need to be logged in to leave comments.
Login now