Defect #8603 » subproject_filter_for_all_projects.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
"last_updated_by",
|
||
|
:type => :list, :values => lambda {author_values}
|
||
|
)
|
||
|
if project && !project.leaf?
|
||
|
if project.nil? || !project.leaf?
|
||
|
add_available_filter(
|
||
|
"subproject_id",
|
||
|
:type => :list_subprojects,
|
||
| app/models/query.rb | ||
|---|---|---|
|
end
|
||
|
def subproject_values
|
||
|
return [] unless project
|
||
|
project.descendants.visible.pluck(:name, :id).map {|name, id| [name, id.to_s]}
|
||
|
end
|
||
| app/models/time_entry_query.rb | ||
|---|---|---|
|
"project_id",
|
||
|
:type => :list, :values => lambda {project_values}
|
||
|
) if project.nil?
|
||
|
if project && !project.leaf?
|
||
|
if project.nil? || !project.leaf?
|
||
|
add_available_filter(
|
||
|
"subproject_id",
|
||
|
:type => :list_subprojects,
|
||
| test/functional/queries_controller_test.rb | ||
|---|---|---|
|
assert_equal Query::VISIBILITY_PUBLIC, query.visibility
|
||
|
end
|
||
|
def test_create_query_for_all_projects_with_subproject_filter
|
||
|
@request.session[:user_id] = 1
|
||
|
query = new_record(Query) do
|
||
|
post(
|
||
|
:create,
|
||
|
:params => {
|
||
|
:project_id => 'ecookbook',
|
||
|
:query_is_for_all => '1',
|
||
|
:f => ['subproject_id'],
|
||
|
:op => {'subproject_id' => '!*'},
|
||
|
:query => {'name' => 'Without subprojects', 'visibility' => '2'}
|
||
|
}
|
||
|
)
|
||
|
assert_response :found
|
||
|
end
|
||
|
assert_nil query.project
|
||
|
assert_equal({:operator => '!*', :values => ['']}, query.filters['subproject_id'])
|
||
|
end
|
||
|
def test_create_global_public_query_should_force_private_with_manage_public_queries_permission
|
||
|
@request.session[:user_id] = 2
|
||
|
query = new_record(Query) do
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert query.available_filters.has_key?('project.status')
|
||
|
end
|
||
|
def test_subproject_filter_should_be_available_for_query_for_all_projects
|
||
|
query = IssueQuery.new(:project => nil, :name => '_')
|
||
|
assert_include 'subproject_id', query.available_filters.keys
|
||
|
assert_equal [], query.available_filters['subproject_id'][:values]
|
||
|
end
|
||
|
def test_subproject_filter_should_not_be_available_when_project_is_leaf
|
||
|
query = IssueQuery.new(:project => Project.find(2), :name => '_')
|
||
|
assert_not_include 'subproject_id', query.available_filters.keys
|
||
|
end
|
||
|
def test_subproject_filter_of_query_for_all_projects_should_apply_in_project
|
||
|
query = IssueQuery.new(:project => nil, :name => '_')
|
||
|
query.add_filter('subproject_id', '!*', [''])
|
||
|
assert_include 'subproject_id', query.filters.keys
|
||
|
assert_include 5, find_issues_with_query(query).map(&:id)
|
||
|
query.project = Project.find(1)
|
||
|
assert_equal [1, 2, 3, 7], find_issues_with_query(query).map(&:id).sort
|
||
|
end
|
||
|
def test_project_status_filter_should_be_available_when_project_has_subprojects
|
||
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
assert query.available_filters.has_key?('project.status')
|
||