@@ -265,7 +265,7 class Query < ActiveRecord::Base | |||||
265 |
|
265 | |||
266 | def statement |
|
266 | def statement | |
267 | # project/subprojects clause |
|
267 | # project/subprojects clause | |
268 |
clause = |
|
268 | project_clauses = [] | |
269 | if project && !@project.active_children.empty? |
|
269 | if project && !@project.active_children.empty? | |
270 | ids = [project.id] |
|
270 | ids = [project.id] | |
271 | if has_filter?("subproject_id") |
|
271 | if has_filter?("subproject_id") | |
@@ -277,17 +277,16 class Query < ActiveRecord::Base | |||||
277 | # main project only |
|
277 | # main project only | |
278 | else |
|
278 | else | |
279 | # all subprojects |
|
279 | # all subprojects | |
280 |
ids += project. |
|
280 | ids += project.child_ids | |
281 | end |
|
281 | end | |
282 | elsif Setting.display_subprojects_issues? |
|
282 | elsif Setting.display_subprojects_issues? | |
283 |
ids += project. |
|
283 | ids += project.child_ids | |
284 | end |
|
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 | elsif project |
|
286 | elsif project | |
287 | clause << "#{Issue.table_name}.project_id = %d" % project.id |
|
287 | project_clauses << "#{Issue.table_name}.project_id = %d" % project.id | |
288 | else |
|
|||
289 | clause << Project.visible_by(User.current) |
|
|||
290 | end |
|
288 | end | |
|
289 | project_clauses << Project.visible_by(User.current) | |||
291 |
|
290 | |||
292 | # filters clauses |
|
291 | # filters clauses | |
293 | filters_clauses = [] |
|
292 | filters_clauses = [] | |
@@ -365,8 +364,6 class Query < ActiveRecord::Base | |||||
365 | filters_clauses << sql |
|
364 | filters_clauses << sql | |
366 | end if filters and valid? |
|
365 | end if filters and valid? | |
367 |
|
366 | |||
368 | clause << ' AND ' unless clause.empty? |
|
367 | (project_clauses + filters_clauses).join(' AND ') | |
369 | clause << filters_clauses.join(' AND ') unless filters_clauses.empty? |
|
|||
370 | clause |
|
|||
371 | end |
|
368 | end | |
372 | end |
|
369 | end |
@@ -53,13 +53,44 class IssuesControllerTest < Test::Unit::TestCase | |||||
53 | assert_template 'index.rhtml' |
|
53 | assert_template 'index.rhtml' | |
54 | assert_not_nil assigns(:issues) |
|
54 | assert_not_nil assigns(:issues) | |
55 | assert_nil assigns(:project) |
|
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 | end |
|
61 | end | |
57 |
|
62 | |||
58 | def test_index_with_project |
|
63 | def test_index_with_project | |
|
64 | Setting.display_subprojects_issues = 0 | |||
59 | get :index, :project_id => 1 |
|
65 | get :index, :project_id => 1 | |
60 | assert_response :success |
|
66 | assert_response :success | |
61 | assert_template 'index.rhtml' |
|
67 | assert_template 'index.rhtml' | |
62 | assert_not_nil assigns(:issues) |
|
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 | end |
|
94 | end | |
64 |
|
95 | |||
65 | def test_index_with_project_and_filter |
|
96 | def test_index_with_project_and_filter |
General Comments 0
You need to be logged in to leave comments.
Login now