@@ -628,26 +628,42 class IssueTest < ActiveSupport::TestCase | |||||
628 | end |
|
628 | end | |
629 |
|
629 | |||
630 | def test_required_attributes_should_be_validated |
|
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 | WorkflowPermission.delete_all |
|
634 | WorkflowPermission.delete_all | |
634 |
WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, |
|
635 | 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 | :role_id => 1, :field_name => 'due_date', | |
636 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, :role_id => 1, :field_name => cf.id.to_s, :rule => 'required') |
|
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, |
|
645 | 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') |
|
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 | user = User.find(2) |
|
651 | user = User.find(2) | |
641 |
|
652 | |||
642 |
issue = Issue.new(:project_id => 1, :tracker_id => 1, |
|
653 | 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 |
|
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 | assert !issue.save, "Issue was saved" |
|
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 | issue.tracker_id = 2 |
|
662 | issue.tracker_id = 2 | |
648 | assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort |
|
663 | assert_equal [cf.id.to_s, "start_date"], issue.required_attribute_names(user).sort | |
649 | assert !issue.save, "Issue was saved" |
|
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 | issue.start_date = Date.today |
|
668 | issue.start_date = Date.today | |
653 | issue.custom_field_values = {cf.id.to_s => 'bar'} |
|
669 | issue.custom_field_values = {cf.id.to_s => 'bar'} |
General Comments 0
You need to be logged in to leave comments.
Login now