@@ -32,8 +32,12 class AttachmentsControllerTest < ActionController::TestCase | |||
|
32 | 32 | @controller = AttachmentsController.new |
|
33 | 33 | @request = ActionController::TestRequest.new |
|
34 | 34 | @response = ActionController::TestResponse.new |
|
35 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
36 | 35 | User.current = nil |
|
36 | set_fixtures_attachments_directory | |
|
37 | end | |
|
38 | ||
|
39 | def teardown | |
|
40 | set_tmp_attachments_directory | |
|
37 | 41 | end |
|
38 | 42 | |
|
39 | 43 | def test_show_diff |
@@ -30,7 +30,11 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
30 | 30 | |
|
31 | 31 | def setup |
|
32 | 32 | Setting.rest_api_enabled = '1' |
|
33 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
33 | set_fixtures_attachments_directory | |
|
34 | end | |
|
35 | ||
|
36 | def teardown | |
|
37 | set_tmp_attachments_directory | |
|
34 | 38 | end |
|
35 | 39 | |
|
36 | 40 | context "/attachments/:id" do |
@@ -97,6 +97,10 class ActiveSupport::TestCase | |||
|
97 | 97 | Attachment.storage_path = "#{Rails.root}/tmp/test/attachments" |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | def set_fixtures_attachments_directory | |
|
101 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
102 | end | |
|
103 | ||
|
100 | 104 | def with_settings(options, &block) |
|
101 | 105 | saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].is_a?(Symbol) ? Setting[k] : Setting[k].dup; h} |
|
102 | 106 | options.each {|k, v| Setting[k] = v} |
@@ -145,7 +145,7 class AttachmentTest < ActiveSupport::TestCase | |||
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | def test_latest_attach |
|
148 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
148 | set_fixtures_attachments_directory | |
|
149 | 149 | a1 = Attachment.find(16) |
|
150 | 150 | assert_equal "testfile.png", a1.filename |
|
151 | 151 | assert a1.readable? |
@@ -182,7 +182,7 RAW | |||
|
182 | 182 | end |
|
183 | 183 | |
|
184 | 184 | def test_attached_images_should_read_later |
|
185 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
185 | set_fixtures_attachments_directory | |
|
186 | 186 | a1 = Attachment.find(16) |
|
187 | 187 | assert_equal "testfile.png", a1.filename |
|
188 | 188 | assert a1.readable? |
@@ -91,7 +91,7 class PdfTest < ActiveSupport::TestCase | |||
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def test_attach |
|
94 | Attachment.storage_path = "#{Rails.root}/test/fixtures/files" | |
|
94 | set_fixtures_attachments_directory | |
|
95 | 95 | |
|
96 | 96 | str2 = "\x83e\x83X\x83g" |
|
97 | 97 | str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding) |
General Comments 0
You need to be logged in to leave comments.
Login now