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