From 39cdf61ab7be267a374c472c230b315971ead43c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 5 Nov 2021 23:23:05 +0100 Subject: 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 --- spec/lib/link_details_extractor_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 spec/lib/link_details_extractor_spec.rb (limited to 'spec/lib/link_details_extractor_spec.rb') diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb new file mode 100644 index 000000000..850857b2d --- /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) { '' } + + 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) { '' } + + it 'ignores the canonical URLs' do + expect(subject.canonical_url).to eq 'https://foo.com/article' + end + end + end +end -- cgit