def issuesassignedtome_items
Issue.visible.open.
- where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).
+ assigned_to(User.current).
limit(10).
includes(:status, :project, :tracker, :priority).
references(:status, :project, :tracker, :priority).
ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v}
ids.any? ? where(:fixed_version_id => ids) : where('1=0')
}
+ scope :assigned_to, lambda {|arg|
+ arg = Array(arg).uniq
+ ids = arg.map {|p| p.is_a?(Principal) ? p.id : p}
+ ids += arg.select {|p| p.is_a?(User)}.map(&:group_ids).flatten.uniq
+ ids.compact!
+ ids.any? ? where(:assigned_to_id => ids) : none
+ }
before_validation :clear_disabled_fields
before_create :default_assign
<ul>
<li><%= link_to l(:label_assigned_issues),
issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') %>:
- <%= Issue.visible.open.where(:assigned_to_id => ([@user.id] + @user.group_ids)).count %>
+ <%= Issue.visible.open.assigned_to(@user).count %>
<li><%= link_to l(:label_reported_issues),
issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>:
<%= Issue.visible.where(:author_id => @user.id).count %>
assert_equal 0, Issue.fixed_version([]).count
end
+ def test_assigned_to_scope_should_return_issues_assigned_to_the_user
+ user = User.generate!
+ issue = Issue.generate!
+ Issue.where(:id => issue.id).update_all :assigned_to_id => user.id
+ assert_equal [issue], Issue.assigned_to(user).to_a
+ end
+
+ def test_assigned_to_scope_should_return_issues_assigned_to_the_user_groups
+ group = Group.generate!
+ user = User.generate!
+ group.users << user
+ issue = Issue.generate!
+ Issue.where(:id => issue.id).update_all :assigned_to_id => group.id
+ assert_equal [issue], Issue.assigned_to(user).to_a
+ end
+
def test_errors_full_messages_should_include_custom_fields_errors
field = IssueCustomField.find_by_name('Database')