mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 01:41:08 +00:00
Allow more flexible host/port treatment with LOCAL_DOMAIN values in tests (#35040)
This commit is contained in:
parent
b2506478ba
commit
ca3cc36549
|
@ -101,7 +101,7 @@ RSpec.describe HomeHelper do
|
||||||
allow(helper).to receive(:closed_registrations?).and_return(true)
|
allow(helper).to receive(:closed_registrations?).and_return(true)
|
||||||
result = helper.sign_up_message
|
result = helper.sign_up_message
|
||||||
|
|
||||||
expect(result).to eq t('auth.registration_closed', instance: Rails.configuration.x.local_domain)
|
expect(result).to eq t('auth.registration_closed', instance: local_domain_uri.host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ RSpec.describe UserMailer do
|
||||||
expect(mail)
|
expect(mail)
|
||||||
.to be_present
|
.to be_present
|
||||||
.and(have_subject(I18n.t('user_mailer.announcement_published.subject')))
|
.and(have_subject(I18n.t('user_mailer.announcement_published.subject')))
|
||||||
.and(have_body_text(I18n.t('user_mailer.announcement_published.description', domain: Rails.configuration.x.local_domain)))
|
.and(have_body_text(I18n.t('user_mailer.announcement_published.description', domain: local_domain_uri.host)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,7 +61,16 @@ RSpec.describe RemoteFollow do
|
||||||
let(:account) { Fabricate(:account, username: 'alice') }
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
it 'returns subscribe address' do
|
it 'returns subscribe address' do
|
||||||
expect(subject).to eq "https://quitter.no/main/ostatussub?profile=https%3A%2F%2F#{Rails.configuration.x.local_domain}%2Fusers%2Falice"
|
expect(subject).to eq(expected_subscribe_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def expected_subscribe_url
|
||||||
|
Addressable::URI.new(
|
||||||
|
host: 'quitter.no',
|
||||||
|
path: '/main/ostatussub',
|
||||||
|
query_values: { profile: "https://#{Rails.configuration.x.local_domain}/users/alice" },
|
||||||
|
scheme: 'https'
|
||||||
|
).to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe 'Statuses' do
|
||||||
include AccountsHelper
|
include AccountsHelper
|
||||||
|
|
||||||
def site_hostname
|
def site_hostname
|
||||||
Rails.configuration.x.web_domain || Rails.configuration.x.local_domain
|
local_domain_uri.host
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has valid opengraph tags' do
|
it 'has valid opengraph tags' do
|
||||||
|
|
|
@ -47,6 +47,10 @@ module DomainHelpers
|
||||||
.and_yield(resolver)
|
.and_yield(resolver)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_domain_uri
|
||||||
|
Addressable::URI.parse("//#{Rails.configuration.x.local_domain}")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def double_mx(exchange)
|
def double_mx(exchange)
|
||||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe 'email confirmation flow when captcha is enabled' do
|
||||||
|
|
||||||
# It presents a page with a link to the app callback
|
# It presents a page with a link to the app callback
|
||||||
expect(page)
|
expect(page)
|
||||||
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: Rails.configuration.x.local_domain))
|
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: local_domain_uri.host))
|
||||||
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,6 @@ require 'rails_helper'
|
||||||
RSpec.describe 'Profile' do
|
RSpec.describe 'Profile' do
|
||||||
include ProfileStories
|
include ProfileStories
|
||||||
|
|
||||||
let(:local_domain) { Rails.configuration.x.local_domain }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
as_a_logged_in_user
|
as_a_logged_in_user
|
||||||
Fabricate(:user, account: Fabricate(:account, username: 'alice'))
|
Fabricate(:user, account: Fabricate(:account, username: 'alice'))
|
||||||
|
@ -16,7 +14,7 @@ RSpec.describe 'Profile' do
|
||||||
visit account_path('alice')
|
visit account_path('alice')
|
||||||
|
|
||||||
expect(page)
|
expect(page)
|
||||||
.to have_title("alice (@alice@#{local_domain})")
|
.to have_title("alice (@alice@#{local_domain_uri.host})")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'I can change my account' do
|
it 'I can change my account' do
|
||||||
|
|
|
@ -31,6 +31,6 @@ RSpec.describe 'redirection confirmations' do
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_title
|
def redirect_title
|
||||||
I18n.t('redirects.title', instance: Rails.configuration.x.local_domain)
|
I18n.t('redirects.title', instance: local_domain_uri.host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,14 @@ require 'rails_helper'
|
||||||
RSpec.describe PublishScheduledAnnouncementWorker do
|
RSpec.describe PublishScheduledAnnouncementWorker do
|
||||||
subject { described_class.new }
|
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_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!(:remote_status) { Fabricate(:status, uri: 'https://domain.com/users/foo/12345', account: remote_account) }
|
||||||
let!(:local_status) { Fabricate(:status) }
|
let!(:local_status) { Fabricate(:status) }
|
||||||
|
@ -12,15 +20,16 @@ RSpec.describe PublishScheduledAnnouncementWorker do
|
||||||
|
|
||||||
describe 'perform' do
|
describe 'perform' do
|
||||||
before 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)
|
service = instance_double(FetchRemoteStatusService)
|
||||||
allow(FetchRemoteStatusService).to receive(:new).and_return(service)
|
allow(FetchRemoteStatusService).to receive(:new).and_return(service)
|
||||||
allow(service).to receive(:call).with('https://domain.com/users/foo/12345') { remote_status.reload }
|
allow(service).to receive(:call).with('https://domain.com/users/foo/12345') { remote_status.reload }
|
||||||
|
|
||||||
subject.perform(scheduled_announcement.id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the linked statuses' do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user