HTML
@@ -463,41 +464,41 @@ describe CookedPostProcessor do
let(:post) { Fabricate(:post, raw: url) }
before do
- Oneboxer.stubs(:onebox).with(url, anything).returns("")
+ Oneboxer.stubs(:onebox).with(url, anything).returns("")
end
it 'should not add lightbox' do
cpp.post_process
expect(cpp.html).to match_html <<~HTML
-
+
HTML
end
end
describe 'when image is an svg' do
fab!(:post) do
- Fabricate(:post, raw: '')
+ Fabricate(:post, raw: "")
end
it 'should not add lightbox' do
cpp.post_process
expect(cpp.html).to match_html <<~HTML
-
+
HTML
end
describe 'when image src is an URL' do
let(:post) do
- Fabricate(:post, raw: '')
+ Fabricate(:post, raw: "")
end
it 'should not add lightbox' do
SiteSetting.crawl_images = true
cpp.post_process
- expect(cpp.html).to match_html("")
+ expect(cpp.html).to match_html("")
end
end
end
@@ -589,7 +590,7 @@ describe CookedPostProcessor do
cpp.post_process
expect(cpp.html).to match_html <<~HTML
-
HTML
@@ -1137,11 +1138,11 @@ describe CookedPostProcessor do
it "uses schemaless url for uploads" do
cpp.optimize_urls
expect(cpp.html).to match_html <<~HTML
-
HTML
end
@@ -1152,11 +1153,11 @@ describe CookedPostProcessor do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
cpp.optimize_urls
expect(cpp.html).to match_html <<~HTML
-
HTML
end
@@ -1165,11 +1166,11 @@ describe CookedPostProcessor do
Rails.configuration.action_controller.stubs(:asset_host).returns("https://my.cdn.com")
cpp.optimize_urls
expect(cpp.html).to match_html <<~HTML
-
HTML
end
@@ -1179,11 +1180,11 @@ describe CookedPostProcessor do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
cpp.optimize_urls
expect(cpp.html).to match_html <<~HTML
-
HTML
end
@@ -1193,11 +1194,11 @@ describe CookedPostProcessor do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
cpp.optimize_urls
expect(cpp.html).to match_html <<~HTML
-
HTML
end
diff --git a/spec/components/file_store/local_store_spec.rb b/spec/components/file_store/local_store_spec.rb
index 680deb2204f..f601dec73dc 100644
--- a/spec/components/file_store/local_store_spec.rb
+++ b/spec/components/file_store/local_store_spec.rb
@@ -9,6 +9,7 @@ describe FileStore::LocalStore do
fab!(:upload) { Fabricate(:upload) }
let(:uploaded_file) { file_from_fixtures("logo.png") }
+ let(:upload_path) { Discourse.store.upload_path }
fab!(:optimized_image) { Fabricate(:optimized_image) }
@@ -16,7 +17,7 @@ describe FileStore::LocalStore do
it "returns a relative url" do
store.expects(:copy_file)
- expect(store.store_upload(uploaded_file, upload)).to match(/\/uploads\/default\/original\/.+#{upload.sha1}\.png/)
+ expect(store.store_upload(uploaded_file, upload)).to match(/\/#{upload_path}\/original\/.+#{upload.sha1}\.png/)
end
end
@@ -25,7 +26,7 @@ describe FileStore::LocalStore do
it "returns a relative url" do
store.expects(:copy_file)
- expect(store.store_optimized_image({}, optimized_image)).to match(/\/uploads\/default\/optimized\/.+#{optimized_image.upload.sha1}_#{OptimizedImage::VERSION}_100x200\.png/)
+ expect(store.store_optimized_image({}, optimized_image)).to match(/\/#{upload_path}\/optimized\/.+#{optimized_image.upload.sha1}_#{OptimizedImage::VERSION}_100x200\.png/)
end
end
@@ -92,24 +93,24 @@ describe FileStore::LocalStore do
describe "#has_been_uploaded?" do
it "identifies relatives urls" do
- expect(store.has_been_uploaded?("/uploads/default/42/0123456789ABCDEF.jpg")).to eq(true)
+ expect(store.has_been_uploaded?("/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(true)
end
it "identifies local urls" do
Discourse.stubs(:base_url_no_prefix).returns("http://discuss.site.com")
- expect(store.has_been_uploaded?("http://discuss.site.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(true)
- expect(store.has_been_uploaded?("//discuss.site.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(true)
+ expect(store.has_been_uploaded?("http://discuss.site.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(true)
+ expect(store.has_been_uploaded?("//discuss.site.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(true)
end
it "identifies local urls when using a CDN" do
Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
- expect(store.has_been_uploaded?("http://my.cdn.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(true)
- expect(store.has_been_uploaded?("//my.cdn.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(true)
+ expect(store.has_been_uploaded?("http://my.cdn.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(true)
+ expect(store.has_been_uploaded?("//my.cdn.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(true)
end
it "does not match dummy urls" do
- expect(store.has_been_uploaded?("http://domain.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(false)
- expect(store.has_been_uploaded?("//domain.com/uploads/default/42/0123456789ABCDEF.jpg")).to eq(false)
+ expect(store.has_been_uploaded?("http://domain.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(false)
+ expect(store.has_been_uploaded?("//domain.com/#{upload_path}/42/0123456789ABCDEF.jpg")).to eq(false)
end
end
@@ -117,12 +118,12 @@ describe FileStore::LocalStore do
describe "#absolute_base_url" do
it "is present" do
- expect(store.absolute_base_url).to eq("http://test.localhost/uploads/default")
+ expect(store.absolute_base_url).to eq("http://test.localhost/#{upload_path}")
end
it "supports subfolder" do
set_subfolder "/forum"
- expect(store.absolute_base_url).to eq("http://test.localhost/forum/uploads/default")
+ expect(store.absolute_base_url).to eq("http://test.localhost/forum/#{upload_path}")
end
end
@@ -130,12 +131,12 @@ describe FileStore::LocalStore do
describe "#relative_base_url" do
it "is present" do
- expect(store.relative_base_url).to eq("/uploads/default")
+ expect(store.relative_base_url).to eq("/#{upload_path}")
end
it "supports subfolder" do
set_subfolder "/forum"
- expect(store.relative_base_url).to eq("/forum/uploads/default")
+ expect(store.relative_base_url).to eq("/forum/#{upload_path}")
end
end
diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb
index 8cdf7af1385..3dd4360a6f4 100644
--- a/spec/components/url_helper_spec.rb
+++ b/spec/components/url_helper_spec.rb
@@ -121,7 +121,7 @@ describe UrlHelper do
end
describe "#local_cdn_url" do
- let(:url) { "/uploads/default/1X/575bcc2886bf7a39684b57ca90be85f7d399bbc7.png" }
+ let(:url) { "/#{Discourse.store.upload_path}/1X/575bcc2886bf7a39684b57ca90be85f7d399bbc7.png" }
let(:asset_host) { "//my.awesome.cdn" }
it "should return correct cdn url for local relative urls" do
diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb
index 33c7598568f..cd18b78967e 100644
--- a/spec/fabricators/post_fabricator.rb
+++ b/spec/fabricators/post_fabricator.rb
@@ -48,26 +48,26 @@ end
Fabricator(:post_with_plenty_of_images, from: :post) do
cooked <<~HTML
-
-
-
+
+
+
With an emoji!
HTML
end
Fabricator(:post_with_uploaded_image, from: :post) do
- raw ''
+ raw ""
end
Fabricator(:post_with_an_attachment, from: :post) do
- raw 'archive.zip'
+ raw "archive.zip"
end
Fabricator(:post_with_unsized_images, from: :post) do
- raw '
-
-
-'
+ raw "
+
+
+"
end
Fabricator(:post_with_image_urls, from: :post) do
@@ -78,31 +78,31 @@ Fabricator(:post_with_image_urls, from: :post) do
end
Fabricator(:post_with_large_image, from: :post) do
- raw ''
+ raw ""
end
Fabricator(:post_with_large_image_and_title, from: :post) do
- raw ''
+ raw ""
end
Fabricator(:post_with_large_image_on_subfolder, from: :post) do
- raw ''
+ raw ""
end
Fabricator(:post_with_uploads, from: :post) do
- raw '
-Link
-
-'
+ raw "
+Link
+
+"
end
Fabricator(:post_with_uploads_and_links, from: :post) do
raw <<~RAW
- Link
-
+ Link
+
Google
- text.txt (20 Bytes)
+ text.txt (20 Bytes)
:smile:
RAW
end
diff --git a/spec/helpers/user_notifications_helper_spec.rb b/spec/helpers/user_notifications_helper_spec.rb
index 7610495b258..b72dcf82c0c 100644
--- a/spec/helpers/user_notifications_helper_spec.rb
+++ b/spec/helpers/user_notifications_helper_spec.rb
@@ -3,6 +3,8 @@
require 'rails_helper'
describe UserNotificationsHelper do
+ let(:upload_path) { Discourse.store.upload_path }
+
describe '#email_excerpt' do
let(:paragraphs) { [
"
This is the first paragraph, but you should read more.
",
@@ -97,7 +99,7 @@ describe UserNotificationsHelper do
it 'should return the right URL' do
expect(helper.logo_url).to eq(
- "http://test.localhost/uploads/default/original/1X/somesha1.png"
+ "http://test.localhost/#{upload_path}/original/1X/somesha1.png"
)
end
@@ -110,7 +112,7 @@ describe UserNotificationsHelper do
it 'should return the right URL' do
expect(helper.logo_url).to eq(
- "https://some.localcdn.com/uploads/default/original/1X/somesha1.png"
+ "https://some.localcdn.com/#{upload_path}/original/1X/somesha1.png"
)
end
end
diff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rb
index dd194f3b897..fa37da185c6 100644
--- a/spec/jobs/pull_hotlinked_images_spec.rb
+++ b/spec/jobs/pull_hotlinked_images_spec.rb
@@ -10,6 +10,7 @@ describe Jobs::PullHotlinkedImages do
let(:large_image_url) { "http://wiki.mozilla.org/images/2/2e/Longcat3.png" }
let(:png) { Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==") }
let(:large_png) { Base64.decode64("iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAK10lEQVR42r3aeVRTVx4H8Oc2atWO7Sw9OnM6HWvrOON0aFlcAZ3RopZWOyqgoCACKqPWBUVQi4gIqAVllciiKPu+JOyGnQQSNgkIIQgoKljAYVARCZnf4yXhkeXlJmDP+f4hOUF+n3fvffe++y5W0i4qJqWoDU8hKQUPxWFKcq9VnHxJ8gTi5EqS0yJOtiRZfHEyJWE0i0MnJaMJTzopaQ/wpJKS0ogneTQYABANTDlDvpxBCsiu72eUP0zPq8Fzr45e8TircRDFQAAy5ABpcgDCgJV2iCbRQ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QP/7JVFmZbgdlxxnKienFBe4/G7YA1kADI7TDilmQJZVlE41cRirBlYdZMzIqB7UnGdseRkohZZmDW+ZhNmfibEHvuzAOcaWTD5XpLuBepdfKtiAxQ1xDPTdnhOdXUH7Nlj7uWKDnAme7bvPlI1a/Hfz4ljp+BfnqPPKD/DzQWIVWNoUiJAAAAAElFTkSuQmCC") }
+ let(:upload_path) { Discourse.store.upload_path }
before do
stub_request(:get, image_url).to_return(body: png, headers: { "Content-Type" => "image/png" })
@@ -18,12 +19,12 @@ describe Jobs::PullHotlinkedImages do
stub_request(
:get,
- "#{Discourse.base_url}/uploads/default/original/1X/f59ea56fe8ebe42048491d43a19d9f34c5d0f8dc.gif"
+ "#{Discourse.base_url}/#{upload_path}/original/1X/f59ea56fe8ebe42048491d43a19d9f34c5d0f8dc.gif"
)
stub_request(
:get,
- "#{Discourse.base_url}/uploads/default/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
+ "#{Discourse.base_url}/#{upload_path}/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
)
SiteSetting.crawl_images = true
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index e82c21d87a9..760252adf52 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -5,6 +5,8 @@ require 'rails_helper'
describe Post do
before { Oneboxer.stubs :onebox }
+ let(:upload_path) { Discourse.store.upload_path }
+
describe '#hidden_reasons' do
context "verify enum sequence" do
before do
@@ -313,8 +315,8 @@ describe Post do
describe "maximum attachments" do
fab!(:newuser) { Fabricate(:user, trust_level: TrustLevel[0]) }
let(:post_no_attachments) { Fabricate.build(:post, post_args.merge(user: newuser)) }
- let(:post_one_attachment) { post_with_body('file.txt', newuser) }
- let(:post_two_attachments) { post_with_body('errors.logmodel.3ds', newuser) }
+ let(:post_one_attachment) { post_with_body("file.txt", newuser) }
+ let(:post_two_attachments) { post_with_body("errors.logmodel.3ds", newuser) }
it "returns 0 attachments for an empty post" do
expect(Fabricate.build(:post).attachment_count).to eq(0)
@@ -729,11 +731,11 @@ describe Post do
end
describe 'before save' do
- let(:cooked) { "