1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-06 09:03:25 +00:00

Code cleanup.

git-svn-id: http://svn.redmine.org/redmine/trunk@14771 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-10-30 19:44:33 +00:00
parent cb3072acee
commit 21421917fc

View File

@ -37,11 +37,12 @@ class IssuesTest < Redmine::IntegrationTest
# create an issue
def test_add_issue
log_user('jsmith', 'jsmith')
get '/projects/1/issues/new', :tracker_id => '1'
get '/projects/ecookbook/issues/new', :tracker_id => '1'
assert_response :success
assert_template 'issues/new'
post '/projects/1/issues', :tracker_id => "1",
issue = new_record(Issue) do
post '/projects/ecookbook/issues', :tracker_id => "1",
:issue => { :start_date => "2006-12-26",
:priority_id => "4",
:subject => "new test issue",
@ -51,10 +52,7 @@ class IssuesTest < Redmine::IntegrationTest
:due_date => "",
:assigned_to_id => "" },
:custom_fields => {'2' => 'Value for field 2'}
# find created issue
issue = Issue.find_by_subject("new test issue")
assert_kind_of Issue, issue
end
# check redirection
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
follow_redirect!
@ -79,11 +77,10 @@ class IssuesTest < Redmine::IntegrationTest
Role.anonymous.remove_permission! :add_issues
Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [3])
assert_difference 'Issue.count' do
issue = new_record(Issue) do
post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
assert_response 302
end
assert_response 302
issue = Issue.order("id DESC").first
assert_equal User.anonymous, issue.author
end
@ -92,15 +89,15 @@ class IssuesTest < Redmine::IntegrationTest
log_user('jsmith', 'jsmith')
set_tmp_attachments_directory
put '/issues/1',
:notes => 'Some notes',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
assert_redirected_to "/issues/1"
attachment = new_record(Attachment) do
put '/issues/1',
:notes => 'Some notes',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
assert_redirected_to "/issues/1"
end
# make sure attachment was saved
attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
assert_kind_of Attachment, attachment
assert_equal Issue.find(1), attachment.container
assert_equal 'testfile.txt', attachment.filename
assert_equal 'This is an attachment', attachment.description
# verify the size of the attachment stored in db
#assert_equal file_data_1.length, attachment.filesize
@ -159,7 +156,7 @@ class IssuesTest < Redmine::IntegrationTest
end
# Create issue
assert_difference 'Issue.count' do
issue = new_record(Issue) do
post '/projects/ecookbook/issues',
:issue => {
:tracker_id => '1',
@ -167,9 +164,8 @@ class IssuesTest < Redmine::IntegrationTest
:subject => 'Issue with user custom field',
:custom_field_values => {@field.id.to_s => users.first.id.to_s}
}
assert_response 302
end
issue = Issue.order('id DESC').first
assert_response 302
# Issue view
follow_redirect!