Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/mastodon/features/compose/components/poll_form.js`: glitch-soc change because of having changed the default number of available poll options. Applied upstream's changes while keeping glitch-soc's default number of poll options. - `public/oops.png`: We had a minor graphics change, probably not worth diverging from upstream. Took upstream version.
This commit is contained in:
@ -3,6 +3,19 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::ActionLogsController, type: :controller do
|
||||
render_views
|
||||
|
||||
# Action logs typically cause issues when their targets are not in the database
|
||||
let!(:account) { Fabricate(:account) }
|
||||
|
||||
let!(:orphaned_logs) do
|
||||
%w(
|
||||
Account User UserRole Report DomainBlock DomainAllow
|
||||
EmailDomainBlock UnavailableDomain Status AccountWarning
|
||||
Announcement IpBlock Instance CustomEmoji CanonicalEmailBlock Appeal
|
||||
).map { |type| Admin::ActionLog.new(account: account, action: 'destroy', target_type: type, target_id: 1312).save! }
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'returns 200' do
|
||||
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 242 KiB After Width: | Height: | Size: 191 KiB |
BIN
spec/fixtures/files/emojo.png
vendored
BIN
spec/fixtures/files/emojo.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
123
spec/lib/status_cache_hydrator_spec.rb
Normal file
123
spec/lib/status_cache_hydrator_spec.rb
Normal file
@ -0,0 +1,123 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe StatusCacheHydrator do
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe '#hydrate' do
|
||||
let(:compare_to_hash) { InlineRenderer.render(status, account, :status) }
|
||||
|
||||
shared_examples 'shared behavior' do
|
||||
context 'when handling a new status' do
|
||||
let(:poll) { Fabricate(:poll) }
|
||||
let(:status) { Fabricate(:status, poll: poll) }
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when handling a new status with own poll' do
|
||||
let(:poll) { Fabricate(:poll, account: account) }
|
||||
let(:status) { Fabricate(:status, poll: poll, account: account) }
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when handling a reblog' do
|
||||
let(:reblog) { Fabricate(:status) }
|
||||
let(:status) { Fabricate(:status, reblog: reblog) }
|
||||
|
||||
context 'that has been favourited' do
|
||||
before do
|
||||
FavouriteService.new.call(account, reblog)
|
||||
end
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'that has been reblogged' do
|
||||
before do
|
||||
ReblogService.new.call(account, reblog)
|
||||
end
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'that has been pinned' do
|
||||
let(:reblog) { Fabricate(:status, account: account) }
|
||||
|
||||
before do
|
||||
StatusPin.create!(account: account, status: reblog)
|
||||
end
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'that has been followed tags' do
|
||||
let(:followed_tag) { Fabricate(:tag) }
|
||||
|
||||
before do
|
||||
reblog.tags << Fabricate(:tag)
|
||||
reblog.tags << followed_tag
|
||||
TagFollow.create!(tag: followed_tag, account: account, rate_limit: false)
|
||||
end
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'that has a poll authored by the user' do
|
||||
let(:poll) { Fabricate(:poll, account: account) }
|
||||
let(:reblog) { Fabricate(:status, poll: poll, account: account) }
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
|
||||
context 'that has been voted in' do
|
||||
let(:poll) { Fabricate(:poll, options: %w(Yellow Blue)) }
|
||||
let(:reblog) { Fabricate(:status, poll: poll) }
|
||||
|
||||
before do
|
||||
VoteService.new.call(account, poll, [0])
|
||||
end
|
||||
|
||||
it 'renders the same attributes as a full render' do
|
||||
expect(subject).to eql(compare_to_hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when cache is warm' do
|
||||
subject do
|
||||
Rails.cache.write("fan-out/#{status.id}", InlineRenderer.render(status, nil, :status))
|
||||
described_class.new(status).hydrate(account.id)
|
||||
end
|
||||
|
||||
it_behaves_like 'shared behavior'
|
||||
end
|
||||
|
||||
context 'when cache is cold' do
|
||||
subject do
|
||||
Rails.cache.delete("fan-out/#{status.id}")
|
||||
described_class.new(status).hydrate(account.id)
|
||||
end
|
||||
|
||||
it_behaves_like 'shared behavior'
|
||||
end
|
||||
end
|
||||
end
|
@ -157,9 +157,9 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
expect(media.file.meta["original"]["width"]).to eq 600
|
||||
expect(media.file.meta["original"]["height"]).to eq 400
|
||||
expect(media.file.meta["original"]["aspect"]).to eq 1.5
|
||||
expect(media.file.meta["small"]["width"]).to eq 490
|
||||
expect(media.file.meta["small"]["height"]).to eq 327
|
||||
expect(media.file.meta["small"]["aspect"]).to eq 490.0 / 327
|
||||
expect(media.file.meta["small"]["width"]).to eq 588
|
||||
expect(media.file.meta["small"]["height"]).to eq 392
|
||||
expect(media.file.meta["small"]["aspect"]).to eq 1.5
|
||||
end
|
||||
|
||||
it 'gives the file a random name' do
|
||||
|
@ -45,7 +45,6 @@ describe AccountSearchService, type: :service do
|
||||
|
||||
results = subject.call('e@example.com', nil, limit: 2)
|
||||
|
||||
expect(results.size).to eq 2
|
||||
expect(results).to eq([exact, remote]).or eq([exact, remote_too])
|
||||
end
|
||||
end
|
||||
|
@ -1,63 +1,91 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessMentionsService, type: :service do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
let(:visibility) { :public }
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: visibility) }
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { ProcessMentionsService.new }
|
||||
|
||||
context 'ActivityPub' do
|
||||
context do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an IDN domain' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'sneak', protocol: :activitypub, domain: 'xn--hresiar-mxa.ch', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:status) { Fabricate(:status, account: account, text: "Hello @sneak@hæresiar.ch") }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an IDN TLD' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'foo', protocol: :activitypub, domain: 'xn--y9a3aq.xn--y9a3aq', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:status) { Fabricate(:status, account: account, text: "Hello @foo@հայ.հայ") }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Temporarily-unreachable ActivityPub user' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox', last_webfingered_at: nil) }
|
||||
context 'when mentions contain blocked accounts' do
|
||||
let(:non_blocked_account) { Fabricate(:account) }
|
||||
let(:individually_blocked_account) { Fabricate(:account) }
|
||||
let(:domain_blocked_account) { Fabricate(:account, domain: 'evil.com') }
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{non_blocked_account.acct} @#{individually_blocked_account.acct} @#{domain_blocked_account.acct}", visibility: :public) }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
|
||||
stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com").to_return(status: 500)
|
||||
account.block!(individually_blocked_account)
|
||||
account.domain_blocks.create!(domain: domain_blocked_account.domain)
|
||||
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
it 'creates a mention to the non-blocked account' do
|
||||
expect(non_blocked_account.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
|
||||
it 'does not create a mention to the individually blocked account' do
|
||||
expect(individually_blocked_account.mentions.where(status: status).count).to eq 0
|
||||
end
|
||||
|
||||
it 'does not create a mention to the domain-blocked account' do
|
||||
expect(domain_blocked_account.mentions.where(status: status).count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'resolving a mention to a remote account' do
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: :public) }
|
||||
|
||||
context 'ActivityPub' do
|
||||
context do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an IDN domain' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'sneak', protocol: :activitypub, domain: 'xn--hresiar-mxa.ch', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:status) { Fabricate(:status, account: account, text: "Hello @sneak@hæresiar.ch") }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an IDN TLD' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'foo', protocol: :activitypub, domain: 'xn--y9a3aq.xn--y9a3aq', inbox_url: 'http://example.com/inbox') }
|
||||
let!(:status) { Fabricate(:status, account: account, text: "Hello @foo@հայ.հայ") }
|
||||
|
||||
before do
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Temporarily-unreachable ActivityPub user' do
|
||||
let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox', last_webfingered_at: nil) }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://example.com/.well-known/host-meta").to_return(status: 404)
|
||||
stub_request(:get, "https://example.com/.well-known/webfinger?resource=acct:remote_user@example.com").to_return(status: 500)
|
||||
subject.call(status)
|
||||
end
|
||||
|
||||
it 'creates a mention' do
|
||||
expect(remote_user.mentions.where(status: status).count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user