mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-06 06:55:04 +00:00
Treat non-null but blank account domain as local (#33576)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
This commit is contained in:
parent
e1d7efadc0
commit
68c9f91ccb
|
@ -126,6 +126,8 @@ class Account < ApplicationRecord
|
|||
validates :uri, absence: true
|
||||
end
|
||||
|
||||
validates :domain, exclusion: { in: [''] }
|
||||
|
||||
normalizes :username, with: ->(username) { username.squish }
|
||||
|
||||
scope :without_internal, -> { where(id: 1...) }
|
||||
|
@ -187,7 +189,7 @@ class Account < ApplicationRecord
|
|||
end
|
||||
|
||||
def remote?
|
||||
domain.present?
|
||||
!domain.nil?
|
||||
end
|
||||
|
||||
def moved?
|
||||
|
|
|
@ -49,14 +49,16 @@ RSpec.describe Account do
|
|||
end
|
||||
|
||||
describe '#local?' do
|
||||
it 'returns true when domain is null' do
|
||||
account = Fabricate(:account, domain: nil)
|
||||
expect(account).to be_local
|
||||
context 'when the domain is null' do
|
||||
subject { Fabricate.build :account, domain: nil }
|
||||
|
||||
it { is_expected.to be_local }
|
||||
end
|
||||
|
||||
it 'returns false when domain is present' do
|
||||
account = Fabricate(:account, domain: 'foreign.tld')
|
||||
expect(account).to_not be_local
|
||||
context 'when the domain is present' do
|
||||
subject { Fabricate.build :account, domain: 'host.example' }
|
||||
|
||||
it { is_expected.to_not be_local }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,12 +69,6 @@ RSpec.describe Account do
|
|||
it { is_expected.to_not be_remote }
|
||||
end
|
||||
|
||||
context 'when the domain is blank' do
|
||||
subject { Fabricate.build :account, domain: '' }
|
||||
|
||||
it { is_expected.to_not be_remote }
|
||||
end
|
||||
|
||||
context 'when the domain is present' do
|
||||
subject { Fabricate.build :account, domain: 'host.example' }
|
||||
|
||||
|
@ -557,6 +553,8 @@ RSpec.describe Account do
|
|||
describe 'Validations' do
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
|
||||
it { is_expected.to_not allow_value('').for(:domain) }
|
||||
|
||||
context 'when account is local' do
|
||||
subject { Fabricate.build :account, domain: nil }
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ RSpec.describe ImportService, :inline_jobs do
|
|||
subject { described_class.new }
|
||||
|
||||
let(:csv) { attachment_fixture('bookmark-imports.txt') }
|
||||
let(:local_account) { Fabricate(:account, username: 'foo', domain: '') }
|
||||
let(:local_account) { Fabricate(:account, username: 'foo', domain: nil) }
|
||||
let!(:remote_status) { Fabricate(:status, uri: 'https://example.com/statuses/1312') }
|
||||
let!(:direct_status) { Fabricate(:status, uri: 'https://example.com/statuses/direct', visibility: :direct) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user