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

This commit is contained in:
KMY 2024-11-19 08:49:55 +09:00
commit 055045981f
221 changed files with 2006 additions and 1127 deletions

View file

@ -7,7 +7,7 @@ RSpec.describe Account::Sensitizes do
describe '.sensitized' do
let(:sensitized_account) { Fabricate :account, sensitized_at: 2.days.ago }
before { Fabricate :account, sensitized_at: false }
before { Fabricate :account, sensitized_at: nil }
it 'returns an array of accounts who are sensitized' do
expect(Account.sensitized)

View file

@ -237,51 +237,26 @@ RSpec.describe Form::Import do
let(:import_file) { file }
let(:import_mode) { mode }
before do
subject.save
end
it 'creates the expected rows' do
expect(account.bulk_imports.first.rows.pluck(:data)).to match_array(expected_rows)
end
before { subject.save }
context 'with a BulkImport' do
let(:bulk_import) { account.bulk_imports.first }
it 'creates a non-nil bulk import' do
expect(bulk_import).to_not be_nil
end
it 'matches the subjects type' do
expect(bulk_import.type.to_sym).to eq subject.type.to_sym
end
it 'matches the subjects original filename' do
expect(bulk_import.original_filename).to eq subject.data.original_filename
end
it 'matches the subjects likely_mismatched? value' do
expect(bulk_import.likely_mismatched?).to eq subject.likely_mismatched?
end
it 'matches the subject overwrite value' do
expect(bulk_import.overwrite?).to eq !!subject.overwrite # rubocop:disable Style/DoubleNegation
end
it 'has zero processed items' do
expect(bulk_import.processed_items).to eq 0
end
it 'has zero imported items' do
expect(bulk_import.imported_items).to eq 0
end
it 'has a correct total_items value' do
expect(bulk_import.total_items).to eq bulk_import.rows.count
end
it 'defaults to unconfirmed true' do
expect(bulk_import.state_unconfirmed?).to be true
it 'creates a bulk import with correct values' do
expect(bulk_import)
.to be_present
.and have_attributes(
type: eq(subject.type),
original_filename: eq(subject.data.original_filename),
likely_mismatched?: eq(subject.likely_mismatched?),
overwrite?: eq(!!subject.overwrite), # rubocop:disable Style/DoubleNegation
processed_items: eq(0),
imported_items: eq(0),
total_items: eq(bulk_import.rows.count),
state_unconfirmed?: be(true)
)
expect(bulk_import.rows.pluck(:data))
.to match_array(expected_rows)
end
end
end

View file

@ -11,7 +11,11 @@ RSpec.describe List do
context 'when account has hit max list limit' do
let(:account) { Fabricate :account }
before { stub_const 'List::PER_ACCOUNT_LIMIT', 0 }
before do
stub_const 'List::PER_ACCOUNT_LIMIT', 1
Fabricate(:list, account: account)
end
context 'when creating a new list' do
it { is_expected.to_not allow_value(account).for(:account).against(:base).with_message(I18n.t('lists.errors.limit')) }

View file

@ -3,6 +3,60 @@
require 'rails_helper'
RSpec.describe SoftwareUpdate do
describe '#pending?' do
subject { described_class.new(version: update_version) }
before { allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version)) }
context 'when the runtime version is older than the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to be_pending }
end
context 'when the runtime version is newer than the update' do
let(:mastodon_version) { '6.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to_not be_pending }
end
context 'when the runtime version is same as the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '4.0.0' }
it { is_expected.to_not be_pending }
end
end
describe '#outdated?' do
subject { described_class.new(version: update_version) }
before { allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version)) }
context 'when the runtime version is older than the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to_not be_outdated }
end
context 'when the runtime version is newer than the update' do
let(:mastodon_version) { '6.0.0' }
let(:update_version) { '5.0.0' }
it { is_expected.to be_outdated }
end
context 'when the runtime version is same as the update' do
let(:mastodon_version) { '4.0.0' }
let(:update_version) { '4.0.0' }
it { is_expected.to be_outdated }
end
end
describe '.pending_to_a' do
before do
allow(Mastodon::Version).to receive(:gem_version).and_return(Gem::Version.new(mastodon_version))

View file

@ -630,4 +630,27 @@ RSpec.describe User do
end
end
end
describe '#applications_last_used' do
let!(:user) { Fabricate(:user) }
let!(:never_used_application) { Fabricate :application, owner: user }
let!(:application_one) { Fabricate :application, owner: user }
let!(:application_two) { Fabricate :application, owner: user }
before do
_other_user_token = Fabricate :access_token, last_used_at: 3.days.ago
_never_used_token = Fabricate :access_token, application: never_used_application, resource_owner_id: user.id, last_used_at: nil
_app_one_old_token = Fabricate :access_token, application: application_one, resource_owner_id: user.id, last_used_at: 5.days.ago
_app_one_new_token = Fabricate :access_token, application: application_one, resource_owner_id: user.id, last_used_at: 1.day.ago
_never_used_token = Fabricate :access_token, application: application_two, resource_owner_id: user.id, last_used_at: 5.days.ago
end
it 'returns a hash of unique applications with last used values' do
expect(user.applications_last_used)
.to include(application_one.id => be_within(1.0).of(1.day.ago))
.and include(application_two.id => be_within(1.0).of(5.days.ago))
.and not_include(never_used_application.id)
end
end
end