Merge pull request #2942 from ClearlyClaire/glitch-soc/merge-upstream

Merge upstream changes up to c20824fa76
This commit is contained in:
Claire 2025-01-15 22:20:30 +01:00 committed by GitHub
commit 6394261d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 66 additions and 29 deletions

View file

@ -43,4 +43,4 @@ jobs:
- name: Run haml-lint - name: Run haml-lint
run: | run: |
echo "::add-matcher::.github/workflows/haml-lint-problem-matcher.json" echo "::add-matcher::.github/workflows/haml-lint-problem-matcher.json"
bin/haml-lint --reporter github bin/haml-lint --parallel --reporter github

View file

@ -58,3 +58,6 @@ Style/TrailingCommaInArrayLiteral:
Style/TrailingCommaInHashLiteral: Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma EnforcedStyleForMultiline: comma
Style/WordArray:
MinSize: 3 # Override default of 2

View file

@ -1,6 +1,6 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp` # `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.69.2. # using RuboCop version 1.70.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
@ -103,10 +103,3 @@ Style/RedundantConstantBase:
Exclude: Exclude:
- 'config/environments/production.rb' - 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb' - 'config/initializers/sidekiq.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 3

View file

@ -529,7 +529,7 @@ GEM
opentelemetry-instrumentation-rack (0.25.0) opentelemetry-instrumentation-rack (0.25.0)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1) opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-rails (0.34.0) opentelemetry-instrumentation-rails (0.34.1)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-action_mailer (~> 0.3.0) opentelemetry-instrumentation-action_mailer (~> 0.3.0)
opentelemetry-instrumentation-action_pack (~> 0.10.0) opentelemetry-instrumentation-action_pack (~> 0.10.0)
@ -538,6 +538,7 @@ GEM
opentelemetry-instrumentation-active_record (~> 0.8.0) opentelemetry-instrumentation-active_record (~> 0.8.0)
opentelemetry-instrumentation-active_support (~> 0.7.0) opentelemetry-instrumentation-active_support (~> 0.7.0)
opentelemetry-instrumentation-base (~> 0.22.1) opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-concurrent_ruby (~> 0.21.4)
opentelemetry-instrumentation-redis (0.25.7) opentelemetry-instrumentation-redis (0.25.7)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1) opentelemetry-instrumentation-base (~> 0.22.1)
@ -793,7 +794,7 @@ GEM
simplecov-html (0.13.1) simplecov-html (0.13.1)
simplecov-lcov (0.8.0) simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4) simplecov_json_formatter (0.1.4)
stackprof (0.2.26) stackprof (0.2.27)
stoplight (4.1.0) stoplight (4.1.0)
redlock (~> 1.0) redlock (~> 1.0)
stringio (3.1.2) stringio (3.1.2)

View file

@ -126,6 +126,8 @@ class Account < ApplicationRecord
validates :uri, absence: true validates :uri, absence: true
end end
validates :domain, exclusion: { in: [''] }
normalizes :username, with: ->(username) { username.squish } normalizes :username, with: ->(username) { username.squish }
scope :without_internal, -> { where(id: 1...) } scope :without_internal, -> { where(id: 1...) }
@ -187,7 +189,7 @@ class Account < ApplicationRecord
end end
def remote? def remote?
domain.present? !domain.nil?
end end
def moved? def moved?

View file

@ -3,7 +3,7 @@ const config = {
'Gemfile|*.{rb,ruby,ru,rake}': 'bin/rubocop --force-exclusion -a', 'Gemfile|*.{rb,ruby,ru,rake}': 'bin/rubocop --force-exclusion -a',
'*.{js,jsx,ts,tsx}': 'eslint --fix', '*.{js,jsx,ts,tsx}': 'eslint --fix',
'*.{css,scss}': 'stylelint --fix', '*.{css,scss}': 'stylelint --fix',
'*.haml': 'bin/haml-lint -a', '*.haml': 'bin/haml-lint -a --parallel',
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit', '**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
}; };

View file

@ -49,14 +49,16 @@ RSpec.describe Account do
end end
describe '#local?' do describe '#local?' do
it 'returns true when domain is null' do context 'when the domain is null' do
account = Fabricate(:account, domain: nil) subject { Fabricate.build :account, domain: nil }
expect(account).to be_local
it { is_expected.to be_local }
end end
it 'returns false when domain is present' do context 'when the domain is present' do
account = Fabricate(:account, domain: 'foreign.tld') subject { Fabricate.build :account, domain: 'host.example' }
expect(account).to_not be_local
it { is_expected.to_not be_local }
end end
end end
@ -67,12 +69,6 @@ RSpec.describe Account do
it { is_expected.to_not be_remote } it { is_expected.to_not be_remote }
end 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 context 'when the domain is present' do
subject { Fabricate.build :account, domain: 'host.example' } subject { Fabricate.build :account, domain: 'host.example' }
@ -557,6 +553,8 @@ RSpec.describe Account do
describe 'Validations' do describe 'Validations' do
it { is_expected.to validate_presence_of(:username) } it { is_expected.to validate_presence_of(:username) }
it { is_expected.to_not allow_value('').for(:domain) }
context 'when account is local' do context 'when account is local' do
subject { Fabricate.build :account, domain: nil } subject { Fabricate.build :account, domain: nil }

View file

@ -204,7 +204,7 @@ RSpec.describe ImportService, :inline_jobs do
subject { described_class.new } subject { described_class.new }
let(:csv) { attachment_fixture('bookmark-imports.txt') } 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!(:remote_status) { Fabricate(:status, uri: 'https://example.com/statuses/1312') }
let!(:direct_status) { Fabricate(:status, uri: 'https://example.com/statuses/direct', visibility: :direct) } let!(:direct_status) { Fabricate(:status, uri: 'https://example.com/statuses/direct', visibility: :direct) }

View file

@ -5,9 +5,7 @@ require 'rails_helper'
RSpec.describe 'Admin::EmailDomainBlocks' do RSpec.describe 'Admin::EmailDomainBlocks' do
let(:current_user) { Fabricate(:admin_user) } let(:current_user) { Fabricate(:admin_user) }
before do before { sign_in current_user }
sign_in current_user
end
describe 'Performing batch updates' do describe 'Performing batch updates' do
before do before do
@ -22,6 +20,27 @@ RSpec.describe 'Admin::EmailDomainBlocks' do
end end
end end
context 'with a selected block' do
let!(:email_domain_block) { Fabricate :email_domain_block }
it 'deletes the block' do
visit admin_email_domain_blocks_path
check_item
expect { click_on button_for_delete }
.to change(EmailDomainBlock, :count).by(-1)
expect { email_domain_block.reload }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
def check_item
within '.batch-table__row' do
find('input[type=checkbox]').check
end
end
def button_for_delete def button_for_delete
I18n.t('admin.email_domain_blocks.delete') I18n.t('admin.email_domain_blocks.delete')
end end

View file

@ -48,6 +48,27 @@ RSpec.describe 'Admin::IpBlocks' do
end end
end end
context 'with a selected block' do
let!(:ip_block) { Fabricate :ip_block }
it 'deletes the block' do
visit admin_ip_blocks_path
check_item
expect { click_on button_for_delete }
.to change(IpBlock, :count).by(-1)
expect { ip_block.reload }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
def check_item
within '.batch-table__row' do
find('input[type=checkbox]').check
end
end
def button_for_delete def button_for_delete
I18n.t('admin.ip_blocks.delete') I18n.t('admin.ip_blocks.delete')
end end