3427 |
3427 |
r = Issue.like('issue today')
|
3428 |
3428 |
assert_include Issue.find(7), r
|
3429 |
3429 |
end
|
|
3430 |
|
|
3431 |
def test_copy_issue_should_copy_only_editable_attributes
|
|
3432 |
User.current = User.find(2)
|
|
3433 |
issue_orig = Issue.find(11)
|
|
3434 |
cf = IssueCustomField.find(6)
|
|
3435 |
cv = CustomValue.create!(:custom_field => cf, :customized => issue_orig, :value => 12.34)
|
|
3436 |
|
|
3437 |
WorkflowPermission.delete_all
|
|
3438 |
# status new
|
|
3439 |
WorkflowPermission.create!(:role_id => 1, :tracker_id => 1,
|
|
3440 |
:old_status_id => 1,
|
|
3441 |
:author => false, :assignee => false,
|
|
3442 |
:field_name => 'fixed_version_id', :rule => 'readonly')
|
|
3443 |
WorkflowPermission.create!(:role_id => 1, :tracker_id => 1,
|
|
3444 |
:old_status_id => 1,
|
|
3445 |
:author => false, :assignee => false,
|
|
3446 |
:field_name => cf.id, :rule => 'readonly')
|
|
3447 |
# closed
|
|
3448 |
WorkflowPermission.create!(:role_id => 1, :tracker_id => 1,
|
|
3449 |
:old_status_id => 5,
|
|
3450 |
:author => false, :assignee => false,
|
|
3451 |
:field_name => 'fixed_version_id', :rule => 'readonly')
|
|
3452 |
WorkflowPermission.create!(:role_id => 1, :tracker_id => 1,
|
|
3453 |
:old_status_id => 5,
|
|
3454 |
:author => false, :assignee => false,
|
|
3455 |
:field_name => cf.id, :rule => 'readonly')
|
|
3456 |
|
|
3457 |
# user cannot change field
|
|
3458 |
assert_not issue_orig.safe_attribute?('fixed_version_id')
|
|
3459 |
assert_not_nil issue_orig.fixed_version_id
|
|
3460 |
# cf_6 is read only
|
|
3461 |
assert issue_orig.read_only_attribute_names(User.current).include?(cf.id.to_s)
|
|
3462 |
assert_equal cv.to_s, issue_orig.custom_field_value(cf.id)
|
|
3463 |
|
|
3464 |
issue_copy = Issue.new.copy_from issue_orig
|
|
3465 |
# field was not copied
|
|
3466 |
assert_nil issue_copy.fixed_version_id
|
|
3467 |
assert_empty issue_copy.custom_field_value(cf.id)
|
|
3468 |
# still can't change field
|
|
3469 |
assert_not issue_copy.safe_attribute?('fixed_version_id')
|
|
3470 |
assert issue_copy.read_only_attribute_names(User.current).include?(cf.id.to_s)
|
|
3471 |
end
|
|
3472 |
|
|
3473 |
def test_copy_issue_from_should_ignore_disabled_rules_for_project_and_tracker
|
|
3474 |
User.current = User.find(2)
|
|
3475 |
source_issue = Issue.find(1)
|
|
3476 |
icf = IssueCustomField.generate!(:tracker_ids => [1], :visible => true, :role_ids => [1], :is_for_all => false, :project_ids => [1])
|
|
3477 |
|
|
3478 |
# Disable changing Project for role Manager
|
|
3479 |
WorkflowPermission.create!(:role_id => 1, :tracker_id => 1,
|
|
3480 |
:old_status_id => 1,
|
|
3481 |
:author => false, :assignee => false,
|
|
3482 |
:field_name => 'project_id', :rule => 'readonly')
|
|
3483 |
|
|
3484 |
CustomValue.create!(:custom_field => icf, :customized => source_issue, :value => 'test string')
|
|
3485 |
|
|
3486 |
|
|
3487 |
new_issue = Issue.new.copy_from(source_issue)
|
|
3488 |
# custom values were copied
|
|
3489 |
assert_not_empty new_issue.custom_field_values
|
|
3490 |
# copied values are equal
|
|
3491 |
assert_equal source_issue.custom_field_value(icf.id), new_issue.custom_field_value(icf.id)
|
|
3492 |
end
|
3430 |
3493 |
end
|