Merge pull request #599 from kmycode/upstream-20240218
Upstream 20240218
This commit is contained in:
commit
f9100f1d93
147 changed files with 3454 additions and 2567 deletions
24
spec/services/after_unallow_domain_service_spec.rb
Normal file
24
spec/services/after_unallow_domain_service_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AfterUnallowDomainService do
|
||||
describe '#call' do
|
||||
context 'with accounts for a domain' do
|
||||
let!(:account) { Fabricate(:account, domain: 'host.example') }
|
||||
let!(:test_account) { Fabricate(:account, domain: 'test.example') }
|
||||
let(:service_double) { instance_double(DeleteAccountService, call: true) }
|
||||
|
||||
before { allow(DeleteAccountService).to receive(:new).and_return(service_double) }
|
||||
|
||||
it 'calls the delete service for accounts from the relevant domain' do
|
||||
subject.call 'test.example'
|
||||
|
||||
expect(service_double)
|
||||
.to_not have_received(:call).with(account, reserve_username: false)
|
||||
expect(service_double)
|
||||
.to have_received(:call).with(test_account, reserve_username: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
spec/services/appeal_service_spec.rb
Normal file
40
spec/services/appeal_service_spec.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AppealService do
|
||||
describe '#call' do
|
||||
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||
|
||||
context 'with an existing strike' do
|
||||
let(:strike) { Fabricate(:account_warning) }
|
||||
let(:text) { 'Appeal text' }
|
||||
|
||||
it 'creates an appeal and notifies staff' do
|
||||
emails = capture_emails { subject.call(strike, text) }
|
||||
|
||||
expect(Appeal.last)
|
||||
.to have_attributes(
|
||||
strike: strike,
|
||||
text: text,
|
||||
account: strike.target_account
|
||||
)
|
||||
|
||||
expect(emails.size)
|
||||
.to eq(1)
|
||||
|
||||
expect(emails.first)
|
||||
.to have_attributes(
|
||||
to: contain_exactly(admin.email),
|
||||
subject: eq(
|
||||
I18n.t(
|
||||
'admin_mailer.new_appeal.subject',
|
||||
username: strike.target_account.acct,
|
||||
instance: Rails.configuration.x.local_domain
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
31
spec/services/create_featured_tag_service_spec.rb
Normal file
31
spec/services/create_featured_tag_service_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CreateFeaturedTagService do
|
||||
describe '#call' do
|
||||
let(:tag) { 'test' }
|
||||
|
||||
context 'with a local account' do
|
||||
let(:account) { Fabricate(:account, domain: nil) }
|
||||
|
||||
it 'creates a new featured tag and distributes' do
|
||||
expect { subject.call(account, tag) }
|
||||
.to change(FeaturedTag, :count).by(1)
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to have_enqueued_sidekiq_job(anything, account.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a remote account' do
|
||||
let(:account) { Fabricate(:account, domain: 'host.example') }
|
||||
|
||||
it 'creates a new featured tag and does not distributes' do
|
||||
expect { subject.call(account, tag) }
|
||||
.to change(FeaturedTag, :count).by(1)
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to_not have_enqueued_sidekiq_job
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -157,8 +157,6 @@ RSpec.describe NotifyService, type: :service do
|
|||
|
||||
describe 'email' do
|
||||
before do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
user.settings.update('notification_emails.follow': enabled)
|
||||
user.save
|
||||
end
|
||||
|
@ -167,7 +165,15 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { true }
|
||||
|
||||
it 'sends email', :sidekiq_inline do
|
||||
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
|
||||
emails = capture_emails { subject }
|
||||
|
||||
expect(emails.size)
|
||||
.to eq(1)
|
||||
expect(emails.first)
|
||||
.to have_attributes(
|
||||
to: contain_exactly(user.email),
|
||||
subject: eq(I18n.t('notification_mailer.follow.subject', name: sender.acct))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -175,7 +181,9 @@ RSpec.describe NotifyService, type: :service do
|
|||
let(:enabled) { false }
|
||||
|
||||
it "doesn't send email" do
|
||||
expect { subject }.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||
emails = capture_emails { subject }
|
||||
|
||||
expect(emails).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
16
spec/services/process_hashtags_service_spec.rb
Normal file
16
spec/services/process_hashtags_service_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessHashtagsService do
|
||||
describe '#call' do
|
||||
let(:status) { Fabricate(:status, visibility: :public, text: 'With tags #one #two') }
|
||||
|
||||
it 'applies the tags from the status text' do
|
||||
expect { subject.call(status) }
|
||||
.to change(Tag, :count).by(2)
|
||||
expect(status.reload.tags.map(&:name))
|
||||
.to contain_exactly('one', 'two')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -158,13 +158,14 @@ RSpec.describe ReportService, type: :service do
|
|||
|
||||
before do
|
||||
Fabricate(:report, target_account: target_account)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
source_account.user.settings['notification_emails.report'] = true
|
||||
source_account.user.save
|
||||
end
|
||||
|
||||
it 'does not send an e-mail' do
|
||||
expect { subject.call }.to_not change(ActionMailer::Base.deliveries, :count).from(0)
|
||||
emails = capture_emails { subject.call }
|
||||
|
||||
expect(emails).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue