2017-04-25 10:47:31 +10:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe FetchLinkCardService do
|
|
|
|
before do
|
2017-05-11 07:30:07 +10:00
|
|
|
stub_request(:head, 'http://example.xn--fiqs8s/').to_return(status: 200, headers: { 'Content-Type' => 'text/html' })
|
2017-04-25 10:47:31 +10:00
|
|
|
stub_request(:get, 'http://example.xn--fiqs8s/').to_return(request_fixture('idn.txt'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'works with IDN URLs' do
|
|
|
|
status = Fabricate(:status, text: 'Check out http://example.中国')
|
|
|
|
|
|
|
|
FetchLinkCardService.new.call(status)
|
2017-04-27 22:42:22 +10:00
|
|
|
expect(a_request(:get, 'http://example.xn--fiqs8s/')).to have_been_made.at_least_once
|
2017-04-25 10:47:31 +10:00
|
|
|
end
|
|
|
|
end
|