@@ -628,26 +628,42 class IssueTest < ActiveSupport::TestCase | |||
|
628 | 628 | end |
|
629 | 629 | |
|
630 | 630 | def test_required_attributes_should_be_validated |
|
631 |
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', |
|
|
631 | cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', | |
|
632 | :is_for_all => true, :tracker_ids => [1, 2]) | |
|
632 | 633 | |
|
633 | 634 | WorkflowPermission.delete_all |
|
634 |
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, |
|
|
635 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => 'category_id', :rule => 'required') | |
|
636 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required') | |
|
635 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
636 | :role_id => 1, :field_name => 'due_date', | |
|
637 | :rule => 'required') | |
|
638 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
639 | :role_id => 1, :field_name => 'category_id', | |
|
640 | :rule => 'required') | |
|
641 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
642 | :role_id => 1, :field_name => cf.id.to_s, | |
|
643 | :rule => 'required') | |
|
637 | 644 | |
|
638 |
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, |
|
|
639 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required') | |
|
645 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, | |
|
646 | :role_id => 1, :field_name => 'start_date', | |
|
647 | :rule => 'required') | |
|
648 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 2, | |
|
649 | :role_id => 1, :field_name => cf.id.to_s, | |
|
650 | :rule => 'required') | |
|
640 | 651 | user = User.find(2) |
|
641 | 652 | |
|
642 |
issue = Issue.new(:project_id => 1, :tracker_id => 1, |
|
|
643 | assert_equal [cf.id.to_s, "category_id", "due_date"], issue.required_attribute_names(user).sort | |
|
653 | issue = Issue.new(:project_id => 1, :tracker_id => 1, | |
|
654 | :status_id => 1, :subject => 'Required fields', | |
|
655 | :author => user) | |
|
656 | assert_equal [cf.id.to_s, "category_id", "due_date"], | |
|
657 | issue.required_attribute_names(user).sort | |
|
644 | 658 | assert !issue.save, "Issue was saved" |
|
645 |
assert_equal ["Category can't be blank", "Due date can't be blank", "Foo can't be blank"], |
|
|
659 | assert_equal ["Category can't be blank", "Due date can't be blank", "Foo can't be blank"], | |
|
660 | issue.errors.full_messages.sort | |
|
646 | 661 | |
|
647 | 662 | issue.tracker_id = 2 |
|
648 | 663 | assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort |
|
649 | 664 | assert !issue.save, "Issue was saved" |
|
650 |
assert_equal ["Foo can't be blank", "Start date can't be blank"], |
|
|
665 | assert_equal ["Foo can't be blank", "Start date can't be blank"], | |
|
666 | issue.errors.full_messages.sort | |
|
651 | 667 | |
|
652 | 668 | issue.start_date = Date.today |
|
653 | 669 | issue.custom_field_values = {cf.id.to_s => 'bar'} |
General Comments 0
You need to be logged in to leave comments.
Login now