Patch #36824 ยป 0001-Allow-to-check-for-shared-versions-with-fixed_versio.patch
app/models/issue_query.rb | ||
---|---|---|
578 | 578 | |
579 | 579 |
def sql_for_fixed_version_status_field(field, operator, value) |
580 | 580 |
where = sql_for_field(field, operator, value, Version.table_name, "status") |
581 |
version_ids = versions(:conditions => [where]).map(&:id) |
|
581 |
version_id_scope = project ? project.shared_versions : Version.visible |
|
582 |
version_ids = version_id_scope.where(where).pluck(:id) |
|
582 | 583 | |
583 | 584 |
nl = operator == "!" ? "#{Issue.table_name}.fixed_version_id IS NULL OR" : '' |
584 | 585 |
"(#{nl} #{sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id")})" |
... | ... | |
586 | 587 | |
587 | 588 |
def sql_for_fixed_version_due_date_field(field, operator, value) |
588 | 589 |
where = sql_for_field(field, operator, value, Version.table_name, "effective_date") |
589 |
version_ids = versions(:conditions => [where]).map(&:id) |
|
590 |
version_id_scope = project ? project.shared_versions : Version.visible |
|
591 |
version_ids = version_id_scope.where(where).pluck(:id) |
|
590 | 592 | |
591 | 593 |
nl = operator == "!*" ? "#{Issue.table_name}.fixed_version_id IS NULL OR" : '' |
592 | 594 |
"(#{nl} #{sql_for_field("fixed_version_id", "=", version_ids, Issue.table_name, "fixed_version_id")})" |
test/unit/query_test.rb | ||
---|---|---|
1235 | 1235 |
assert_equal [1, 3, 7, 8], find_issues_with_query(query).map(&:id).uniq.sort |
1236 | 1236 |
end |
1237 | 1237 | |
1238 |
def test_filter_on_fixed_version_status_respects_sharing |
|
1239 |
issue = Issue.generate!(:project_id => 1, :fixed_version_id => 7) |
|
1240 | ||
1241 |
filter_name = "fixed_version.status" |
|
1242 | ||
1243 |
query = IssueQuery.new(:name => '_', project: Project.find(1)) |
|
1244 |
assert_include filter_name, query.available_filters.keys |
|
1245 |
query.filters = {filter_name => {:operator => '=', :values => ['open']}} |
|
1246 |
assert_include issue, find_issues_with_query(query) |
|
1247 | ||
1248 |
query = IssueQuery.new(:name => '_', project: Project.find(1)) |
|
1249 |
query.filters = {filter_name => {:operator => '=', :values => ['closed']}} |
|
1250 |
refute_includes find_issues_with_query(query), issue |
|
1251 |
end |
|
1252 | ||
1238 | 1253 |
def test_filter_on_version_custom_field |
1239 | 1254 |
field = IssueCustomField.generate!(:field_format => 'version', :is_filter => true) |
1240 | 1255 |
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {field.id.to_s => '2'}) |