@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } }
end
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
+ # project filter
+ project_values = Project.all(:conditions => Project.visible_by(User.current), :order => 'lft').map do |p|
+ pre = (p.level > 0 ? ('--' * p.level + ' ') : '')
+ ["#{pre}#{p.name}",p.id.to_s]
+ end
+ @available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values}
end
@available_filters
end
assert query.available_filters['fixed_version_id'][:values].detect {|v| v.last == '2'}
end
+ def test_project_filter_in_global_queries
+ query = Query.new(:project => nil, :name => '_')
+ project_filter = query.available_filters["project_id"]
+ assert_not_nil project_filter
+ project_ids = project_filter[:values].map{|p| p[1]}
+ assert project_ids.include?("1") #public project
+ assert !project_ids.include?("2") #private project user cannot see
+ end
+
def find_issues_with_query(query)
Issue.find :all,
:include => [ :assigned_to, :status, :tracker, :project, :priority ],