mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-22 16:31:12 +00:00
Adds a scope to get issues assigned to a user.
git-svn-id: http://svn.redmine.org/redmine/trunk@14720 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d6c6c7ac62
commit
8160f2addb
@ -33,7 +33,7 @@ module MyHelper
|
|||||||
|
|
||||||
def issuesassignedtome_items
|
def issuesassignedtome_items
|
||||||
Issue.visible.open.
|
Issue.visible.open.
|
||||||
where(:assigned_to_id => ([User.current.id] + User.current.group_ids)).
|
assigned_to(User.current).
|
||||||
limit(10).
|
limit(10).
|
||||||
includes(:status, :project, :tracker, :priority).
|
includes(:status, :project, :tracker, :priority).
|
||||||
references(:status, :project, :tracker, :priority).
|
references(:status, :project, :tracker, :priority).
|
||||||
|
|||||||
@ -95,6 +95,13 @@ class Issue < ActiveRecord::Base
|
|||||||
ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v}
|
ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v}
|
||||||
ids.any? ? where(:fixed_version_id => ids) : where('1=0')
|
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_validation :clear_disabled_fields
|
||||||
before_create :default_assign
|
before_create :default_assign
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><%= link_to l(:label_assigned_issues),
|
<li><%= link_to l(:label_assigned_issues),
|
||||||
issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') %>:
|
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),
|
<li><%= link_to l(:label_reported_issues),
|
||||||
issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>:
|
issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>:
|
||||||
<%= Issue.visible.where(:author_id => @user.id).count %>
|
<%= Issue.visible.where(:author_id => @user.id).count %>
|
||||||
|
|||||||
@ -418,6 +418,22 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal 0, Issue.fixed_version([]).count
|
assert_equal 0, Issue.fixed_version([]).count
|
||||||
end
|
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
|
def test_errors_full_messages_should_include_custom_fields_errors
|
||||||
field = IssueCustomField.find_by_name('Database')
|
field = IssueCustomField.find_by_name('Database')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user