# 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",
: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!
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
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
end
# Create issue
- assert_difference 'Issue.count' do
+ issue = new_record(Issue) do
post '/projects/ecookbook/issues',
:issue => {
:tracker_id => '1',
: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!