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