adjust functional IssuesControllerTest (#1005)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11887 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2013-05-19 03:40:22 +00:00
parent b3a6555b30
commit dbc7369d9d
1 changed files with 20 additions and 19 deletions

View File

@ -2449,12 +2449,12 @@ class IssuesControllerTest < ActionController::TestCase
issue = Issue.find(3) issue = Issue.find(3)
count = issue.attachments.count count = issue.attachments.count
assert count > 0 assert count > 0
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
assert_difference 'Attachment.count', count do assert_difference 'Attachment.count', count do
assert_no_difference 'Journal.count' do assert_difference 'Journal.count', 2 do
post :create, :project_id => 1, :copy_from => 3, post :create, :project_id => 1, :copy_from => 3,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}, :issue => {:project_id => '1', :tracker_id => '3',
:status_id => '1', :subject => 'Copy with attachments'},
:copy_attachments => '1' :copy_attachments => '1'
end end
end end
@ -2469,12 +2469,12 @@ class IssuesControllerTest < ActionController::TestCase
issue = Issue.find(3) issue = Issue.find(3)
count = issue.attachments.count count = issue.attachments.count
assert count > 0 assert count > 0
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
assert_no_difference 'Attachment.count' do assert_no_difference 'Attachment.count' do
assert_no_difference 'Journal.count' do assert_difference 'Journal.count', 2 do
post :create, :project_id => 1, :copy_from => 3, post :create, :project_id => 1, :copy_from => 3,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'} :issue => {:project_id => '1', :tracker_id => '3',
:status_id => '1', :subject => 'Copy with attachments'}
end end
end end
end end
@ -2487,14 +2487,16 @@ class IssuesControllerTest < ActionController::TestCase
issue = Issue.find(3) issue = Issue.find(3)
count = issue.attachments.count count = issue.attachments.count
assert count > 0 assert count > 0
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
assert_difference 'Attachment.count', count + 1 do assert_difference 'Attachment.count', count + 1 do
assert_no_difference 'Journal.count' do assert_difference 'Journal.count', 2 do
post :create, :project_id => 1, :copy_from => 3, post :create, :project_id => 1, :copy_from => 3,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with attachments'}, :issue => {:project_id => '1', :tracker_id => '3',
:status_id => '1', :subject => 'Copy with attachments'},
:copy_attachments => '1', :copy_attachments => '1',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} :attachments => {'1' =>
{'file' => uploaded_test_file('testfile.txt', 'text/plain'),
'description' => 'test file'}}
end end
end end
end end
@ -2519,11 +2521,11 @@ class IssuesControllerTest < ActionController::TestCase
@request.session[:user_id] = 2 @request.session[:user_id] = 2
issue = Issue.generate_with_descendants! issue = Issue.generate_with_descendants!
count = issue.descendants.count count = issue.descendants.count
assert_difference 'Issue.count', count + 1 do
assert_difference 'Issue.count', count+1 do assert_difference 'Journal.count', (count + 1) * 2 do
assert_no_difference 'Journal.count' do
post :create, :project_id => 1, :copy_from => issue.id, post :create, :project_id => 1, :copy_from => issue.id,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'}, :issue => {:project_id => '1', :tracker_id => '3',
:status_id => '1', :subject => 'Copy with subtasks'},
:copy_subtasks => '1' :copy_subtasks => '1'
end end
end end
@ -2535,11 +2537,11 @@ class IssuesControllerTest < ActionController::TestCase
def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
@request.session[:user_id] = 2 @request.session[:user_id] = 2
issue = Issue.generate_with_descendants! issue = Issue.generate_with_descendants!
assert_difference 'Issue.count', 1 do assert_difference 'Issue.count', 1 do
assert_no_difference 'Journal.count' do assert_difference 'Journal.count', 2 do
post :create, :project_id => 1, :copy_from => 3, post :create, :project_id => 1, :copy_from => 3,
:issue => {:project_id => '1', :tracker_id => '3', :status_id => '1', :subject => 'Copy with subtasks'} :issue => {:project_id => '1', :tracker_id => '3',
:status_id => '1', :subject => 'Copy with subtasks'}
end end
end end
copy = Issue.where(:parent_id => nil).first(:order => 'id DESC') copy = Issue.where(:parent_id => nil).first(:order => 'id DESC')
@ -3727,11 +3729,10 @@ class IssuesControllerTest < ActionController::TestCase
:status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31' :status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
} }
end end
issue = Issue.first(:order => 'id DESC') issue = Issue.first(:order => 'id DESC')
assert_equal 1, issue.journals.size assert_equal 1, issue.journals.size
journal = issue.journals.first journal = issue.journals.first
assert_equal 0, journal.details.size assert_equal 1, journal.details.size
assert_equal 'Copying one issue', journal.notes assert_equal 'Copying one issue', journal.notes
end end