From 93daf6865ed5401bb6e5901a3e14bc2bd81a6812 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sat, 13 Oct 2012 10:55:09 +0000 Subject: [PATCH] code layout clean up test_required_attributes_should_be_validated of unit issue test git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10646 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/unit/issue_test.rb | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 048b208ce..e1d9dc5fc 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -628,26 +628,42 @@ class IssueTest < ActiveSupport::TestCase end def test_required_attributes_should_be_validated - cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :is_for_all => true, :tracker_ids => [1, 2]) + 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 => 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') + 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 + 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 + 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 + 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'}