From be29227c12da043996cf05a489fa6b7ef26bea81 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 24 Nov 2011 08:10:41 +0000 Subject: [PATCH] reset Attachment.storage_path at the end of attachment tests Attachment files are deleted when database data were deleted. So, other tests fail. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7911 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../functional/attachments_controller_test.rb | 19 ++++++++++++++++++- test/integration/api_test/attachments_test.rb | 10 +++++----- test/unit/attachment_test.rb | 2 ++ test/unit/helpers/application_helper_test.rb | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 801114ca4..bc1a5183a 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -50,6 +50,7 @@ class AttachmentsControllerTest < ActionController::TestCase :attributes => {:class => /line-code/}, :content => /Demande créée avec succès/ end + set_tmp_attachments_directory end def test_show_diff_replcace_cannot_convert_content @@ -68,6 +69,7 @@ class AttachmentsControllerTest < ActionController::TestCase :content => /Demande cr\?\?e avec succ\?s/ end end + set_tmp_attachments_directory end def test_show_diff_latin_1 @@ -86,6 +88,7 @@ class AttachmentsControllerTest < ActionController::TestCase :content => /Demande créée avec succès/ end end + set_tmp_attachments_directory end def test_show_text_file @@ -93,6 +96,7 @@ class AttachmentsControllerTest < ActionController::TestCase assert_response :success assert_template 'file' assert_equal 'text/html', @response.content_type + set_tmp_attachments_directory end def test_show_text_file_utf_8 @@ -133,7 +137,7 @@ class AttachmentsControllerTest < ActionController::TestCase :content => '7', :attributes => { :class => 'line-num' }, :sibling => { :tag => 'td', :content => /Demande cr\?\?e avec succ\?s/ } - end + end end def test_show_text_file_latin_1 @@ -163,17 +167,20 @@ class AttachmentsControllerTest < ActionController::TestCase get :show, :id => 4 assert_response :success assert_equal 'application/x-ruby', @response.content_type + set_tmp_attachments_directory end def test_show_other get :show, :id => 6 assert_response :success assert_equal 'application/octet-stream', @response.content_type + set_tmp_attachments_directory end def test_show_file_from_private_issue_without_permission get :show, :id => 15 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F15' + set_tmp_attachments_directory end def test_show_file_from_private_issue_with_permission @@ -181,12 +188,14 @@ class AttachmentsControllerTest < ActionController::TestCase get :show, :id => 15 assert_response :success assert_tag 'h2', :content => /private.diff/ + set_tmp_attachments_directory end def test_download_text_file get :download, :id => 4 assert_response :success assert_equal 'application/x-ruby', @response.content_type + set_tmp_attachments_directory end def test_download_should_assign_content_type_if_blank @@ -195,16 +204,19 @@ class AttachmentsControllerTest < ActionController::TestCase get :download, :id => 4 assert_response :success assert_equal 'text/x-ruby', @response.content_type + set_tmp_attachments_directory end def test_download_missing_file get :download, :id => 2 assert_response 404 + set_tmp_attachments_directory end def test_anonymous_on_private_private get :download, :id => 7 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7' + set_tmp_attachments_directory end def test_destroy_issue_attachment @@ -221,6 +233,7 @@ class AttachmentsControllerTest < ActionController::TestCase assert_equal 'attachment', j.details.first.property assert_equal '1', j.details.first.prop_key assert_equal 'error281.txt', j.details.first.old_value + set_tmp_attachments_directory end def test_destroy_wiki_page_attachment @@ -229,6 +242,7 @@ class AttachmentsControllerTest < ActionController::TestCase post :destroy, :id => 3 assert_response 302 end + set_tmp_attachments_directory end def test_destroy_project_attachment @@ -237,6 +251,7 @@ class AttachmentsControllerTest < ActionController::TestCase post :destroy, :id => 8 assert_response 302 end + set_tmp_attachments_directory end def test_destroy_version_attachment @@ -245,11 +260,13 @@ class AttachmentsControllerTest < ActionController::TestCase post :destroy, :id => 9 assert_response 302 end + set_tmp_attachments_directory end def test_destroy_without_permission post :destroy, :id => 3 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' assert Attachment.find_by_id(3) + set_tmp_attachments_directory end end diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb index fa5117c8b..10b92328c 100644 --- a/test/integration/api_test/attachments_test.rb +++ b/test/integration/api_test/attachments_test.rb @@ -37,7 +37,6 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest context "GET" do should "return the attachment" do get '/attachments/7.xml', {}, :authorization => credentials('jsmith') - assert_response :success assert_equal 'application/xml', @response.content_type assert_tag :tag => 'attachment', @@ -57,8 +56,8 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest should "deny access without credentials" do get '/attachments/7.xml' - assert_response 401 + set_tmp_attachments_directory end end end @@ -66,16 +65,17 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest context "/attachments/download/:id/:filename" do context "GET" do should "return the attachment content" do - get '/attachments/download/7/archive.zip', {}, :authorization => credentials('jsmith') - + get '/attachments/download/7/archive.zip', + {}, :authorization => credentials('jsmith') assert_response :success assert_equal 'application/octet-stream', @response.content_type + set_tmp_attachments_directory end should "deny access without credentials" do get '/attachments/download/7/archive.zip' - assert_response 302 + set_tmp_attachments_directory end end end diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 3cd5fb4d5..00519d663 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -141,5 +141,7 @@ class AttachmentTest < ActiveSupport::TestCase assert_equal 17, la1.id la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG") assert_equal 17, la2.id + + set_tmp_attachments_directory end end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index aeb714042..701bfeed7 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -203,6 +203,7 @@ RAW } attachments = [a1, a2] to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text, :attachments => attachments) } + set_tmp_attachments_directory end def test_textile_external_links -- 2.39.5