Defect #34297 » 34297-v2.patch
| app/models/query.rb | ||
|---|---|---|
|
def project_statement
|
||
|
project_clauses = []
|
||
|
active_subprojects_ids = []
|
||
|
subprojects_ids = []
|
||
|
active_subprojects_ids = project.descendants.active.map(&:id) if project
|
||
|
if active_subprojects_ids.any?
|
||
|
subprojects_ids = project.descendants.where.not(status: Project::STATUS_ARCHIVED).ids if project
|
||
|
if subprojects_ids.any?
|
||
|
if has_filter?("subproject_id")
|
||
|
case operator_for("subproject_id")
|
||
|
when '='
|
||
| ... | ... | |
|
project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
|
||
|
when '!'
|
||
|
# exclude the selected subprojects
|
||
|
ids = [project.id] + active_subprojects_ids - values_for("subproject_id").map(&:to_i)
|
||
|
ids = [project.id] + subprojects_ids - values_for("subproject_id").map(&:to_i)
|
||
|
project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
|
||
|
when '!*'
|
||
|
# main project only
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_index_should_list_issues_of_closed_subprojects
|
||
|
Project.update_all(:is_public => true)
|
||
|
project = Project.find(1)
|
||
|
project.descendants.each(&:close)
|
||
|
with_settings :display_subprojects_issues => '1' do
|
||
|
get(:index, :params => {:project_id => project.id})
|
||
|
assert_response :success
|
||
|
assert_select 'td.id' do
|
||
|
assert_select 'a[href="/issues/5"]', 1
|
||
|
assert_select 'a[href="/issues/6"]', 1
|
||
|
assert_select 'a[href="/issues/9"]', 1
|
||
|
assert_select 'a[href="/issues/10"]', 1
|
||
|
assert_select 'a[href="/issues/13"]', 1
|
||
|
assert_select 'a[href="/issues/14"]', 0 # private issue
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def test_index_with_project_and_subprojects_should_show_private_subprojects_with_permission
|
||
|
@request.session[:user_id] = 2
|
||
|
with_settings :display_subprojects_issues => '1' do
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
ActiveRecord::Base.default_timezone = :local # restore Redmine default
|
||
|
end
|
||
|
def test_project_statement_with_closed_subprojects
|
||
|
project = Project.find(1)
|
||
|
project.descendants.each(&:close)
|
||
|
with_settings :display_subprojects_issues => '1' do
|
||
|
query = IssueQuery.new(:name => '_', :project => project)
|
||
|
statement = query.project_statement
|
||
|
assert_equal "projects.lft >= #{project.lft} AND projects.rgt <= #{project.rgt}", statement
|
||
|
end
|
||
|
end
|
||
|
def test_filter_on_subprojects
|
||
|
query = IssueQuery.new(:name => '_', :project => Project.find(1))
|
||
|
filter_name = "subproject_id"
|
||
- « Previous
- 1
- 2
- Next »