Allow additional workflow transitions for issue author and assignee (#2732).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4895 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Vendored
+16
-10
@@ -1,31 +1,37 @@
|
||||
---
|
||||
issue_statuses_006:
|
||||
name: Rejected
|
||||
is_default: false
|
||||
is_closed: true
|
||||
id: 6
|
||||
issue_statuses_001:
|
||||
id: 1
|
||||
name: New
|
||||
is_default: true
|
||||
is_closed: false
|
||||
id: 1
|
||||
position: 1
|
||||
issue_statuses_002:
|
||||
id: 2
|
||||
name: Assigned
|
||||
is_default: false
|
||||
is_closed: false
|
||||
id: 2
|
||||
position: 2
|
||||
issue_statuses_003:
|
||||
id: 3
|
||||
name: Resolved
|
||||
is_default: false
|
||||
is_closed: false
|
||||
id: 3
|
||||
position: 3
|
||||
issue_statuses_004:
|
||||
name: Feedback
|
||||
id: 4
|
||||
is_default: false
|
||||
is_closed: false
|
||||
id: 4
|
||||
position: 4
|
||||
issue_statuses_005:
|
||||
id: 5
|
||||
name: Closed
|
||||
is_default: false
|
||||
is_closed: true
|
||||
id: 5
|
||||
position: 5
|
||||
issue_statuses_006:
|
||||
id: 6
|
||||
name: Rejected
|
||||
is_default: false
|
||||
is_closed: true
|
||||
position: 6
|
||||
|
||||
@@ -65,17 +65,17 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
|
||||
# allowed transitions
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[3][]',
|
||||
:value => '5',
|
||||
:name => 'issue_status[3][5][]',
|
||||
:value => 'always',
|
||||
:checked => 'checked' }
|
||||
# not allowed
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[3][]',
|
||||
:value => '2',
|
||||
:name => 'issue_status[3][2][]',
|
||||
:value => 'always',
|
||||
:checked => nil }
|
||||
# unused
|
||||
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[4][]' }
|
||||
:name => 'issue_status[1][1][]' }
|
||||
end
|
||||
|
||||
def test_get_edit_with_role_and_tracker_and_all_statuses
|
||||
@@ -89,13 +89,17 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
assert_equal IssueStatus.count, assigns(:statuses).size
|
||||
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[1][]',
|
||||
:value => '1',
|
||||
:name => 'issue_status[1][1][]',
|
||||
:value => 'always',
|
||||
:checked => nil }
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
post :edit, :role_id => 2, :tracker_id => 1, :issue_status => {'4' => ['5'], '3' => ['1', '2']}
|
||||
post :edit, :role_id => 2, :tracker_id => 1,
|
||||
:issue_status => {
|
||||
'4' => {'5' => ['always']},
|
||||
'3' => {'1' => ['always'], '2' => ['always']}
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 3, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
@@ -103,6 +107,30 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
assert_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4})
|
||||
end
|
||||
|
||||
def test_post_edit_with_additional_transitions
|
||||
post :edit, :role_id => 2, :tracker_id => 1,
|
||||
:issue_status => {
|
||||
'4' => {'5' => ['always']},
|
||||
'3' => {'1' => ['author'], '2' => ['assignee'], '4' => ['author', 'assignee']}
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 4, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
|
||||
w = Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 4, :new_status_id => 5})
|
||||
assert ! w.author
|
||||
assert ! w.assignee
|
||||
w = Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 1})
|
||||
assert w.author
|
||||
assert ! w.assignee
|
||||
w = Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
assert ! w.author
|
||||
assert w.assignee
|
||||
w = Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 4})
|
||||
assert w.author
|
||||
assert w.assignee
|
||||
end
|
||||
|
||||
def test_clear_workflow
|
||||
assert Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssueStatusTest < ActiveSupport::TestCase
|
||||
fixtures :issue_statuses, :issues
|
||||
fixtures :issue_statuses, :issues, :roles, :trackers
|
||||
|
||||
def test_create
|
||||
status = IssueStatus.new :name => "Assigned"
|
||||
@@ -68,6 +68,30 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||
status.reload
|
||||
assert status.is_default?
|
||||
end
|
||||
|
||||
def test_new_statuses_allowed_to
|
||||
Workflow.delete_all
|
||||
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
|
||||
status = IssueStatus.find(1)
|
||||
role = Role.find(1)
|
||||
tracker = Tracker.find(1)
|
||||
|
||||
assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id)
|
||||
assert_equal [2], status.find_new_statuses_allowed_to([role], tracker, false, false).map(&:id)
|
||||
|
||||
assert_equal [2, 3], status.new_statuses_allowed_to([role], tracker, true, false).map(&:id)
|
||||
assert_equal [2, 3], status.find_new_statuses_allowed_to([role], tracker, true, false).map(&:id)
|
||||
|
||||
assert_equal [2, 4], status.new_statuses_allowed_to([role], tracker, false, true).map(&:id)
|
||||
assert_equal [2, 4], status.find_new_statuses_allowed_to([role], tracker, false, true).map(&:id)
|
||||
|
||||
assert_equal [2, 3, 4, 5], status.new_statuses_allowed_to([role], tracker, true, true).map(&:id)
|
||||
assert_equal [2, 3, 4, 5], status.find_new_statuses_allowed_to([role], tracker, true, true).map(&:id)
|
||||
end
|
||||
|
||||
context "#update_done_ratios" do
|
||||
setup do
|
||||
|
||||
@@ -210,6 +210,33 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
|
||||
end
|
||||
|
||||
|
||||
|
||||
def test_new_statuses_allowed_to
|
||||
Workflow.delete_all
|
||||
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
|
||||
status = IssueStatus.find(1)
|
||||
role = Role.find(1)
|
||||
tracker = Tracker.find(1)
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1)
|
||||
assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
|
||||
|
||||
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
|
||||
assert_equal [1, 2, 3], issue.new_statuses_allowed_to(user).map(&:id)
|
||||
|
||||
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :assigned_to => user)
|
||||
assert_equal [1, 2, 4], issue.new_statuses_allowed_to(user).map(&:id)
|
||||
|
||||
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
|
||||
assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
|
||||
end
|
||||
|
||||
def test_copy
|
||||
issue = Issue.new.copy_from(1)
|
||||
assert issue.save
|
||||
|
||||
Reference in New Issue
Block a user