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
This commit is contained in:
parent
14b931eb4a
commit
ad25e3807d
|
@ -32,8 +32,12 @@ class AttachmentsControllerTest < ActionController::TestCase
|
||||||
@controller = AttachmentsController.new
|
@controller = AttachmentsController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
@response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
|
|
||||||
User.current = nil
|
User.current = nil
|
||||||
|
set_fixtures_attachments_directory
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_diff
|
def test_show_diff
|
||||||
|
|
|
@ -30,7 +30,11 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Setting.rest_api_enabled = '1'
|
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
|
end
|
||||||
|
|
||||||
context "/attachments/:id" do
|
context "/attachments/:id" do
|
||||||
|
|
|
@ -97,6 +97,10 @@ class ActiveSupport::TestCase
|
||||||
Attachment.storage_path = "#{Rails.root}/tmp/test/attachments"
|
Attachment.storage_path = "#{Rails.root}/tmp/test/attachments"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_fixtures_attachments_directory
|
||||||
|
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
|
||||||
|
end
|
||||||
|
|
||||||
def with_settings(options, &block)
|
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}
|
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}
|
options.each {|k, v| Setting[k] = v}
|
||||||
|
|
|
@ -145,7 +145,7 @@ class AttachmentTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_latest_attach
|
def test_latest_attach
|
||||||
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
|
set_fixtures_attachments_directory
|
||||||
a1 = Attachment.find(16)
|
a1 = Attachment.find(16)
|
||||||
assert_equal "testfile.png", a1.filename
|
assert_equal "testfile.png", a1.filename
|
||||||
assert a1.readable?
|
assert a1.readable?
|
||||||
|
|
|
@ -182,7 +182,7 @@ RAW
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_attached_images_should_read_later
|
def test_attached_images_should_read_later
|
||||||
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
|
set_fixtures_attachments_directory
|
||||||
a1 = Attachment.find(16)
|
a1 = Attachment.find(16)
|
||||||
assert_equal "testfile.png", a1.filename
|
assert_equal "testfile.png", a1.filename
|
||||||
assert a1.readable?
|
assert a1.readable?
|
||||||
|
|
|
@ -91,7 +91,7 @@ class PdfTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_attach
|
def test_attach
|
||||||
Attachment.storage_path = "#{Rails.root}/test/fixtures/files"
|
set_fixtures_attachments_directory
|
||||||
|
|
||||||
str2 = "\x83e\x83X\x83g"
|
str2 = "\x83e\x83X\x83g"
|
||||||
str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
|
str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
|
||||||
|
|
|
@ -34,6 +34,7 @@ class ProjectTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
@ecookbook = Project.find(1)
|
@ecookbook = Project.find(1)
|
||||||
@ecookbook_sub1 = Project.find(3)
|
@ecookbook_sub1 = Project.find(3)
|
||||||
|
set_tmp_attachments_directory
|
||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue