# "me" value subsitution
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
if field =~ /^cf_(\d+)$/
-<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,
- :conditions => {:assigned_to_id => User.current.id},
+ :conditions => {:assigned_to_id => ([User.current.id] + User.current.group_ids)},
:limit => 10,
:include => [ :status, :project, :tracker, :priority ],
:order => "#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC") %>
find_issues_with_query(query)
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
User.current = User.find(1)
query = Query.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})