@@ -755,6 +755,31 class IssuesControllerTest < ActionController::TestCase | |||||
755 | end |
|
755 | end | |
756 | end |
|
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 | context "without workflow privilege" do |
|
783 | context "without workflow privilege" do | |
759 | setup do |
|
784 | setup do | |
760 | Workflow.delete_all(["role_id = ?", Role.anonymous.id]) |
|
785 | Workflow.delete_all(["role_id = ?", Role.anonymous.id]) | |
@@ -1092,16 +1117,28 class IssuesControllerTest < ActionController::TestCase | |||||
1092 | Journal.delete_all |
|
1117 | Journal.delete_all | |
1093 |
|
1118 | |||
1094 | # anonymous user |
|
1119 | # anonymous user | |
1095 | put :update, |
|
1120 | assert_difference 'Attachment.count' do | |
1096 |
|
|
1121 | put :update, :id => 1, | |
1097 |
|
|
1122 | :notes => '', | |
1098 |
|
|
1123 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |
|
1124 | end | |||
|
1125 | ||||
1099 | assert_redirected_to :action => 'show', :id => '1' |
|
1126 | assert_redirected_to :action => 'show', :id => '1' | |
1100 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
1127 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') | |
1101 | assert j.notes.blank? |
|
1128 | assert j.notes.blank? | |
1102 | assert_equal 1, j.details.size |
|
1129 | assert_equal 1, j.details.size | |
1103 | assert_equal 'testfile.txt', j.details.first.value |
|
1130 | assert_equal 'testfile.txt', j.details.first.value | |
1104 | assert_equal User.anonymous, j.user |
|
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 | mail = ActionMailer::Base.deliveries.last |
|
1143 | mail = ActionMailer::Base.deliveries.last | |
1107 | assert mail.body.include?('testfile.txt') |
|
1144 | assert mail.body.include?('testfile.txt') |
General Comments 0
You need to be logged in to leave comments.
Login now