Workflow enhancement: editable and required fields configurable by role, tracker and status (#703, #3521).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9977 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Vendored
+538
-269
File diff suppressed because it is too large
Load Diff
@@ -823,7 +823,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_show_should_display_update_form_with_minimal_permissions
|
||||
Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
|
||||
Workflow.delete_all :role_id => 1
|
||||
WorkflowTransition.delete_all :role_id => 1
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => 1
|
||||
@@ -1300,7 +1300,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_get_new_with_minimal_permissions
|
||||
Role.find(1).update_attribute :permissions, [:add_issues]
|
||||
Workflow.delete_all :role_id => 1
|
||||
WorkflowTransition.delete_all :role_id => 1
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1, :tracker_id => 1
|
||||
@@ -1426,6 +1426,50 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:attributes => {:name => 'issue[custom_field_values][2]', :value => 'Custom field value'}
|
||||
end
|
||||
|
||||
def test_get_new_should_mark_required_fields
|
||||
cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'label[for=issue_start_date]' do
|
||||
assert_select 'span[class=required]', 0
|
||||
end
|
||||
assert_select 'label[for=issue_due_date]' do
|
||||
assert_select 'span[class=required]'
|
||||
end
|
||||
assert_select 'label[for=?]', "issue_custom_field_values_#{cf1.id}" do
|
||||
assert_select 'span[class=required]', 0
|
||||
end
|
||||
assert_select 'label[for=?]', "issue_custom_field_values_#{cf2.id}" do
|
||||
assert_select 'span[class=required]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_new_should_not_display_readonly_fields
|
||||
cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_select 'input[name=?]', 'issue[start_date]'
|
||||
assert_select 'input[name=?]', 'issue[due_date]', 0
|
||||
assert_select 'input[name=?]', "issue[custom_field_values][#{cf1.id}]"
|
||||
assert_select 'input[name=?]', "issue[custom_field_values][#{cf2.id}]", 0
|
||||
end
|
||||
|
||||
def test_get_new_without_tracker_id
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
@@ -1463,7 +1507,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5}
|
||||
assert_response :success
|
||||
assert_template 'attributes'
|
||||
assert_template 'form'
|
||||
|
||||
issue = assigns(:issue)
|
||||
assert_kind_of Issue, issue
|
||||
@@ -1474,10 +1518,10 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_update_new_form_should_propose_transitions_based_on_initial_status
|
||||
@request.session[:user_id] = 2
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
|
||||
|
||||
xhr :post, :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 1,
|
||||
@@ -1678,6 +1722,58 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_error_tag :content => /Database can't be blank/
|
||||
end
|
||||
|
||||
def test_create_should_validate_required_fields
|
||||
cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'required')
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
post :create, :project_id => 1, :issue => {
|
||||
:tracker_id => 2,
|
||||
:status_id => 1,
|
||||
:subject => 'Test',
|
||||
:start_date => '',
|
||||
:due_date => '',
|
||||
:custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''}
|
||||
}
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
end
|
||||
|
||||
assert_error_tag :content => /Due date can't be blank/i
|
||||
assert_error_tag :content => /Bar can't be blank/i
|
||||
end
|
||||
|
||||
def test_create_should_ignore_readonly_fields
|
||||
cf1 = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
cf2 = IssueCustomField.create!(:name => 'Bar', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Issue.count' do
|
||||
post :create, :project_id => 1, :issue => {
|
||||
:tracker_id => 2,
|
||||
:status_id => 1,
|
||||
:subject => 'Test',
|
||||
:start_date => '2012-07-14',
|
||||
:due_date => '2012-07-16',
|
||||
:custom_field_values => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
issue = Issue.first(:order => 'id DESC')
|
||||
assert_equal Date.parse('2012-07-14'), issue.start_date
|
||||
assert_nil issue.due_date
|
||||
assert_equal 'value1', issue.custom_field_value(cf1)
|
||||
assert_nil issue.custom_field_value(cf2)
|
||||
end
|
||||
|
||||
def test_post_create_with_watchers
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@@ -1917,7 +2013,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
context "without workflow privilege" do
|
||||
setup do
|
||||
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
||||
WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
|
||||
Role.anonymous.add_permission! :add_issues, :add_issue_notes
|
||||
end
|
||||
|
||||
@@ -1976,9 +2072,9 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
context "with workflow privilege" do
|
||||
setup do
|
||||
Workflow.delete_all(["role_id = ?", Role.anonymous.id])
|
||||
Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
|
||||
Workflow.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
|
||||
WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
|
||||
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
|
||||
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
|
||||
Role.anonymous.add_permission! :add_issues, :add_issue_notes
|
||||
end
|
||||
|
||||
@@ -2286,7 +2382,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5}
|
||||
assert_response :success
|
||||
assert_template 'attributes'
|
||||
assert_template 'form'
|
||||
|
||||
issue = assigns(:issue)
|
||||
assert_kind_of Issue, issue
|
||||
@@ -2298,10 +2394,10 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_update_edit_form_should_propose_transitions_based_on_initial_status
|
||||
@request.session[:user_id] = 2
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
|
||||
|
||||
xhr :put, :new, :project_id => 1,
|
||||
:id => 2,
|
||||
@@ -2317,7 +2413,6 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2
|
||||
xhr :put, :new, :project_id => 1,
|
||||
:id => 1,
|
||||
:project_change => '1',
|
||||
:issue => {:project_id => 2,
|
||||
:tracker_id => 2,
|
||||
:subject => 'This is the test_new issue',
|
||||
@@ -2845,13 +2940,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_bulk_edit_should_only_propose_statuses_allowed_for_all_issues
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 1)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
|
||||
@request.session[:user_id] = 2
|
||||
get :bulk_edit, :ids => [1, 2]
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class RolesControllerTest < ActionController::TestCase
|
||||
assert_redirected_to '/roles'
|
||||
role = Role.find_by_name('RoleWithWorkflowCopy')
|
||||
assert_not_nil role
|
||||
assert_equal Role.find(1).workflows.size, role.workflows.size
|
||||
assert_equal Role.find(1).workflow_rules.size, role.workflow_rules.size
|
||||
end
|
||||
|
||||
def test_edit
|
||||
|
||||
@@ -66,7 +66,7 @@ class TrackersControllerTest < ActionController::TestCase
|
||||
assert_equal [1], tracker.project_ids.sort
|
||||
assert_equal Tracker::CORE_FIELDS, tracker.core_fields
|
||||
assert_equal [1, 6], tracker.custom_field_ids.sort
|
||||
assert_equal 0, tracker.workflows.count
|
||||
assert_equal 0, tracker.workflow_rules.count
|
||||
end
|
||||
|
||||
def create_with_disabled_core_fields
|
||||
@@ -86,7 +86,7 @@ class TrackersControllerTest < ActionController::TestCase
|
||||
assert_redirected_to :action => 'index'
|
||||
tracker = Tracker.find_by_name('New tracker')
|
||||
assert_equal 0, tracker.projects.count
|
||||
assert_equal Tracker.find(1).workflows.count, tracker.workflows.count
|
||||
assert_equal Tracker.find(1).workflow_rules.count, tracker.workflow_rules.count
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
|
||||
@@ -37,7 +37,7 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
|
||||
count = Workflow.count(:all, :conditions => 'role_id = 1 AND tracker_id = 2')
|
||||
count = WorkflowTransition.count(:all, :conditions => 'role_id = 1 AND tracker_id = 2')
|
||||
assert_tag :tag => 'a', :content => count.to_s,
|
||||
:attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' }
|
||||
end
|
||||
@@ -51,9 +51,9 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_get_edit_with_role_and_tracker
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||||
Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||||
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
|
||||
|
||||
get :edit, :role_id => 2, :tracker_id => 1
|
||||
assert_response :success
|
||||
@@ -79,7 +79,7 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
def test_get_edit_with_role_and_tracker_and_all_statuses
|
||||
Workflow.delete_all
|
||||
WorkflowTransition.delete_all
|
||||
|
||||
get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0'
|
||||
assert_response :success
|
||||
@@ -102,9 +102,9 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 3, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_not_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
assert_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4})
|
||||
assert_equal 3, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_not_nil WorkflowTransition.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
assert_nil WorkflowTransition.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
|
||||
@@ -115,27 +115,117 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
}
|
||||
assert_redirected_to '/workflows/edit?role_id=2&tracker_id=1'
|
||||
|
||||
assert_equal 4, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_equal 4, WorkflowTransition.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})
|
||||
w = WorkflowTransition.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})
|
||||
w = WorkflowTransition.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})
|
||||
w = WorkflowTransition.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})
|
||||
w = WorkflowTransition.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
|
||||
assert WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0
|
||||
|
||||
post :edit, :role_id => 2, :tracker_id => 1
|
||||
assert_equal 0, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_equal 0, WorkflowTransition.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
end
|
||||
|
||||
def test_get_permissions
|
||||
get :permissions
|
||||
|
||||
assert_response :success
|
||||
assert_template 'permissions'
|
||||
assert_not_nil assigns(:roles)
|
||||
assert_not_nil assigns(:trackers)
|
||||
end
|
||||
|
||||
def test_get_permissions_with_role_and_tracker
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'assigned_to_id', :rule => 'required')
|
||||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required')
|
||||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly')
|
||||
|
||||
get :permissions, :role_id => 1, :tracker_id => 2
|
||||
assert_response :success
|
||||
assert_template 'permissions'
|
||||
|
||||
assert_select 'input[name=role_id][value=1]'
|
||||
assert_select 'input[name=tracker_id][value=2]'
|
||||
|
||||
# Required field
|
||||
assert_select 'select[name=?]', 'permissions[assigned_to_id][2]' do
|
||||
assert_select 'option[value=]'
|
||||
assert_select 'option[value=][selected=selected]', 0
|
||||
assert_select 'option[value=readonly]', :text => 'Read-only'
|
||||
assert_select 'option[value=readonly][selected=selected]', 0
|
||||
assert_select 'option[value=required]', :text => 'Required'
|
||||
assert_select 'option[value=required][selected=selected]'
|
||||
end
|
||||
|
||||
# Read-only field
|
||||
assert_select 'select[name=?]', 'permissions[fixed_version_id][3]' do
|
||||
assert_select 'option[value=]'
|
||||
assert_select 'option[value=][selected=selected]', 0
|
||||
assert_select 'option[value=readonly]', :text => 'Read-only'
|
||||
assert_select 'option[value=readonly][selected=selected]'
|
||||
assert_select 'option[value=required]', :text => 'Required'
|
||||
assert_select 'option[value=required][selected=selected]', 0
|
||||
end
|
||||
|
||||
# Other field
|
||||
assert_select 'select[name=?]', 'permissions[due_date][3]' do
|
||||
assert_select 'option[value=]'
|
||||
assert_select 'option[value=][selected=selected]', 0
|
||||
assert_select 'option[value=readonly]', :text => 'Read-only'
|
||||
assert_select 'option[value=readonly][selected=selected]', 0
|
||||
assert_select 'option[value=required]', :text => 'Required'
|
||||
assert_select 'option[value=required][selected=selected]', 0
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_permissions
|
||||
WorkflowPermission.delete_all
|
||||
|
||||
post :permissions, :role_id => 1, :tracker_id => 2, :permissions => {
|
||||
'assigned_to_id' => {'1' => '', '2' => 'readonly', '3' => ''},
|
||||
'fixed_version_id' => {'1' => 'required', '2' => 'readonly', '3' => ''},
|
||||
'due_date' => {'1' => '', '2' => '', '3' => ''},
|
||||
}
|
||||
assert_redirected_to '/workflows/permissions?role_id=1&tracker_id=2'
|
||||
|
||||
workflows = WorkflowPermission.all
|
||||
assert_equal 3, workflows.size
|
||||
workflows.each do |workflow|
|
||||
assert_equal 1, workflow.role_id
|
||||
assert_equal 2, workflow.tracker_id
|
||||
end
|
||||
assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'assigned_to_id' && wf.rule == 'readonly'}
|
||||
assert workflows.detect {|wf| wf.old_status_id == 1 && wf.field_name == 'fixed_version_id' && wf.rule == 'required'}
|
||||
assert workflows.detect {|wf| wf.old_status_id == 2 && wf.field_name == 'fixed_version_id' && wf.rule == 'readonly'}
|
||||
end
|
||||
|
||||
def test_post_permissions_should_clear_permissions
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'assigned_to_id', :rule => 'required')
|
||||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required')
|
||||
wf1 = WorkflowPermission.create!(:role_id => 1, :tracker_id => 3, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required')
|
||||
wf2 = WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly')
|
||||
|
||||
post :permissions, :role_id => 1, :tracker_id => 2
|
||||
assert_redirected_to '/workflows/permissions?role_id=1&tracker_id=2'
|
||||
|
||||
workflows = WorkflowPermission.all
|
||||
assert_equal 2, workflows.size
|
||||
assert wf1.reload
|
||||
assert wf2.reload
|
||||
end
|
||||
|
||||
def test_get_copy
|
||||
@@ -192,7 +282,7 @@ class WorkflowsControllerTest < ActionController::TestCase
|
||||
|
||||
# Returns an array of status transitions that can be compared
|
||||
def status_transitions(conditions)
|
||||
Workflow.find(:all, :conditions => conditions,
|
||||
WorkflowTransition.find(:all, :conditions => conditions,
|
||||
:order => 'tracker_id, role_id, old_status_id, new_status_id').collect {|w| [w.old_status, w.new_status_id]}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,8 +36,8 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||
assert_difference 'IssueStatus.count', -1 do
|
||||
assert status.destroy
|
||||
end
|
||||
assert_nil Workflow.first(:conditions => {:old_status_id => status.id})
|
||||
assert_nil Workflow.first(:conditions => {:new_status_id => status.id})
|
||||
assert_nil WorkflowTransition.first(:conditions => {:old_status_id => status.id})
|
||||
assert_nil WorkflowTransition.first(:conditions => {:new_status_id => status.id})
|
||||
end
|
||||
|
||||
def test_destroy_status_in_use
|
||||
@@ -70,12 +70,12 @@ class IssueStatusTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_new_statuses_allowed_to
|
||||
Workflow.delete_all
|
||||
WorkflowTransition.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)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
|
||||
WorkflowTransition.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)
|
||||
|
||||
+171
-8
@@ -31,6 +31,10 @@ class IssueTest < ActiveSupport::TestCase
|
||||
|
||||
include Redmine::I18n
|
||||
|
||||
def teardown
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
|
||||
:status_id => 1, :priority => IssuePriority.all.first,
|
||||
@@ -362,12 +366,12 @@ class IssueTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_new_statuses_allowed_to
|
||||
Workflow.delete_all
|
||||
WorkflowTransition.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)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
|
||||
WorkflowTransition.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)
|
||||
@@ -390,7 +394,7 @@ class IssueTest < ActiveSupport::TestCase
|
||||
admin = User.find(1)
|
||||
issue = Issue.find(1)
|
||||
assert !admin.member_of?(issue.project)
|
||||
expected_statuses = [issue.status] + Workflow.find_all_by_old_status_id(issue.status_id).map(&:new_status).uniq.sort
|
||||
expected_statuses = [issue.status] + WorkflowTransition.find_all_by_old_status_id(issue.status_id).map(&:new_status).uniq.sort
|
||||
|
||||
assert_equal expected_statuses, issue.new_statuses_allowed_to(admin)
|
||||
end
|
||||
@@ -403,7 +407,7 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal [1, 2], issue.new_statuses_allowed_to(User.find(2)).map(&:id)
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_not_include_disabled_field
|
||||
def test_safe_attributes_names_should_not_include_disabled_field
|
||||
tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
|
||||
|
||||
issue = Issue.new(:tracker => tracker)
|
||||
@@ -435,7 +439,7 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal Date.parse('2012-07-14'), issue.due_date
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_accept_target_tracker_fields
|
||||
def test_safe_attributes_should_accept_target_tracker_enabled_fields
|
||||
source = Tracker.find(1)
|
||||
source.core_fields = []
|
||||
source.save!
|
||||
@@ -449,6 +453,165 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal Date.parse('2012-07-14'), issue.due_date
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_not_include_readonly_fields
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1)
|
||||
assert_equal %w(due_date), issue.read_only_attribute_names(user)
|
||||
assert_not_include 'due_date', issue.safe_attribute_names(user)
|
||||
|
||||
issue.send :safe_attributes=, {'start_date' => '2012-07-14', 'due_date' => '2012-07-14'}, user
|
||||
assert_equal Date.parse('2012-07-14'), issue.start_date
|
||||
assert_nil issue.due_date
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_not_include_readonly_custom_fields
|
||||
cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
|
||||
cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1])
|
||||
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1)
|
||||
assert_equal [cf2.id.to_s], issue.read_only_attribute_names(user)
|
||||
assert_not_include cf2.id.to_s, issue.safe_attribute_names(user)
|
||||
|
||||
issue.send :safe_attributes=, {'custom_field_values' => {cf1.id.to_s => 'value1', cf2.id.to_s => 'value2'}}, user
|
||||
assert_equal 'value1', issue.custom_field_value(cf1)
|
||||
assert_nil issue.custom_field_value(cf2)
|
||||
|
||||
issue.send :safe_attributes=, {'custom_fields' => [{'id' => cf1.id.to_s, 'value' => 'valuea'}, {'id' => cf2.id.to_s, 'value' => 'valueb'}]}, user
|
||||
assert_equal 'valuea', issue.custom_field_value(cf1)
|
||||
assert_nil issue.custom_field_value(cf2)
|
||||
end
|
||||
|
||||
def test_editable_custom_field_values_should_return_non_readonly_custom_values
|
||||
cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
cf2 = IssueCustomField.create!(:name => 'Readonly field', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf2.id.to_s, :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1)
|
||||
values = issue.editable_custom_field_values(user)
|
||||
assert values.detect {|value| value.custom_field == cf1}
|
||||
assert_nil values.detect {|value| value.custom_field == cf2}
|
||||
|
||||
issue.tracker_id = 2
|
||||
values = issue.editable_custom_field_values(user)
|
||||
assert values.detect {|value| value.custom_field == cf1}
|
||||
assert values.detect {|value| value.custom_field == cf2}
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_accept_target_tracker_writable_fields
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
|
||||
|
||||
issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
|
||||
assert_equal Date.parse('2012-07-12'), issue.start_date
|
||||
assert_nil issue.due_date
|
||||
|
||||
issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'tracker_id' => 2}, user
|
||||
assert_equal Date.parse('2012-07-12'), issue.start_date
|
||||
assert_equal Date.parse('2012-07-16'), issue.due_date
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_accept_target_status_writable_fields
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
WorkflowPermission.create!(:old_status_id => 2, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
|
||||
|
||||
issue.send :safe_attributes=, {'start_date' => '2012-07-12', 'due_date' => '2012-07-14'}, user
|
||||
assert_equal Date.parse('2012-07-12'), issue.start_date
|
||||
assert_nil issue.due_date
|
||||
|
||||
issue.send :safe_attributes=, {'start_date' => '2012-07-15', 'due_date' => '2012-07-16', 'status_id' => 2}, user
|
||||
assert_equal Date.parse('2012-07-12'), issue.start_date
|
||||
assert_equal Date.parse('2012-07-16'), issue.due_date
|
||||
end
|
||||
|
||||
def test_required_attributes_should_be_validated
|
||||
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2])
|
||||
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'category_id', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
|
||||
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => 'start_date', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required')
|
||||
user = User.find(2)
|
||||
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, :subject => 'Required fields', :author => user)
|
||||
assert_equal [cf.id.to_s, "category_id", "due_date"], issue.required_attribute_names(user).sort
|
||||
assert !issue.save, "Issue was saved"
|
||||
assert_equal ["Category can't be blank", "Due date can't be blank", "Foo can't be blank"], issue.errors.full_messages.sort
|
||||
|
||||
issue.tracker_id = 2
|
||||
assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort
|
||||
assert !issue.save, "Issue was saved"
|
||||
assert_equal ["Foo can't be blank", "Start date can't be blank"], issue.errors.full_messages.sort
|
||||
|
||||
issue.start_date = Date.today
|
||||
issue.custom_field_values = {cf.id.to_s => 'bar'}
|
||||
assert issue.save
|
||||
end
|
||||
|
||||
def test_required_attribute_names_for_multiple_roles_should_intersect_rules
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'required')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'required')
|
||||
user = User.find(2)
|
||||
member = Member.find(1)
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
|
||||
|
||||
assert_equal %w(due_date start_date), issue.required_attribute_names(user).sort
|
||||
|
||||
member.role_ids = [1, 2]
|
||||
member.save!
|
||||
assert_equal [], issue.required_attribute_names(user.reload)
|
||||
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'required')
|
||||
assert_equal %w(due_date), issue.required_attribute_names(user)
|
||||
|
||||
member.role_ids = [1, 2, 3]
|
||||
member.save!
|
||||
assert_equal [], issue.required_attribute_names(user.reload)
|
||||
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
|
||||
# required + readonly => required
|
||||
assert_equal %w(due_date), issue.required_attribute_names(user)
|
||||
end
|
||||
|
||||
def test_read_only_attribute_names_for_multiple_roles_should_intersect_rules
|
||||
WorkflowPermission.delete_all
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'due_date', :rule => 'readonly')
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'start_date', :rule => 'readonly')
|
||||
user = User.find(2)
|
||||
member = Member.find(1)
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1)
|
||||
|
||||
assert_equal %w(due_date start_date), issue.read_only_attribute_names(user).sort
|
||||
|
||||
member.role_ids = [1, 2]
|
||||
member.save!
|
||||
assert_equal [], issue.read_only_attribute_names(user.reload)
|
||||
|
||||
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 2, :field_name => 'due_date', :rule => 'readonly')
|
||||
assert_equal %w(due_date), issue.read_only_attribute_names(user)
|
||||
end
|
||||
|
||||
def test_copy
|
||||
issue = Issue.new.copy_from(1)
|
||||
assert issue.copy?
|
||||
|
||||
@@ -35,13 +35,13 @@ class RoleTest < ActiveSupport::TestCase
|
||||
|
||||
def test_copy_workflows
|
||||
source = Role.find(1)
|
||||
assert_equal 90, source.workflows.size
|
||||
assert_equal 90, source.workflow_rules.size
|
||||
|
||||
target = Role.new(:name => 'Target')
|
||||
assert target.save
|
||||
target.workflows.copy(source)
|
||||
target.workflow_rules.copy(source)
|
||||
target.reload
|
||||
assert_equal 90, target.workflows.size
|
||||
assert_equal 90, target.workflow_rules.size
|
||||
end
|
||||
|
||||
def test_permissions_should_be_unserialized_with_its_coder
|
||||
|
||||
@@ -30,20 +30,20 @@ class TrackerTest < ActiveSupport::TestCase
|
||||
|
||||
def test_copy_workflows
|
||||
source = Tracker.find(1)
|
||||
assert_equal 89, source.workflows.size
|
||||
assert_equal 89, source.workflow_rules.size
|
||||
|
||||
target = Tracker.new(:name => 'Target')
|
||||
assert target.save
|
||||
target.workflows.copy(source)
|
||||
target.workflow_rules.copy(source)
|
||||
target.reload
|
||||
assert_equal 89, target.workflows.size
|
||||
assert_equal 89, target.workflow_rules.size
|
||||
end
|
||||
|
||||
def test_issue_statuses
|
||||
tracker = Tracker.find(1)
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||||
Workflow.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||||
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
|
||||
|
||||
assert_kind_of Array, tracker.issue_statuses
|
||||
assert_kind_of IssueStatus, tracker.issue_statuses.first
|
||||
@@ -51,7 +51,7 @@ class TrackerTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def test_issue_statuses_empty
|
||||
Workflow.delete_all("tracker_id = 1")
|
||||
WorkflowTransition.delete_all("tracker_id = 1")
|
||||
assert_equal [], Tracker.find(1).issue_statuses
|
||||
end
|
||||
|
||||
|
||||
@@ -21,17 +21,45 @@ class WorkflowTest < ActiveSupport::TestCase
|
||||
fixtures :roles, :trackers, :issue_statuses
|
||||
|
||||
def test_copy
|
||||
Workflow.delete_all
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 2)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 3, :assignee => true)
|
||||
Workflow.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 4, :author => true)
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 2)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 3, :assignee => true)
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 4, :author => true)
|
||||
|
||||
assert_difference 'Workflow.count', 3 do
|
||||
Workflow.copy(Tracker.find(2), Role.find(1), Tracker.find(3), Role.find(2))
|
||||
assert_difference 'WorkflowTransition.count', 3 do
|
||||
WorkflowTransition.copy(Tracker.find(2), Role.find(1), Tracker.find(3), Role.find(2))
|
||||
end
|
||||
|
||||
assert Workflow.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false})
|
||||
assert Workflow.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true})
|
||||
assert Workflow.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false})
|
||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false})
|
||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 3, :author => false, :assignee => true})
|
||||
assert WorkflowTransition.first(:conditions => {:role_id => 2, :tracker_id => 3, :old_status_id => 1, :new_status_id => 4, :author => true, :assignee => false})
|
||||
end
|
||||
|
||||
def test_workflow_permission_should_validate_rule
|
||||
wp = WorkflowPermission.new(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :field_name => 'due_date')
|
||||
assert !wp.save
|
||||
|
||||
wp.rule = 'foo'
|
||||
assert !wp.save
|
||||
|
||||
wp.rule = 'required'
|
||||
assert wp.save
|
||||
|
||||
wp.rule = 'readonly'
|
||||
assert wp.save
|
||||
end
|
||||
|
||||
def test_workflow_permission_should_validate_field_name
|
||||
wp = WorkflowPermission.new(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :rule => 'required')
|
||||
assert !wp.save
|
||||
|
||||
wp.field_name = 'foo'
|
||||
assert !wp.save
|
||||
|
||||
wp.field_name = 'due_date'
|
||||
assert wp.save
|
||||
|
||||
wp.field_name = '1'
|
||||
assert wp.save
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user