@@ -755,6 +755,31 class IssuesControllerTest < ActionController::TestCase | |||
|
755 | 755 | end |
|
756 | 756 | end |
|
757 | 757 | |
|
758 | def test_post_create_with_attachment | |
|
759 | set_tmp_attachments_directory | |
|
760 | @request.session[:user_id] = 2 | |
|
761 | ||
|
762 | assert_difference 'Issue.count' do | |
|
763 | assert_difference 'Attachment.count' do | |
|
764 | post :create, :project_id => 1, | |
|
765 | :issue => { :tracker_id => '1', :subject => 'With attachment' }, | |
|
766 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |
|
767 | end | |
|
768 | end | |
|
769 | ||
|
770 | issue = Issue.first(:order => 'id DESC') | |
|
771 | attachment = Attachment.first(:order => 'id DESC') | |
|
772 | ||
|
773 | assert_equal issue, attachment.container | |
|
774 | assert_equal 2, attachment.author_id | |
|
775 | assert_equal 'testfile.txt', attachment.filename | |
|
776 | assert_equal 'text/plain', attachment.content_type | |
|
777 | assert_equal 'test file', attachment.description | |
|
778 | assert_equal 59, attachment.filesize | |
|
779 | assert File.exists?(attachment.diskfile) | |
|
780 | assert_equal 59, File.size(attachment.diskfile) | |
|
781 | end | |
|
782 | ||
|
758 | 783 | context "without workflow privilege" do |
|
759 | 784 | setup do |
|
760 | 785 | Workflow.delete_all(["role_id = ?", Role.anonymous.id]) |
@@ -1092,16 +1117,28 class IssuesControllerTest < ActionController::TestCase | |||
|
1092 | 1117 | Journal.delete_all |
|
1093 | 1118 | |
|
1094 | 1119 | # anonymous user |
|
1095 | put :update, | |
|
1096 |
|
|
|
1097 |
|
|
|
1098 |
|
|
|
1120 | assert_difference 'Attachment.count' do | |
|
1121 | put :update, :id => 1, | |
|
1122 | :notes => '', | |
|
1123 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |
|
1124 | end | |
|
1125 | ||
|
1099 | 1126 | assert_redirected_to :action => 'show', :id => '1' |
|
1100 | 1127 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
1101 | 1128 | assert j.notes.blank? |
|
1102 | 1129 | assert_equal 1, j.details.size |
|
1103 | 1130 | assert_equal 'testfile.txt', j.details.first.value |
|
1104 | 1131 | assert_equal User.anonymous, j.user |
|
1132 | ||
|
1133 | attachment = Attachment.first(:order => 'id DESC') | |
|
1134 | assert_equal Issue.find(1), attachment.container | |
|
1135 | assert_equal User.anonymous, attachment.author | |
|
1136 | assert_equal 'testfile.txt', attachment.filename | |
|
1137 | assert_equal 'text/plain', attachment.content_type | |
|
1138 | assert_equal 'test file', attachment.description | |
|
1139 | assert_equal 59, attachment.filesize | |
|
1140 | assert File.exists?(attachment.diskfile) | |
|
1141 | assert_equal 59, File.size(attachment.diskfile) | |
|
1105 | 1142 | |
|
1106 | 1143 | mail = ActionMailer::Base.deliveries.last |
|
1107 | 1144 | assert mail.body.include?('testfile.txt') |
General Comments 0
You need to be logged in to leave comments.
Login now