@@ -756,12 +756,16 class Issue < ActiveRecord::Base | |||
|
756 | 756 | initial_status = IssueStatus.find_by_id(status_id_was) |
|
757 | 757 | end |
|
758 | 758 | initial_status ||= status |
|
759 | ||
|
759 | ||
|
760 | initial_assigned_to_id = assigned_to_id_changed? ? assigned_to_id_was : assigned_to_id | |
|
761 | assignee_transitions_allowed = initial_assigned_to_id.present? && | |
|
762 | (user.id == initial_assigned_to_id || user.group_ids.include?(initial_assigned_to_id)) | |
|
763 | ||
|
760 | 764 | statuses = initial_status.find_new_statuses_allowed_to( |
|
761 | 765 | user.admin ? Role.all : user.roles_for_project(project), |
|
762 | 766 | tracker, |
|
763 | 767 | author == user, |
|
764 | assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id | |
|
768 | assignee_transitions_allowed | |
|
765 | 769 | ) |
|
766 | 770 | statuses << initial_status unless statuses.empty? |
|
767 | 771 | statuses << IssueStatus.default if include_default |
@@ -509,9 +509,9 class IssueTest < ActiveSupport::TestCase | |||
|
509 | 509 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
510 | 510 | :old_status_id => 1, :new_status_id => 3, |
|
511 | 511 | :author => true, :assignee => false) |
|
512 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
|
513 |
:new_status_id => 4, |
|
|
514 | :assignee => true) | |
|
512 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, | |
|
513 | :old_status_id => 1, :new_status_id => 4, | |
|
514 | :author => false, :assignee => true) | |
|
515 | 515 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, |
|
516 | 516 | :old_status_id => 1, :new_status_id => 5, |
|
517 | 517 | :author => true, :assignee => true) |
@@ -537,6 +537,26 class IssueTest < ActiveSupport::TestCase | |||
|
537 | 537 | :project_id => 1, :author => user, |
|
538 | 538 | :assigned_to => user) |
|
539 | 539 | assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id) |
|
540 | ||
|
541 | group = Group.generate! | |
|
542 | group.users << user | |
|
543 | issue = Issue.generate!(:tracker => tracker, :status => status, | |
|
544 | :project_id => 1, :author => user, | |
|
545 | :assigned_to => group) | |
|
546 | assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id) | |
|
547 | end | |
|
548 | ||
|
549 | def test_new_statuses_allowed_to_should_consider_group_assignment | |
|
550 | WorkflowTransition.delete_all | |
|
551 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, | |
|
552 | :old_status_id => 1, :new_status_id => 4, | |
|
553 | :author => false, :assignee => true) | |
|
554 | user = User.find(2) | |
|
555 | group = Group.generate! | |
|
556 | group.users << user | |
|
557 | ||
|
558 | issue = Issue.generate!(:author_id => 1, :assigned_to => group) | |
|
559 | assert_include 4, issue.new_statuses_allowed_to(user).map(&:id) | |
|
540 | 560 | end |
|
541 | 561 | |
|
542 | 562 | 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