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/.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 6ec3141fe6..7990175806 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 diff --git a/Gemfile.lock b/Gemfile.lock index a625765faf..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) @@ -793,7 +794,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) diff --git a/app/models/account.rb b/app/models/account.rb index d332edc149..ad8f4714eb 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/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', }; 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) } 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