mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-14 16:28:16 +00:00
Compare commits
3 Commits
e6f232a792
...
43fc4fe04a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
43fc4fe04a | ||
![]() |
6ad46f2b18 | ||
![]() |
2cf9ebe9b6 |
|
@ -73,6 +73,7 @@ class FetchLinkCardService < BaseService
|
||||||
PreviewCardsStatus.create(status: @status, preview_card: @card, url: @original_url)
|
PreviewCardsStatus.create(status: @status, preview_card: @card, url: @original_url)
|
||||||
Rails.cache.delete(@status)
|
Rails.cache.delete(@status)
|
||||||
Trends.links.register(@status)
|
Trends.links.register(@status)
|
||||||
|
DistributionWorker.perform_async(@status.id, { update: true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ RSpec.describe FetchLinkCardService do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
let(:html) { '<!doctype html><title>Hello world</title>' }
|
let(:html) { '<!doctype html><title>Hello world</title>' }
|
||||||
|
let(:status) { Fabricate(:status, text: 'http://example.com/html') }
|
||||||
let(:oembed_cache) { nil }
|
let(:oembed_cache) { nil }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -34,11 +35,22 @@ RSpec.describe FetchLinkCardService do
|
||||||
stub_request(:get, 'http://example.com/long_canonical_url').to_return(request_fixture('long_canonical_url.txt'))
|
stub_request(:get, 'http://example.com/long_canonical_url').to_return(request_fixture('long_canonical_url.txt'))
|
||||||
stub_request(:get, 'http://example.com/alternative_utf8_spelling_in_header').to_return(request_fixture('alternative_utf8_spelling_in_header.txt'))
|
stub_request(:get, 'http://example.com/alternative_utf8_spelling_in_header').to_return(request_fixture('alternative_utf8_spelling_in_header.txt'))
|
||||||
|
|
||||||
|
allow(DistributionWorker).to receive(:perform_async)
|
||||||
|
allow(Trends.links).to receive(:register)
|
||||||
|
|
||||||
Rails.cache.write('oembed_endpoint:example.com', oembed_cache) if oembed_cache
|
Rails.cache.write('oembed_endpoint:example.com', oembed_cache) if oembed_cache
|
||||||
|
|
||||||
subject.call(status)
|
subject.call(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'registers trends' do
|
||||||
|
expect(Trends.links).to have_received(:register).with(status)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redistributes status' do
|
||||||
|
expect(DistributionWorker).to have_received(:perform_async).with(status.id, { update: true })
|
||||||
|
end
|
||||||
|
|
||||||
context 'with a local status' do
|
context 'with a local status' do
|
||||||
context 'with URL of a regular HTML page' do
|
context 'with URL of a regular HTML page' do
|
||||||
let(:status) { Fabricate(:status, text: 'http://example.com/html') }
|
let(:status) { Fabricate(:status, text: 'http://example.com/html') }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user