Merge remote-tracking branch 'parent/main' into upstream-20240926
This commit is contained in:
commit
c905714459
517 changed files with 4284 additions and 3891 deletions
|
@ -72,7 +72,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
|||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.url).to eq 'https://foo.bar/watch?v=12345'
|
||||
expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
|
||||
expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix\n\nhttps://foo.bar/watch?v=12345"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -105,7 +105,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
|||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.url).to eq 'https://foo.bar/watch?v=12345'
|
||||
expect(strip_tags(status.text)).to eq 'Nyan Cat 10 hours remixhttps://foo.bar/watch?v=12345'
|
||||
expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix\n\nhttps://foo.bar/watch?v=12345"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -125,7 +125,58 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
|||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.url).to eq 'https://foo.bar/@foo/1234'
|
||||
expect(strip_tags(status.text)).to eq "Let's change the worldhttps://foo.bar/@foo/1234"
|
||||
expect(strip_tags(status.text)).to eq "Let's change the world\n\nhttps://foo.bar/@foo/1234"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Event object that contains a HTML summary' do
|
||||
let(:object) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: 'https://foo.bar/@foo/1234',
|
||||
type: 'Event',
|
||||
name: 'Fediverse Birthday Party',
|
||||
startTime: '2024-01-31T20:00:00.000+01:00',
|
||||
location: {
|
||||
type: 'Place',
|
||||
name: 'FooBar – The not converted location',
|
||||
},
|
||||
content: 'The not converted detailed description of the event object.',
|
||||
summary: '<p>See you at the <strong>FooBar</strong>!</p><ul><li><strong>Doors:</strong> 8pm</li><li><strong>Music:</strong> 10pm</li></ul>',
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.url).to eq 'https://foo.bar/@foo/1234'
|
||||
expect(status.text).to start_with "<h2>#{object[:name]}</h2>\n\n#{object[:summary]}\n\n"
|
||||
expect(status.text).to include "href=\"#{object[:id]}\""
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Article object that contains a HTML summary' do
|
||||
let(:object) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: 'https://foo.bar/blog/future-of-the-fediverse',
|
||||
type: 'Article',
|
||||
name: 'Future of the Fediverse',
|
||||
content: 'Lorem Ipsum',
|
||||
summary: '<p>Guest article by <a href="https://john.mastodon">John Mastodon</a></p><p>The fediverse is great reading this you will find out why!</p>',
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates status' do
|
||||
status = sender.statuses.first
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.url).to eq object[:id]
|
||||
expect(status.text).to start_with "<h2>#{object[:name]}</h2>\n\n#{object[:summary]}\n\n"
|
||||
expect(status.text).to include "href=\"#{object[:id]}\""
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,27 +4,55 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe ApproveAppealService do
|
||||
describe '#call' do
|
||||
context 'with an existing appeal' do
|
||||
let(:appeal) { Fabricate(:appeal) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:appeal) { Fabricate(:appeal) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
it 'processes the appeal approval' do
|
||||
expect { subject.call(appeal, account) }
|
||||
.to mark_overruled
|
||||
.and record_approver
|
||||
it 'processes the appeal approval' do
|
||||
expect { subject.call(appeal, account) }
|
||||
.to mark_overruled
|
||||
.and record_approver
|
||||
end
|
||||
|
||||
context 'with an appeal about then-deleted posts marked as sensitive by moderators' do
|
||||
let(:target_account) { Fabricate(:account) }
|
||||
let(:appeal) { Fabricate(:appeal, strike: strike, account: target_account) }
|
||||
let(:deleted_media) { Fabricate(:media_attachment, type: :video, status: Fabricate(:status, account: target_account), account: target_account) }
|
||||
let(:kept_media) { Fabricate(:media_attachment, type: :video, status: Fabricate(:status, account: target_account), account: target_account) }
|
||||
let(:strike) { Fabricate(:account_warning, target_account: target_account, action: :mark_statuses_as_sensitive, status_ids: [deleted_media.status.id, kept_media.status.id]) }
|
||||
|
||||
before do
|
||||
target_account.unsuspend!
|
||||
deleted_media.status.discard!
|
||||
end
|
||||
|
||||
def mark_overruled
|
||||
change(appeal.strike, :overruled_at)
|
||||
.from(nil)
|
||||
.to(be > 1.minute.ago)
|
||||
end
|
||||
it 'approves the appeal, marks the statuses as not sensitive and notifies target account about the approval', :inline_jobs do
|
||||
emails = capture_emails { subject.call(appeal, account) }
|
||||
|
||||
def record_approver
|
||||
change(appeal, :approved_by_account)
|
||||
.from(nil)
|
||||
.to(account)
|
||||
expect(appeal.reload).to be_approved
|
||||
expect(strike.reload).to be_overruled
|
||||
|
||||
expect(kept_media.status.reload).to_not be_sensitive
|
||||
|
||||
expect(emails.size)
|
||||
.to eq(1)
|
||||
expect(emails.first)
|
||||
.to have_attributes(
|
||||
to: contain_exactly(target_account.user.email),
|
||||
subject: eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def mark_overruled
|
||||
change(appeal.strike, :overruled_at)
|
||||
.from(nil)
|
||||
.to(be > 1.minute.ago)
|
||||
end
|
||||
|
||||
def record_approver
|
||||
change(appeal, :approved_by_account)
|
||||
.from(nil)
|
||||
.to(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue