Allow more flexible host/port treatment with LOCAL_DOMAIN values in tests (#35040)

This commit is contained in:
Matt Jankowski
2025-06-16 09:12:23 -04:00
committed by GitHub
parent b2506478ba
commit ca3cc36549
9 changed files with 32 additions and 12 deletions

View File

@@ -5,6 +5,14 @@ require 'rails_helper'
RSpec.describe PublishScheduledAnnouncementWorker do
subject { described_class.new }
around do |example|
original_web_domain = Rails.configuration.x.web_domain
original_default_host = Rails.configuration.action_mailer.default_url_options[:host]
example.run
Rails.configuration.x.web_domain = original_web_domain
Rails.configuration.action_mailer.default_url_options[:host] = original_default_host
end
let!(:remote_account) { Fabricate(:account, domain: 'domain.com', username: 'foo', uri: 'https://domain.com/users/foo') }
let!(:remote_status) { Fabricate(:status, uri: 'https://domain.com/users/foo/12345', account: remote_account) }
let!(:local_status) { Fabricate(:status) }
@@ -12,15 +20,16 @@ RSpec.describe PublishScheduledAnnouncementWorker do
describe 'perform' do
before do
Rails.configuration.x.web_domain = 'mastodon.social' # The TwitterText Regex needs a real/plausible link target
Rails.configuration.action_mailer.default_url_options[:host] = Rails.configuration.x.web_domain
service = instance_double(FetchRemoteStatusService)
allow(FetchRemoteStatusService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('https://domain.com/users/foo/12345') { remote_status.reload }
subject.perform(scheduled_announcement.id)
end
it 'updates the linked statuses' do
expect(scheduled_announcement.reload.status_ids).to eq [remote_status.id, local_status.id]
expect { subject.perform(scheduled_announcement.id) }
.to change { scheduled_announcement.reload.status_ids }.from(nil).to([remote_status.id, local_status.id])
end
end
end