1 require "#{File.dirname(__FILE__)}/../test_helper"
3 class IssuesTest < ActionController::IntegrationTest
4 fixtures :projects, :users, :trackers, :issue_statuses, :issues, :enumerations
8 log_user('jsmith', 'jsmith')
9 get "projects/add_issue/1", :tracker_id => "1"
10 assert_response :success
11 assert_template "projects/add_issue"
13 post "projects/add_issue/1", :tracker_id => "1",
14 :issue => { :start_date => "2006-12-26",
16 :subject => "new test issue",
18 :description => "new issue",
21 :assigned_to_id => "" }
23 issue = Issue.find_by_subject("new test issue")
24 assert_kind_of Issue, issue
27 assert_redirected_to "projects/1/issues"
29 assert assigns(:issues).include?(issue)
31 # check issue attributes
32 assert_equal 'jsmith', issue.author.login
33 assert_equal 1, issue.project.id
34 assert_equal 1, issue.status.id
37 # add then remove 2 attachments to an issue
38 def test_issue_attachements
39 log_user('jsmith', 'jsmith')
41 post "issues/add_note/1", { :notes => 'Some notes', 'attachments[]' => ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + '/files/testfile.txt', 'text/plain') }
42 assert_redirected_to "issues/show/1"
44 # make sure attachment was saved
45 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
46 assert_kind_of Attachment, attachment
47 assert_equal Issue.find(1), attachment.container
48 # verify the size of the attachment stored in db
49 #assert_equal file_data_1.length, attachment.filesize
50 # verify that the attachment was written to disk
51 assert File.exist?(attachment.diskfile)
53 # remove the attachments
54 Issue.find(1).attachments.each(&:destroy)
55 assert_equal 0, Issue.find(1).attachments.length