summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-16 17:52:47 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-16 17:52:47 +0000
commitad25e3807d2d63b5796fe25099b20d687bec3704 (patch)
tree0364df609c68b250479fa65a57e0d65df8a2259e /test
parent14b931eb4a93fd0a55ca0959e0e8253d6f27e7a7 (diff)
downloadredmine-ad25e3807d2d63b5796fe25099b20d687bec3704.tar.gz
redmine-ad25e3807d2d63b5796fe25099b20d687bec3704.zip
Make sure that tests restore the attachments path to the tmp dir so that fixture files don't get deleted.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8248 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/attachments_controller_test.rb6
-rw-r--r--test/integration/api_test/attachments_test.rb6
-rw-r--r--test/test_helper.rb4
-rw-r--r--test/unit/attachment_test.rb2
-rw-r--r--test/unit/helpers/application_helper_test.rb2
-rw-r--r--test/unit/lib/redmine/export/pdf_test.rb2
-rw-r--r--test/unit/project_test.rb1
7 files changed, 18 insertions, 5 deletions
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb
index 625a21eb5..dd5c05fdf 100644
--- a/test/functional/attachments_controller_test.rb
+++ b/test/functional/attachments_controller_test.rb
@@ -32,8 +32,12 @@ class AttachmentsControllerTest < ActionController::TestCase
@controller = AttachmentsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
- Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
User.current = nil
+ set_fixtures_attachments_directory
+ end
+
+ def teardown
+ set_tmp_attachments_directory
end
def test_show_diff
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb
index 10b92328c..73ded9b30 100644
--- a/test/integration/api_test/attachments_test.rb
+++ b/test/integration/api_test/attachments_test.rb
@@ -30,7 +30,11 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
def setup
Setting.rest_api_enabled = '1'
- Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
+ set_fixtures_attachments_directory
+ end
+
+ def teardown
+ set_tmp_attachments_directory
end
context "/attachments/:id" do
diff --git a/test/test_helper.rb b/test/test_helper.rb
index dcac221d4..7ff3434be 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -97,6 +97,10 @@ class ActiveSupport::TestCase
Attachment.storage_path = "#{Rails.root}/tmp/test/attachments"
end
+ def set_fixtures_attachments_directory
+ Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
+ end
+
def with_settings(options, &block)
saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].is_a?(Symbol) ? Setting[k] : Setting[k].dup; h}
options.each {|k, v| Setting[k] = v}
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 0cdec7b0f..56474b051 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -145,7 +145,7 @@ class AttachmentTest < ActiveSupport::TestCase
end
def test_latest_attach
- Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
+ set_fixtures_attachments_directory
a1 = Attachment.find(16)
assert_equal "testfile.png", a1.filename
assert a1.readable?
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 031d514df..7482e75b5 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -182,7 +182,7 @@ RAW
end
def test_attached_images_should_read_later
- Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
+ set_fixtures_attachments_directory
a1 = Attachment.find(16)
assert_equal "testfile.png", a1.filename
assert a1.readable?
diff --git a/test/unit/lib/redmine/export/pdf_test.rb b/test/unit/lib/redmine/export/pdf_test.rb
index 3ee8caefd..6082eee9d 100644
--- a/test/unit/lib/redmine/export/pdf_test.rb
+++ b/test/unit/lib/redmine/export/pdf_test.rb
@@ -91,7 +91,7 @@ class PdfTest < ActiveSupport::TestCase
end
def test_attach
- Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
+ set_fixtures_attachments_directory
str2 = "\x83e\x83X\x83g"
str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index babc2e2ed..d2b70492b 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -34,6 +34,7 @@ class ProjectTest < ActiveSupport::TestCase
def setup
@ecookbook = Project.find(1)
@ecookbook_sub1 = Project.find(3)
+ set_tmp_attachments_directory
User.current = nil
end