summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-11-05 23:23:05 +0100
committerGitHub <noreply@github.com>2021-11-05 23:23:05 +0100
commit39cdf61ab7be267a374c472c230b315971ead43c (patch)
tree990744c23f78c62a078d65d39f07c7d70a1e1c67 /spec
parent989c67d29d379f872f23a513f43d5100630c1b12 (diff)
Add support for structured data and more OpenGraph tags to link cards (#16938)
Save preview cards under their canonical URL Increase max redirects to follow from 2 to 3
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/link_details_extractor_spec.rb29
-rw-r--r--spec/services/fetch_link_card_service_spec.rb2
2 files changed, 30 insertions, 1 deletions
diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb
new file mode 100644
index 00000000000..850857b2dd1
--- /dev/null
+++ b/spec/lib/link_details_extractor_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.describe LinkDetailsExtractor do
+ let(:original_url) { '' }
+ let(:html) { '' }
+ let(:html_charset) { nil }
+
+ subject { described_class.new(original_url, html, html_charset) }
+
+ describe '#canonical_url' do
+ let(:original_url) { 'https://foo.com/article?bar=baz123' }
+
+ context 'when canonical URL points to another host' do
+ let(:html) { '<!doctype html><link rel="canonical" href="https://bar.com/different-article" />' }
+
+ it 'ignores the canonical URLs' do
+ expect(subject.canonical_url).to eq original_url
+ end
+ end
+
+ context 'when canonical URL points to the same host' do
+ let(:html) { '<!doctype html><link rel="canonical" href="https://foo.com/article" />' }
+
+ it 'ignores the canonical URLs' do
+ expect(subject.canonical_url).to eq 'https://foo.com/article'
+ end
+ end
+ end
+end
diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb
index 736a6078dd6..4914c275326 100644
--- a/spec/services/fetch_link_card_service_spec.rb
+++ b/spec/services/fetch_link_card_service_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
RSpec.describe FetchLinkCardService, type: :service do
- subject { FetchLinkCardService.new }
+ subject { described_class.new }
before do
stub_request(:get, 'http://example.xn--fiqs8s/').to_return(request_fixture('idn.txt'))