Merged r3927 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.0-stable@3977 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/351/head
Eric Davis 14 years ago
parent b6bc3a3665
commit c67272599c
  1. 6
      app/models/query.rb
  2. 9
      test/unit/query_test.rb

@ -219,6 +219,12 @@ class Query < ActiveRecord::Base
@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

@ -33,6 +33,15 @@ class QueryTest < ActiveSupport::TestCase
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 ],

Loading…
Cancel
Save