if project
user_values += project.users.sort.collect{|s| [s.name, s.id.to_s] }
else
- project_ids = Project.all(:conditions => Project.visible_by(User.current)).collect(&:id)
- if project_ids.any?
- # members of the user's projects
- user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids]).sort.collect{|s| [s.name, s.id.to_s] }
+ all_projects = Project.visible.all
+ if all_projects.any?
+ # members of visible projects
+ user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", all_projects.collect(&:id)]).sort.collect{|s| [s.name, s.id.to_s] }
+
+ # project filter
+ project_values = []
+ Project.project_tree(all_projects) do |p, level|
+ prefix = (level > 0 ? ('--' * level + ' ') : '')
+ project_values << ["#{prefix}#{p.name}", p.id.to_s]
+ end
+ @available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty?
end
end
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
@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 users[:values].map{|u|u[1]}.include?("3")
end
+ should "include visible projects in cross-project view" do
+ projects = @query.available_filters["project_id"]
+ assert_not_nil projects
+ assert projects[:values].map{|u|u[1]}.include?("1")
+ end
+
context "'member_of_group' filter" do
should "be present" do
assert @query.available_filters.keys.include?("member_of_group")