GITSCM: Tweaked git scm view layout
[gitredmine.git] / test / integration / issues_test.rb
blobeac407b1b46c685ecd0562aff8b6b6bfd651c572
1 require "#{File.dirname(__FILE__)}/../test_helper"
3 class IssuesTest < ActionController::IntegrationTest
4   fixtures :projects, :users, :trackers, :issue_statuses, :issues,  :enumerations
6   # create an issue
7   def test_add_issue
8     log_user('jsmith', 'jsmith')
9     get "projects/add_issue/1", :tracker_id => "1"
10     assert_response :success
11     assert_template "projects/add_issue"
12     
13     post "projects/add_issue/1", :tracker_id => "1",
14                                  :issue => { :start_date => "2006-12-26", 
15                                              :priority_id => "3", 
16                                              :subject => "new test issue", 
17                                              :category_id => "", 
18                                              :description => "new issue", 
19                                              :done_ratio => "0",
20                                              :due_date => "",
21                                              :assigned_to_id => "" }
22     # find created issue
23     issue = Issue.find_by_subject("new test issue")
24     assert_kind_of Issue, issue
26     # check redirection
27     assert_redirected_to "projects/1/issues"
28     follow_redirect!
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
35   end
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"
43     
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)
52     
53     # remove the attachments
54     Issue.find(1).attachments.each(&:destroy)
55     assert_equal 0, Issue.find(1).attachments.length
56   end
58 end