Merge remote-tracking branch 'parent/main' into upstream-20231225

This commit is contained in:
KMY 2023-12-25 09:59:33 +09:00
commit 4355dfc64f
151 changed files with 1711 additions and 644 deletions

View file

@ -1163,6 +1163,7 @@ RSpec.describe Account do
it 'returns every usable non-suspended account' do
expect(described_class.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account)
expect(described_class.searchable).to_not include(suspended_local, suspended_remote, unconfirmed, unapproved)
end
it 'does not mess with previously-applied scopes' do

View file

@ -235,13 +235,17 @@ RSpec.describe AccountStatusesCleanupPolicy do
describe '#compute_cutoff_id' do
subject { account_statuses_cleanup_policy.compute_cutoff_id }
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
before { Fabricate(:status, created_at: 3.years.ago) }
context 'when the account has posted multiple toots' do
let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) }
let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) }
let!(:recent_status) { Fabricate(:status, created_at: 2.days.ago, account: account) }
let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) }
before do
Fabricate(:status, created_at: 3.years.ago, account: account)
Fabricate(:status, created_at: 2.days.ago, account: account)
end
it 'returns the most recent id that is still below policy age' do
expect(subject).to eq old_status.id
@ -270,16 +274,16 @@ RSpec.describe AccountStatusesCleanupPolicy do
let!(:faved_secondary) { Fabricate(:status, created_at: 1.year.ago, account: account) }
let!(:reblogged_primary) { Fabricate(:status, created_at: 1.year.ago, account: account) }
let!(:reblogged_secondary) { Fabricate(:status, created_at: 1.year.ago, account: account) }
let!(:recent_status) { Fabricate(:status, created_at: 2.days.ago, account: account) }
let!(:media_attachment) { Fabricate(:media_attachment, account: account, status: status_with_media) }
let!(:status_pin) { Fabricate(:status_pin, account: account, status: pinned_status) }
let!(:favourite) { Fabricate(:favourite, account: account, status: self_faved) }
let!(:bookmark) { Fabricate(:bookmark, account: account, status: self_bookmarked) }
let!(:recent_status) { Fabricate(:status, created_at: 2.days.ago, account: account) }
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
before do
Fabricate(:media_attachment, account: account, status: status_with_media)
Fabricate(:status_pin, account: account, status: pinned_status)
Fabricate(:favourite, account: account, status: self_faved)
Fabricate(:bookmark, account: account, status: self_bookmarked)
faved_primary.status_stat.update(favourites_count: 4)
faved_secondary.status_stat.update(favourites_count: 5)
reblogged_primary.status_stat.update(reblogs_count: 4)

View file

@ -28,7 +28,7 @@ RSpec.describe CanonicalEmailBlock do
end
describe '.block?' do
let!(:canonical_email_block) { Fabricate(:canonical_email_block, email: 'foo@bar.com') }
before { Fabricate(:canonical_email_block, email: 'foo@bar.com') }
it 'returns true for the same email' do
expect(described_class.block?('foo@bar.com')).to be true

View file

@ -516,17 +516,29 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(described_class.tagged_with([tag_cats.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_dogs.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_tagged_with_zebras.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_cats.id]))
.to include(status_with_tag_cats, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with([tag_dogs.id]))
.to include(status_with_tag_dogs, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with([tag_zebras.id]))
.to include(status_tagged_with_zebras, status_with_all_tags)
.and not_include(status_without_tags)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(described_class.tagged_with([tag_cats.id, tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_with_tag_dogs.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_cats.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_tagged_with_zebras.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_dogs.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_dogs.id, status_tagged_with_zebras.id, status_with_all_tags.id)
expect(described_class.tagged_with([tag_cats.id, tag_dogs.id]))
.to include(status_with_tag_cats, status_with_tag_dogs, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with([tag_cats.id, tag_zebras.id]))
.to include(status_with_tag_cats, status_tagged_with_zebras, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with([tag_dogs.id, tag_zebras.id]))
.to include(status_with_tag_dogs, status_tagged_with_zebras, status_with_all_tags)
.and not_include(status_without_tags)
end
end
end
@ -543,17 +555,26 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(described_class.tagged_with_all([tag_cats.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_with_all_tags.id)
expect(described_class.tagged_with_all([tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_dogs.id, status_with_all_tags.id)
expect(described_class.tagged_with_all([tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_tagged_with_zebras.id)
expect(described_class.tagged_with_all([tag_cats.id]))
.to include(status_with_tag_cats, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with_all([tag_dogs.id]))
.to include(status_with_tag_dogs, status_with_all_tags)
.and not_include(status_without_tags)
expect(described_class.tagged_with_all([tag_zebras.id]))
.to include(status_tagged_with_zebras)
.and not_include(status_without_tags)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(described_class.tagged_with_all([tag_cats.id, tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_all_tags.id)
expect(described_class.tagged_with_all([tag_cats.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to eq []
expect(described_class.tagged_with_all([tag_dogs.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to eq []
expect(described_class.tagged_with_all([tag_cats.id, tag_dogs.id]))
.to include(status_with_all_tags)
expect(described_class.tagged_with_all([tag_cats.id, tag_zebras.id]))
.to eq []
expect(described_class.tagged_with_all([tag_dogs.id, tag_zebras.id]))
.to eq []
end
end
end
@ -570,17 +591,29 @@ RSpec.describe Status do
context 'when given one tag' do
it 'returns the expected statuses' do
expect(described_class.tagged_with_none([tag_cats.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_dogs.id, status_tagged_with_zebras.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_tagged_with_zebras.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_with_tag_dogs.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_cats.id]))
.to include(status_with_tag_dogs, status_tagged_with_zebras, status_without_tags)
.and not_include(status_with_all_tags)
expect(described_class.tagged_with_none([tag_dogs.id]))
.to include(status_with_tag_cats, status_tagged_with_zebras, status_without_tags)
.and not_include(status_with_all_tags)
expect(described_class.tagged_with_none([tag_zebras.id]))
.to include(status_with_tag_cats, status_with_tag_dogs, status_without_tags)
.and not_include(status_with_all_tags)
end
end
context 'when given multiple tags' do
it 'returns the expected statuses' do
expect(described_class.tagged_with_none([tag_cats.id, tag_dogs.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_tagged_with_zebras.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_cats.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_dogs.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_dogs.id, tag_zebras.id]).reorder(:id).pluck(:id).uniq).to contain_exactly(status_with_tag_cats.id, status_without_tags.id)
expect(described_class.tagged_with_none([tag_cats.id, tag_dogs.id]))
.to include(status_tagged_with_zebras, status_without_tags)
.and not_include(status_with_all_tags)
expect(described_class.tagged_with_none([tag_cats.id, tag_zebras.id]))
.to include(status_with_tag_dogs, status_without_tags)
.and not_include(status_with_all_tags)
expect(described_class.tagged_with_none([tag_dogs.id, tag_zebras.id]))
.to include(status_with_tag_cats, status_without_tags)
.and not_include(status_with_all_tags)
end
end
end

View file

@ -422,6 +422,7 @@ RSpec.describe User do
it 'deactivates all sessions' do
expect(user.session_activations.count).to eq 0
expect { session_activation.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it 'revokes all access tokens' do
@ -430,6 +431,7 @@ RSpec.describe User do
it 'removes push subscriptions' do
expect(Web::PushSubscription.where(user: user).or(Web::PushSubscription.where(access_token: access_token)).count).to eq 0
expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end