fix the incorrect specs

fix the incorrect specs

Previously the ‘local_cdn_url’ method didn’t return the correct cdn url. So we have written a few incorrect spec tests too.

f92a6f7ac5228342177bf089d269e2f69a69e2f5

diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index dc14832232..fccb0d3ad7 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -1378,21 +1378,23 @@ HTML
       [some attachment|random](#{upload.short_url})
       RAW
 
+      cdn_url = Discourse.store.cdn_url(upload.url)
+
       cooked = <<~HTML
-        <p><img src="#{upload.url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
-        <p><img src="#{upload.url}" alt="upload" title="some title to test" data-base62-sha1="#{upload.base62_sha1}"></p>
+        <p><img src="#{cdn_url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
+        <p><img src="#{cdn_url}" alt="upload" title="some title to test" data-base62-sha1="#{upload.base62_sha1}"></p>
         <ul>
         <li>
-        <p><img src="#{upload.url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
+        <p><img src="#{cdn_url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
         </li>
         <li>
         <p>test</p>
         <ul>
-        <li><img src="#{upload.url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></li>
+        <li><img src="#{cdn_url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></li>
         </ul>
         </li>
         </ul>
-        <p><img src="#{upload.url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
+        <p><img src="#{cdn_url}" alt="upload" data-base62-sha1="#{upload.base62_sha1}"></p>
         <p><a href="#{upload.short_path}">some attachment</a></p>
         <p><a class="attachment" href="#{upload.short_path}">some attachment</a></p>
         <p><a href="#{upload.short_path}">some attachment|random</a></p>
diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb
index 77ae944249..4d86341fe5 100644
--- a/spec/components/url_helper_spec.rb
+++ b/spec/components/url_helper_spec.rb
@@ -124,7 +124,7 @@ describe UrlHelper do
     let(:asset_host) { "//my.awesome.cdn" }
 
     it "should return correct cdn url for local relative urls" do
-      Discourse.stubs(:asset_host).returns(asset_host)
+      set_cdn_url asset_host
       cdn_url = UrlHelper.local_cdn_url(url)
       expect(cdn_url).to eq("#{asset_host}#{url}")
     end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 92d4aafad1..d035fdfac4 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -1367,6 +1367,7 @@ describe Post do
       upload1 = Fabricate(:upload)
       upload2 = Fabricate(:upload)
       upload3 = Fabricate(:video_upload)
+      upload4 = Fabricate(:upload)
 
       set_cdn_url "https://awesome.com/somepath"
 
@@ -1375,7 +1376,7 @@ describe Post do
 
       ![](#{upload1.short_url})
 
-      "#{GlobalSetting.cdn_url}#{upload1.url}"
+      "#{GlobalSetting.cdn_url}#{upload4.url}"
 
       <a href='#{Discourse.base_url}#{upload2.url}'>Link to upload</a>
       ![](http://example.com/external.png)
@@ -1392,15 +1393,15 @@ describe Post do
       end
 
       expect(urls).to contain_exactly(
-        upload1.url,
         "#{GlobalSetting.cdn_url}#{upload1.url}",
+        "#{GlobalSetting.cdn_url}#{upload4.url}",
         "#{Discourse.base_url}#{upload2.url}",
         "#{Discourse.base_url}#{upload3.short_path}"
       )
 
       expect(paths).to contain_exactly(
         upload1.url,
-        upload1.url,
+        upload4.url,
         upload2.url,
         nil
       )

GitHub sha: 129e308d