@@ -745,11 +745,15 class Issue < ActiveRecord::Base | |||
|
745 | 745 | end |
|
746 | 746 | initial_status ||= status |
|
747 | 747 | |
|
748 | initial_assigned_to_id = assigned_to_id_changed? ? assigned_to_id_was : assigned_to_id | |
|
749 | assignee_transitions_allowed = initial_assigned_to_id.present? && | |
|
750 | (user.id == initial_assigned_to_id || user.group_ids.include?(initial_assigned_to_id)) | |
|
751 | ||
|
748 | 752 | statuses = initial_status.find_new_statuses_allowed_to( |
|
749 | 753 | user.admin ? Role.all : user.roles_for_project(project), |
|
750 | 754 | tracker, |
|
751 | 755 | author == user, |
|
752 | assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id | |
|
756 | assignee_transitions_allowed | |
|
753 | 757 | ) |
|
754 | 758 | statuses << initial_status unless statuses.empty? |
|
755 | 759 | statuses << IssueStatus.default if include_default |
@@ -488,9 +488,9 class IssueTest < ActiveSupport::TestCase | |||
|
488 | 488 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
489 | 489 | :old_status_id => 1, :new_status_id => 3, |
|
490 | 490 | :author => true, :assignee => false) |
|
491 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
|
492 |
:new_status_id => 4, |
|
|
493 | :assignee => true) | |
|
491 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, | |
|
492 | :old_status_id => 1, :new_status_id => 4, | |
|
493 | :author => false, :assignee => true) | |
|
494 | 494 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
495 | 495 | :old_status_id => 1, :new_status_id => 5, |
|
496 | 496 | :author => true, :assignee => true) |
@@ -516,6 +516,26 class IssueTest < ActiveSupport::TestCase | |||
|
516 | 516 | :project_id => 1, :author => user, |
|
517 | 517 | :assigned_to => user) |
|
518 | 518 | assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id) |
|
519 | ||
|
520 | group = Group.generate! | |
|
521 | group.users << user | |
|
522 | issue = Issue.generate!(:tracker => tracker, :status => status, | |
|
523 | :project_id => 1, :author => user, | |
|
524 | :assigned_to => group) | |
|
525 | assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id) | |
|
526 | end | |
|
527 | ||
|
528 | def test_new_statuses_allowed_to_should_consider_group_assignment | |
|
529 | WorkflowTransition.delete_all | |
|
530 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, | |
|
531 | :old_status_id => 1, :new_status_id => 4, | |
|
532 | :author => false, :assignee => true) | |
|
533 | user = User.find(2) | |
|
534 | group = Group.generate! | |
|
535 | group.users << user | |
|
536 | ||
|
537 | issue = Issue.generate!(:author_id => 1, :assigned_to => group) | |
|
538 | assert_include 4, issue.new_statuses_allowed_to(user).map(&:id) | |
|
519 | 539 | end |
|
520 | 540 | |
|
521 | 541 | def test_new_statuses_allowed_to_should_return_all_transitions_for_admin |
General Comments 0
You need to be logged in to leave comments.
Login now