Merge remote-tracking branch 'parent/main' into upstream-20241231
This commit is contained in:
commit
3c77d4e8e4
268 changed files with 4213 additions and 3029 deletions
|
@ -129,8 +129,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
|
||||
|
||||
it 'records the given id' do
|
||||
account_statuses_cleanup_policy.record_last_inspected(42)
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 42
|
||||
expect { account_statuses_cleanup_policy.record_last_inspected(42) }
|
||||
.to change(account_statuses_cleanup_policy, :last_inspected).from(nil).to(42)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -153,8 +153,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'does not change the recorded id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 42
|
||||
expect { subject }
|
||||
.to_not change(account_statuses_cleanup_policy, :last_inspected).from(42)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -164,8 +164,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'records the older id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 10
|
||||
expect { subject }
|
||||
.to change(account_statuses_cleanup_policy, :last_inspected).from(42).to(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -179,8 +179,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'does not change the recorded id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 42
|
||||
expect { subject }
|
||||
.to_not change(account_statuses_cleanup_policy, :last_inspected).from(42)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -190,8 +190,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'records the older id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 10
|
||||
expect { subject }
|
||||
.to change(account_statuses_cleanup_policy, :last_inspected).from(42).to(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -205,8 +205,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'does not change the recorded id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 42
|
||||
expect { subject }
|
||||
.to_not change(account_statuses_cleanup_policy, :last_inspected).from(42)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -216,8 +216,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
end
|
||||
|
||||
it 'records the older id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 10
|
||||
expect { subject }
|
||||
.to change(account_statuses_cleanup_policy, :last_inspected).from(42).to(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -227,8 +227,8 @@ RSpec.describe AccountStatusesCleanupPolicy do
|
|||
let(:status) { Fabricate(:status, account: account) }
|
||||
|
||||
it 'does not change the recorded id' do
|
||||
subject
|
||||
expect(account_statuses_cleanup_policy.last_inspected).to eq 42
|
||||
expect { subject }
|
||||
.to_not change(account_statuses_cleanup_policy, :last_inspected).from(42)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomFilter do
|
||||
include_examples 'Expireable'
|
||||
|
||||
describe 'Validations' do
|
||||
it { is_expected.to validate_presence_of(:title) }
|
||||
it { is_expected.to validate_presence_of(:context) }
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Invite do
|
||||
include_examples 'Expireable'
|
||||
|
||||
describe '#valid_for_use?' do
|
||||
it 'returns true when there are no limitations' do
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: nil)
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe IpBlock do
|
||||
include_examples 'Expireable'
|
||||
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :ip_block }
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
media.destroy
|
||||
end
|
||||
|
||||
it 'saves metadata and generates styles' do
|
||||
it 'saves media attachment with correct file and size metadata' do
|
||||
expect(media)
|
||||
.to be_persisted
|
||||
.and be_processing_complete
|
||||
|
@ -98,28 +98,18 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
file: be_present,
|
||||
type: eq('image'),
|
||||
file_content_type: eq(content_type),
|
||||
file_file_name: end_with(extension),
|
||||
blurhash: have_attributes(size: eq(36))
|
||||
file_file_name: end_with(extension)
|
||||
)
|
||||
|
||||
# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
|
||||
expect(Rack::Mime.mime_type(extension, nil)).to eq content_type
|
||||
|
||||
# Strip original file name
|
||||
expect(media.file_file_name)
|
||||
.to_not start_with '600x400'
|
||||
|
||||
# Generate styles
|
||||
expect(FastImage.size(media.file.path(:original)))
|
||||
.to eq [600, 400]
|
||||
expect(FastImage.size(media.file.path(:small)))
|
||||
.to eq [588, 392]
|
||||
|
||||
# Use extension recognized by Rack::Mime (used by PublicFileServerMiddleware)
|
||||
expect(media.file.path(:original))
|
||||
.to end_with(extension)
|
||||
expect(media.file.path(:small))
|
||||
.to end_with(extension)
|
||||
|
||||
# Set meta for original and thumbnail
|
||||
expect(media_metadata)
|
||||
expect(media.file.meta.deep_symbolize_keys)
|
||||
.to include(
|
||||
original: include(
|
||||
width: eq(600),
|
||||
|
@ -132,60 +122,6 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
aspect: eq(1.5)
|
||||
)
|
||||
)
|
||||
|
||||
# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
|
||||
expect(Rack::Mime.mime_type(extension, nil)).to eq content_type
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'animated 600x400 image' do
|
||||
after do
|
||||
media.destroy
|
||||
end
|
||||
|
||||
it 'saves metadata and generates styles' do
|
||||
expect(media)
|
||||
.to be_persisted
|
||||
.and be_processing_complete
|
||||
.and have_attributes(
|
||||
file: be_present,
|
||||
type: eq('gifv'),
|
||||
file_content_type: eq('video/mp4'),
|
||||
file_file_name: end_with('.mp4'),
|
||||
blurhash: have_attributes(size: eq(36))
|
||||
)
|
||||
|
||||
# Strip original file name
|
||||
expect(media.file_file_name)
|
||||
.to_not start_with '600x400'
|
||||
|
||||
# Transcode to MP4
|
||||
expect(media.file.path(:original))
|
||||
.to end_with('.mp4')
|
||||
|
||||
# Generate static thumbnail
|
||||
expect(FastImage.size(media.file.path(:small)))
|
||||
.to eq [600, 400]
|
||||
expect(FastImage.animated?(media.file.path(:small)))
|
||||
.to be false
|
||||
expect(media.file.path(:small))
|
||||
.to end_with('.png')
|
||||
|
||||
# Set meta for styles
|
||||
expect(media_metadata)
|
||||
.to include(
|
||||
original: include(
|
||||
width: eq(600),
|
||||
height: eq(400),
|
||||
duration: eq(3),
|
||||
frame_rate: '1/1'
|
||||
),
|
||||
small: include(
|
||||
width: eq(600),
|
||||
height: eq(400),
|
||||
aspect: eq(1.5)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,10 +137,10 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
it_behaves_like 'static 600x400 image', 'image/png', '.png'
|
||||
end
|
||||
|
||||
describe 'gif' do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('600x400.gif')) }
|
||||
describe 'monochrome jpg' do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('monochrome.png')) }
|
||||
|
||||
it_behaves_like 'static 600x400 image', 'image/gif', '.gif'
|
||||
it_behaves_like 'static 600x400 image', 'image/png', '.png'
|
||||
end
|
||||
|
||||
describe 'webp' do
|
||||
|
@ -225,12 +161,6 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
it_behaves_like 'static 600x400 image', 'image/jpeg', '.jpeg'
|
||||
end
|
||||
|
||||
describe 'monochrome jpg' do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('monochrome.png')) }
|
||||
|
||||
it_behaves_like 'static 600x400 image', 'image/png', '.png'
|
||||
end
|
||||
|
||||
describe 'base64-encoded image' do
|
||||
let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('600x400.jpeg').read)}" }
|
||||
let(:media) { Fabricate(:media_attachment, file: base64_attachment) }
|
||||
|
@ -239,15 +169,51 @@ RSpec.describe MediaAttachment, :attachment_processing do
|
|||
end
|
||||
|
||||
describe 'animated gif' do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('600x400-animated.gif')) }
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('avatar.gif')) }
|
||||
|
||||
it_behaves_like 'animated 600x400 image'
|
||||
it 'sets correct file metadata' do
|
||||
expect(media)
|
||||
.to have_attributes(
|
||||
type: eq('gifv'),
|
||||
file_content_type: eq('video/mp4')
|
||||
)
|
||||
expect(media_metadata)
|
||||
.to include(
|
||||
original: include(
|
||||
width: eq(128),
|
||||
height: eq(128)
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'animated png' do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture('600x400-animated.png')) }
|
||||
describe 'static gif' do
|
||||
fixtures = [
|
||||
{ filename: 'attachment.gif', width: 600, height: 400, aspect: 1.5 },
|
||||
{ filename: 'mini-static.gif', width: 32, height: 32, aspect: 1.0 },
|
||||
]
|
||||
|
||||
it_behaves_like 'animated 600x400 image'
|
||||
fixtures.each do |fixture|
|
||||
context fixture[:filename] do
|
||||
let(:media) { Fabricate(:media_attachment, file: attachment_fixture(fixture[:filename])) }
|
||||
|
||||
it 'sets correct file metadata' do
|
||||
expect(media)
|
||||
.to have_attributes(
|
||||
type: eq('image'),
|
||||
file_content_type: eq('image/gif')
|
||||
)
|
||||
expect(media_metadata)
|
||||
.to include(
|
||||
original: include(
|
||||
width: eq(fixture[:width]),
|
||||
height: eq(fixture[:height]),
|
||||
aspect: eq(fixture[:aspect])
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ogg with cover art' do
|
||||
|
|
18
spec/models/mute_spec.rb
Normal file
18
spec/models/mute_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mute do
|
||||
include_examples 'Expireable'
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to belong_to(:account).required }
|
||||
it { is_expected.to belong_to(:target_account).required }
|
||||
end
|
||||
|
||||
describe 'Validations' do
|
||||
subject { Fabricate.build :mute }
|
||||
|
||||
it { is_expected.to validate_uniqueness_of(:account_id).scoped_to(:target_account_id) }
|
||||
end
|
||||
end
|
|
@ -3,32 +3,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Poll do
|
||||
describe 'Scopes' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:attached_poll) { Fabricate(:poll, status: status) }
|
||||
let(:not_attached_poll) do
|
||||
Fabricate(:poll).tap do |poll|
|
||||
poll.status = nil
|
||||
poll.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.attached' do
|
||||
it 'finds the correct records' do
|
||||
results = described_class.attached
|
||||
|
||||
expect(results).to eq([attached_poll])
|
||||
end
|
||||
end
|
||||
|
||||
describe '.unattached' do
|
||||
it 'finds the correct records' do
|
||||
results = described_class.unattached
|
||||
|
||||
expect(results).to eq([not_attached_poll])
|
||||
end
|
||||
end
|
||||
end
|
||||
include_examples 'Expireable'
|
||||
|
||||
describe '#reset_votes!' do
|
||||
let(:poll) { Fabricate :poll, cached_tallies: [2, 3], votes_count: 5, voters_count: 5 }
|
||||
|
|
|
@ -18,6 +18,14 @@ RSpec.describe UserRole do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'position' do
|
||||
subject { Fabricate.build :user_role }
|
||||
|
||||
let(:limit) { described_class::POSITION_LIMIT }
|
||||
|
||||
it { is_expected.to validate_numericality_of(:position).is_in(-limit..limit) }
|
||||
end
|
||||
|
||||
describe 'color' do
|
||||
it { is_expected.to allow_values('#112233', '#aabbcc', '').for(:color) }
|
||||
it { is_expected.to_not allow_values('x', '112233445566', '#xxyyzz').for(:color) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue