Merge branch 'main' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2022-10-28 11:36:25 +02:00
567 changed files with 14361 additions and 20828 deletions

View File

@ -3,40 +3,31 @@
require 'rails_helper'
describe PermalinkRedirector do
let(:remote_account) { Fabricate(:account, username: 'alice', domain: 'example.com', url: 'https://example.com/@alice', id: 2) }
describe '#redirect_url' do
before do
account = Fabricate(:account, username: 'alice', id: 1)
Fabricate(:status, account: account, id: 123)
Fabricate(:status, account: remote_account, id: 123, url: 'https://example.com/status-123')
end
it 'returns path for legacy account links' do
redirector = described_class.new('web/accounts/1')
expect(redirector.redirect_path).to eq 'https://cb6e6126.ngrok.io/@alice'
redirector = described_class.new('accounts/2')
expect(redirector.redirect_path).to eq 'https://example.com/@alice'
end
it 'returns path for legacy status links' do
redirector = described_class.new('web/statuses/123')
expect(redirector.redirect_path).to eq 'https://cb6e6126.ngrok.io/@alice/123'
end
it 'returns path for legacy tag links' do
redirector = described_class.new('web/timelines/tag/hoge')
expect(redirector.redirect_path).to be_nil
redirector = described_class.new('statuses/123')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
it 'returns path for pretty account links' do
redirector = described_class.new('web/@alice')
expect(redirector.redirect_path).to eq 'https://cb6e6126.ngrok.io/@alice'
redirector = described_class.new('@alice@example.com')
expect(redirector.redirect_path).to eq 'https://example.com/@alice'
end
it 'returns path for pretty status links' do
redirector = described_class.new('web/@alice/123')
expect(redirector.redirect_path).to eq 'https://cb6e6126.ngrok.io/@alice/123'
end
it 'returns path for pretty tag links' do
redirector = described_class.new('web/tags/hoge')
expect(redirector.redirect_path).to be_nil
redirector = described_class.new('@alice/123')
expect(redirector.redirect_path).to eq 'https://example.com/status-123'
end
end
end

View File

@ -28,9 +28,5 @@ RSpec.describe Vacuum::PreviewCardsVacuum do
it 'does not delete attached preview cards' do
expect(new_preview_card.reload).to be_persisted
end
it 'deletes preview cards not attached to any status' do
expect { orphaned_preview_card.reload }.to raise_error ActiveRecord::RecordNotFound
end
end
end