about summary refs log tree commit diff
path: root/spec/services/fetch_link_card_service_spec.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-12-17 19:19:45 +0100
committerEugen Rochko <eugen@zeonfederated.com>2018-12-17 19:19:45 +0100
commite709b8da0d685d3cc48d430a9761896094f67d72 (patch)
tree8d60d548237c7478bb974e2813288fdda11a8862 /spec/services/fetch_link_card_service_spec.rb
parent4ede51743e5b9121a49e9131f91cf012fab410f8 (diff)
Ignore low-confidence CharlockHolmes guesses when parsing link cards (#9510)
* Add failing test for windows-1251 link cards

* Ignore low-confidence CharlockHolmes guesses

Fixes #9466

* Fix no method error when charlock holmes cannot detect charset
Diffstat (limited to 'spec/services/fetch_link_card_service_spec.rb')
-rw-r--r--spec/services/fetch_link_card_service_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb
index 88c5339db..50c60aafd 100644
--- a/spec/services/fetch_link_card_service_spec.rb
+++ b/spec/services/fetch_link_card_service_spec.rb
@@ -17,6 +17,8 @@ RSpec.describe FetchLinkCardService, type: :service do
     stub_request(:head, 'https://github.com/qbi/WannaCry').to_return(status: 404)
     stub_request(:head, 'http://example.com/test-').to_return(status: 200, headers: { 'Content-Type' => 'text/html' })
     stub_request(:get, 'http://example.com/test-').to_return(request_fixture('idn.txt'))
+    stub_request(:head, 'http://example.com/windows-1251').to_return(status: 200, headers: { 'Content-Type' => 'text/html' })
+    stub_request(:get, 'http://example.com/windows-1251').to_return(request_fixture('windows-1251.txt'))
 
     subject.call(status)
   end
@@ -58,6 +60,15 @@ RSpec.describe FetchLinkCardService, type: :service do
     end
 
     context do
+      let(:status) { Fabricate(:status, text: 'Check out http://example.com/windows-1251') }
+
+      it 'works with windows-1251' do
+        expect(a_request(:get, 'http://example.com/windows-1251')).to have_been_made.at_least_once
+        expect(status.preview_cards.first.title).to eq('сэмпл текст')
+      end
+    end
+
+    context do
       let(:status) { Fabricate(:status, text: 'テストhttp://example.com/日本語') }
 
       it 'works with Japanese path string' do