From 68c9f91ccb46b14ce43424479b3ff8ab28800997 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 14 Jan 2025 12:40:55 -0500 Subject: [PATCH 1/6] Treat non-null but blank account domain as local (#33576) --- app/models/account.rb | 4 +++- spec/models/account_spec.rb | 22 ++++++++++------------ spec/services/import_service_spec.rb | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 6258857b1b..05e833d575 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -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? diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 5b995b4af6..a0187b6211 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -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 } diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index 0a99c5e748..2e1358c635 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -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) } From 9f03e5b53ae0c4088ea989b3ad4e3555e33daaa1 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 15 Jan 2025 02:47:34 -0500 Subject: [PATCH 2/6] Expand coverage of `admin/*blocks` areas (#33594) --- spec/system/admin/email_domain_blocks_spec.rb | 25 ++++++++++++++++--- spec/system/admin/ip_blocks_spec.rb | 21 ++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/spec/system/admin/email_domain_blocks_spec.rb b/spec/system/admin/email_domain_blocks_spec.rb index acf5027eda..807cfb3768 100644 --- a/spec/system/admin/email_domain_blocks_spec.rb +++ b/spec/system/admin/email_domain_blocks_spec.rb @@ -5,9 +5,7 @@ require 'rails_helper' RSpec.describe 'Admin::EmailDomainBlocks' do let(:current_user) { Fabricate(:admin_user) } - before do - sign_in current_user - end + before { sign_in current_user } describe 'Performing batch updates' do before do @@ -22,6 +20,27 @@ RSpec.describe 'Admin::EmailDomainBlocks' do 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 I18n.t('admin.email_domain_blocks.delete') end diff --git a/spec/system/admin/ip_blocks_spec.rb b/spec/system/admin/ip_blocks_spec.rb index 8e8c8031c8..3bed506b68 100644 --- a/spec/system/admin/ip_blocks_spec.rb +++ b/spec/system/admin/ip_blocks_spec.rb @@ -48,6 +48,27 @@ RSpec.describe 'Admin::IpBlocks' do 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 I18n.t('admin.ip_blocks.delete') end From 1ae574e32a634850141f02625958a1c69d2acefb Mon Sep 17 00:00:00 2001 From: fusagiko / takayamaki <24884114+takayamaki@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:48:26 +0900 Subject: [PATCH 3/6] Enable parallel execution for linting tasks in HAML workflows (#33593) --- .github/workflows/lint-haml.yml | 2 +- lint-staged.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-haml.yml b/.github/workflows/lint-haml.yml index 499be2010a..9361358078 100644 --- a/.github/workflows/lint-haml.yml +++ b/.github/workflows/lint-haml.yml @@ -43,4 +43,4 @@ jobs: - name: Run haml-lint run: | echo "::add-matcher::.github/workflows/haml-lint-problem-matcher.json" - bin/haml-lint --reporter github + bin/haml-lint --parallel --reporter github diff --git a/lint-staged.config.js b/lint-staged.config.js index 63f5258a94..baf5d0d454 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -3,7 +3,7 @@ const config = { 'Gemfile|*.{rb,ruby,ru,rake}': 'bin/rubocop --force-exclusion -a', '*.{js,jsx,ts,tsx}': 'eslint --fix', '*.{css,scss}': 'stylelint --fix', - '*.haml': 'bin/haml-lint -a', + '*.haml': 'bin/haml-lint -a --parallel', '**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit', }; From 2a0951e98780f71ee7e672d33e2b9f9560cc9d98 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:48:52 +0100 Subject: [PATCH 4/6] Update dependency stackprof to v0.2.27 (#33596) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a625765faf..3bc530f983 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -793,7 +793,7 @@ GEM simplecov-html (0.13.1) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - stackprof (0.2.26) + stackprof (0.2.27) stoplight (4.1.0) redlock (~> 1.0) stringio (3.1.2) From ea01ecd44103b34a6b5a0a115aba9509ed24850e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:49:12 +0100 Subject: [PATCH 5/6] Update dependency opentelemetry-instrumentation-rails to v0.34.1 (#33595) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3bc530f983..a4c5f8ad98 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -529,7 +529,7 @@ GEM opentelemetry-instrumentation-rack (0.25.0) opentelemetry-api (~> 1.0) opentelemetry-instrumentation-base (~> 0.22.1) - opentelemetry-instrumentation-rails (0.34.0) + opentelemetry-instrumentation-rails (0.34.1) opentelemetry-api (~> 1.0) opentelemetry-instrumentation-action_mailer (~> 0.3.0) opentelemetry-instrumentation-action_pack (~> 0.10.0) @@ -538,6 +538,7 @@ GEM opentelemetry-instrumentation-active_record (~> 0.8.0) opentelemetry-instrumentation-active_support (~> 0.7.0) opentelemetry-instrumentation-base (~> 0.22.1) + opentelemetry-instrumentation-concurrent_ruby (~> 0.21.4) opentelemetry-instrumentation-redis (0.25.7) opentelemetry-api (~> 1.0) opentelemetry-instrumentation-base (~> 0.22.1) From c20824fa760061cf8fba258dbbd6b0a615df4749 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 15 Jan 2025 09:29:14 -0500 Subject: [PATCH 6/6] Promote `Style/WordArray` rule out of todo into main config (#33580) --- .rubocop/style.yml | 3 +++ .rubocop_todo.yml | 9 +-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.rubocop/style.yml b/.rubocop/style.yml index df1da2ba36..f59340d452 100644 --- a/.rubocop/style.yml +++ b/.rubocop/style.yml @@ -58,3 +58,6 @@ Style/TrailingCommaInArrayLiteral: Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: comma + +Style/WordArray: + MinSize: 3 # Override default of 2 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 12ef0ad620..38aec67bef 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `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 # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -103,10 +103,3 @@ Style/RedundantConstantBase: Exclude: - 'config/environments/production.rb' - 'config/initializers/sidekiq.rb' - -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 3