Include issues asigned to user's groups when using "assigned to me" filter (#2964).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6332 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8ba74845bc
commit
7f77744e86
|
@ -487,7 +487,14 @@ class Query < ActiveRecord::Base
|
||||||
|
|
||||||
# "me" value subsitution
|
# "me" value subsitution
|
||||||
if %w(assigned_to_id author_id watcher_id).include?(field)
|
if %w(assigned_to_id author_id watcher_id).include?(field)
|
||||||
v.push(User.current.logged? ? User.current.id.to_s : "0") if v.delete("me")
|
if v.delete("me")
|
||||||
|
if User.current.logged?
|
||||||
|
v.push(User.current.id.to_s)
|
||||||
|
v += User.current.group_ids.map(&:to_s) if field == 'assigned_to_id'
|
||||||
|
else
|
||||||
|
v.push("0")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if field =~ /^cf_(\d+)$/
|
if field =~ /^cf_(\d+)$/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<h3><%=l(:label_assigned_to_me_issues)%> (<%= Issue.visible.open.count(:conditions => {:assigned_to_id => User.current.id})%>)</h3>
|
<h3><%=l(:label_assigned_to_me_issues)%> (<%= Issue.visible.open.count(:conditions => {:assigned_to_id => ([User.current.id] + User.current.group_ids)})%>)</h3>
|
||||||
|
|
||||||
<% assigned_issues = Issue.visible.open.find(:all,
|
<% assigned_issues = Issue.visible.open.find(:all,
|
||||||
:conditions => {:assigned_to_id => User.current.id},
|
:conditions => {:assigned_to_id => ([User.current.id] + User.current.group_ids)},
|
||||||
:limit => 10,
|
:limit => 10,
|
||||||
:include => [ :status, :project, :tracker, :priority ],
|
:include => [ :status, :project, :tracker, :priority ],
|
||||||
:order => "#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
|
:order => "#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
|
||||||
|
|
|
@ -336,6 +336,24 @@ class QueryTest < ActiveSupport::TestCase
|
||||||
find_issues_with_query(query)
|
find_issues_with_query(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_filter_assigned_to_me
|
||||||
|
user = User.find(2)
|
||||||
|
group = Group.find(10)
|
||||||
|
User.current = user
|
||||||
|
i1 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => user)
|
||||||
|
i2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => group)
|
||||||
|
i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => Group.find(11))
|
||||||
|
group.users << user
|
||||||
|
|
||||||
|
query = Query.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
||||||
|
result = query.issues
|
||||||
|
assert_equal Issue.visible.all(:conditions => {:assigned_to_id => ([2] + user.reload.group_ids)}).sort_by(&:id), result.sort_by(&:id)
|
||||||
|
|
||||||
|
assert result.include?(i1)
|
||||||
|
assert result.include?(i2)
|
||||||
|
assert !result.include?(i3)
|
||||||
|
end
|
||||||
|
|
||||||
def test_filter_watched_issues
|
def test_filter_watched_issues
|
||||||
User.current = User.find(1)
|
User.current = User.find(1)
|
||||||
query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
|
query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
|
||||||
|
|
Loading…
Reference in New Issue