Skip to content

Commit

Permalink
Merge pull request #2942 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to c20824f
  • Loading branch information
ClearlyClaire authored Jan 15, 2025
2 parents e489410 + ad71a8d commit 6394261
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-haml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions .rubocop/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ Style/TrailingCommaInArrayLiteral:

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma

Style/WordArray:
MinSize: 3 # Override default of 2
9 changes: 1 addition & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
5 changes: 3 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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...) }
Expand Down Expand Up @@ -187,7 +189,7 @@ def local?
end

def remote?
domain.present?
!domain.nil?
end

def moved?
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down
22 changes: 10 additions & 12 deletions spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@
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

Expand All @@ -67,12 +69,6 @@
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' }

Expand Down Expand Up @@ -557,6 +553,8 @@
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 }

Expand Down
2 changes: 1 addition & 1 deletion spec/services/import_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
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) }

Expand Down
25 changes: 22 additions & 3 deletions spec/system/admin/email_domain_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
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
Expand All @@ -22,6 +20,27 @@
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
Expand Down
21 changes: 21 additions & 0 deletions spec/system/admin/ip_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ def submit_form
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
Expand Down

0 comments on commit 6394261

Please sign in to comment.