@@ -75,7 +75,7 class DocumentsControllerTest < ActionController::TestCase | |||
|
75 | 75 | :document => { :title => 'DocumentsControllerTest#test_post_new', |
|
76 | 76 | :description => 'This is a new document', |
|
77 | 77 | :category_id => 2}, |
|
78 |
:attachments => {'1' => {'file' => |
|
|
78 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
79 | 79 | |
|
80 | 80 | assert_redirected_to 'projects/ecookbook/documents' |
|
81 | 81 |
@@ -787,7 +787,7 class IssuesControllerTest < ActionController::TestCase | |||
|
787 | 787 | post :edit, |
|
788 | 788 | :id => 1, |
|
789 | 789 | :notes => '', |
|
790 |
:attachments => {'1' => {'file' => |
|
|
790 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
791 | 791 | assert_redirected_to :action => 'show', :id => '1' |
|
792 | 792 | j = Issue.find(1).journals.find(:first, :order => 'id DESC') |
|
793 | 793 | assert j.notes.blank? |
@@ -272,7 +272,7 class ProjectsControllerTest < ActionController::TestCase | |||
|
272 | 272 | |
|
273 | 273 | assert_difference 'Attachment.count' do |
|
274 | 274 | post :add_file, :id => 1, :version_id => '', |
|
275 |
:attachments => {'1' => {'file' => |
|
|
275 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
276 | 276 | end |
|
277 | 277 | assert_redirected_to 'projects/ecookbook/files' |
|
278 | 278 | a = Attachment.find(:first, :order => 'created_on DESC') |
@@ -303,7 +303,7 class ProjectsControllerTest < ActionController::TestCase | |||
|
303 | 303 | |
|
304 | 304 | assert_difference 'Attachment.count' do |
|
305 | 305 | post :add_file, :id => 1, :version_id => '2', |
|
306 |
:attachments => {'1' => {'file' => |
|
|
306 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
|
307 | 307 | end |
|
308 | 308 | assert_redirected_to 'projects/ecookbook/files' |
|
309 | 309 | a = Attachment.find(:first, :order => 'created_on DESC') |
@@ -71,7 +71,7 class IssuesTest < ActionController::IntegrationTest | |||
|
71 | 71 | |
|
72 | 72 | post 'issues/1/edit', |
|
73 | 73 | :notes => 'Some notes', |
|
74 |
:attachments => {'1' => {'file' => |
|
|
74 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} | |
|
75 | 75 | assert_redirected_to "issues/1" |
|
76 | 76 | |
|
77 | 77 | # make sure attachment was saved |
@@ -54,7 +54,7 class ActiveSupport::TestCase | |||
|
54 | 54 | assert_equal login, User.find(session[:user_id]).login |
|
55 | 55 | end |
|
56 | 56 | |
|
57 |
def |
|
|
57 | def uploaded_test_file(name, mime) | |
|
58 | 58 | ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime) |
|
59 | 59 | end |
|
60 | 60 |
@@ -25,14 +25,14 class AttachmentTest < ActiveSupport::TestCase | |||
|
25 | 25 | |
|
26 | 26 | def test_create |
|
27 | 27 | a = Attachment.new(:container => Issue.find(1), |
|
28 |
:file => |
|
|
28 | :file => uploaded_test_file("testfile.txt", "text/plain"), | |
|
29 | 29 | :author => User.find(1)) |
|
30 | 30 | assert a.save |
|
31 | 31 | assert_equal 'testfile.txt', a.filename |
|
32 | 32 | assert_equal 59, a.filesize |
|
33 | 33 | assert_equal 'text/plain', a.content_type |
|
34 | 34 | assert_equal 0, a.downloads |
|
35 |
assert_equal Digest::MD5.hexdigest( |
|
|
35 | assert_equal Digest::MD5.hexdigest(uploaded_test_file("testfile.txt", "text/plain").read), a.digest | |
|
36 | 36 | assert File.exist?(a.diskfile) |
|
37 | 37 | end |
|
38 | 38 |
General Comments 0
You need to be logged in to leave comments.
Login now