@@ -33,7 +33,7 module MyHelper | |||||
33 |
|
33 | |||
34 | def issuesassignedtome_items |
|
34 | def issuesassignedtome_items | |
35 | Issue.visible.open. |
|
35 | Issue.visible.open. | |
36 | where(:assigned_to_id => ([User.current.id] + User.current.group_ids)). |
|
36 | assigned_to(User.current). | |
37 | limit(10). |
|
37 | limit(10). | |
38 | includes(:status, :project, :tracker, :priority). |
|
38 | includes(:status, :project, :tracker, :priority). | |
39 | references(:status, :project, :tracker, :priority). |
|
39 | references(:status, :project, :tracker, :priority). |
@@ -95,6 +95,13 class Issue < ActiveRecord::Base | |||||
95 | ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v} |
|
95 | ids = [versions].flatten.compact.map {|v| v.is_a?(Version) ? v.id : v} | |
96 | ids.any? ? where(:fixed_version_id => ids) : where('1=0') |
|
96 | ids.any? ? where(:fixed_version_id => ids) : where('1=0') | |
97 | } |
|
97 | } | |
|
98 | scope :assigned_to, lambda {|arg| | |||
|
99 | arg = Array(arg).uniq | |||
|
100 | ids = arg.map {|p| p.is_a?(Principal) ? p.id : p} | |||
|
101 | ids += arg.select {|p| p.is_a?(User)}.map(&:group_ids).flatten.uniq | |||
|
102 | ids.compact! | |||
|
103 | ids.any? ? where(:assigned_to_id => ids) : none | |||
|
104 | } | |||
98 |
|
105 | |||
99 | before_validation :clear_disabled_fields |
|
106 | before_validation :clear_disabled_fields | |
100 | before_create :default_assign |
|
107 | before_create :default_assign |
@@ -27,7 +27,7 | |||||
27 | <ul> |
|
27 | <ul> | |
28 | <li><%= link_to l(:label_assigned_issues), |
|
28 | <li><%= link_to l(:label_assigned_issues), | |
29 | issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') %>: |
|
29 | issues_path(:set_filter => 1, :assigned_to_id => 'me', :sort => 'priority:desc,updated_on:desc') %>: | |
30 |
<%= Issue.visible.open. |
|
30 | <%= Issue.visible.open.assigned_to(@user).count %> | |
31 | <li><%= link_to l(:label_reported_issues), |
|
31 | <li><%= link_to l(:label_reported_issues), | |
32 | issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>: |
|
32 | issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>: | |
33 | <%= Issue.visible.where(:author_id => @user.id).count %> |
|
33 | <%= Issue.visible.where(:author_id => @user.id).count %> |
@@ -418,6 +418,22 class IssueTest < ActiveSupport::TestCase | |||||
418 | assert_equal 0, Issue.fixed_version([]).count |
|
418 | assert_equal 0, Issue.fixed_version([]).count | |
419 | end |
|
419 | end | |
420 |
|
420 | |||
|
421 | def test_assigned_to_scope_should_return_issues_assigned_to_the_user | |||
|
422 | user = User.generate! | |||
|
423 | issue = Issue.generate! | |||
|
424 | Issue.where(:id => issue.id).update_all :assigned_to_id => user.id | |||
|
425 | assert_equal [issue], Issue.assigned_to(user).to_a | |||
|
426 | end | |||
|
427 | ||||
|
428 | def test_assigned_to_scope_should_return_issues_assigned_to_the_user_groups | |||
|
429 | group = Group.generate! | |||
|
430 | user = User.generate! | |||
|
431 | group.users << user | |||
|
432 | issue = Issue.generate! | |||
|
433 | Issue.where(:id => issue.id).update_all :assigned_to_id => group.id | |||
|
434 | assert_equal [issue], Issue.assigned_to(user).to_a | |||
|
435 | end | |||
|
436 | ||||
421 | def test_errors_full_messages_should_include_custom_fields_errors |
|
437 | def test_errors_full_messages_should_include_custom_fields_errors | |
422 | field = IssueCustomField.find_by_name('Database') |
|
438 | field = IssueCustomField.find_by_name('Database') | |
423 |
|
439 |
General Comments 0
You need to be logged in to leave comments.
Login now