code layout clean up test_safe_attributes_should_accept_target_status_writable_fields of unit issue test

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10645 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-10-13 10:54:27 +00:00
parent 0cf44b976f
commit 0df2c4a975
1 changed files with 13 additions and 4 deletions

View File

@ -603,17 +603,26 @@ class IssueTest < ActiveSupport::TestCase
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')
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
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
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