Merge commit 'ea10febd257b5b729a50aeb3218389763f5f4b97' into glitch-soc/merge-upstream
This commit is contained in:
@@ -23,7 +23,8 @@ RSpec.describe NotificationMailer do
|
||||
|
||||
describe 'mention' do
|
||||
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
||||
let(:mail) { described_class.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: mention) }
|
||||
let(:mail) { prepared_mailer_for(receiver.account).mention }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
||||
|
||||
@@ -40,7 +41,8 @@ RSpec.describe NotificationMailer do
|
||||
|
||||
describe 'follow' do
|
||||
let(:follow) { sender.follow!(receiver.account) }
|
||||
let(:mail) { described_class.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: follow) }
|
||||
let(:mail) { prepared_mailer_for(receiver.account).follow }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
||||
|
||||
@@ -56,7 +58,8 @@ RSpec.describe NotificationMailer do
|
||||
|
||||
describe 'favourite' do
|
||||
let(:favourite) { Favourite.create!(account: sender, status: own_status) }
|
||||
let(:mail) { described_class.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: favourite) }
|
||||
let(:mail) { prepared_mailer_for(own_status.account).favourite }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
||||
|
||||
@@ -73,7 +76,8 @@ RSpec.describe NotificationMailer do
|
||||
|
||||
describe 'reblog' do
|
||||
let(:reblog) { Status.create!(account: sender, reblog: own_status) }
|
||||
let(:mail) { described_class.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: reblog) }
|
||||
let(:mail) { prepared_mailer_for(own_status.account).reblog }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
||||
|
||||
@@ -90,7 +94,8 @@ RSpec.describe NotificationMailer do
|
||||
|
||||
describe 'follow_request' do
|
||||
let(:follow_request) { Fabricate(:follow_request, account: sender, target_account: receiver.account) }
|
||||
let(:mail) { described_class.follow_request(receiver.account, Notification.create!(account: receiver.account, activity: follow_request)) }
|
||||
let(:notification) { Notification.create!(account: receiver.account, activity: follow_request) }
|
||||
let(:mail) { prepared_mailer_for(receiver.account).follow_request }
|
||||
|
||||
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
||||
|
||||
@@ -103,4 +108,10 @@ RSpec.describe NotificationMailer do
|
||||
expect(mail.body.encoded).to match('bob has requested to follow you')
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepared_mailer_for(recipient)
|
||||
described_class.with(recipient: recipient, notification: notification)
|
||||
end
|
||||
end
|
||||
|
@@ -5,31 +5,40 @@
|
||||
class NotificationMailerPreview < ActionMailer::Preview
|
||||
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/mention
|
||||
def mention
|
||||
m = Mention.last
|
||||
NotificationMailer.mention(m.account, Notification.find_by(activity: m))
|
||||
activity = Mention.last
|
||||
mailer_for(activity.account, activity).mention
|
||||
end
|
||||
|
||||
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow
|
||||
def follow
|
||||
f = Follow.last
|
||||
NotificationMailer.follow(f.target_account, Notification.find_by(activity: f))
|
||||
activity = Follow.last
|
||||
mailer_for(activity.target_account, activity).follow
|
||||
end
|
||||
|
||||
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow_request
|
||||
def follow_request
|
||||
f = Follow.last
|
||||
NotificationMailer.follow_request(f.target_account, Notification.find_by(activity: f))
|
||||
activity = Follow.last
|
||||
mailer_for(activity.target_account, activity).follow_request
|
||||
end
|
||||
|
||||
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/favourite
|
||||
def favourite
|
||||
f = Favourite.last
|
||||
NotificationMailer.favourite(f.status.account, Notification.find_by(activity: f))
|
||||
activity = Favourite.last
|
||||
mailer_for(activity.status.account, activity).favourite
|
||||
end
|
||||
|
||||
# Preview this email at http://localhost:3000/rails/mailers/notification_mailer/reblog
|
||||
def reblog
|
||||
r = Status.where.not(reblog_of_id: nil).first
|
||||
NotificationMailer.reblog(r.reblog.account, Notification.find_by(activity: r))
|
||||
activity = Status.where.not(reblog_of_id: nil).first
|
||||
mailer_for(activity.reblog.account, activity).reblog
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mailer_for(account, activity)
|
||||
NotificationMailer.with(
|
||||
recipient: account,
|
||||
notification: Notification.find_by(activity: activity)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@@ -44,9 +44,27 @@ RSpec.describe ReportService, type: :service do
|
||||
stub_request(:post, 'http://foo.com/inbox').to_return(status: 200)
|
||||
end
|
||||
|
||||
it 'sends ActivityPub payload to the author of the replied-to post' do
|
||||
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward)
|
||||
expect(a_request(:post, 'http://foo.com/inbox')).to have_been_made
|
||||
context 'when forward_to_domains includes both the replied-to domain and the origin domain' do
|
||||
it 'sends ActivityPub payload to both the author of the replied-to post and the reported user' do
|
||||
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward, forward_to_domains: [remote_account.domain, remote_thread_account.domain])
|
||||
expect(a_request(:post, 'http://foo.com/inbox')).to have_been_made
|
||||
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made
|
||||
end
|
||||
end
|
||||
|
||||
context 'when forward_to_domains includes only the replied-to domain' do
|
||||
it 'sends ActivityPub payload only to the author of the replied-to post' do
|
||||
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward, forward_to_domains: [remote_thread_account.domain])
|
||||
expect(a_request(:post, 'http://foo.com/inbox')).to have_been_made
|
||||
expect(a_request(:post, 'http://example.com/inbox')).to_not have_been_made
|
||||
end
|
||||
end
|
||||
|
||||
context 'when forward_to_domains does not include the replied-to domain' do
|
||||
it 'does not send ActivityPub payload to the author of the replied-to post' do
|
||||
subject.call(source_account, remote_account, status_ids: [reported_status.id], forward: forward)
|
||||
expect(a_request(:post, 'http://foo.com/inbox')).to_not have_been_made
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -68,7 +68,7 @@ describe SearchService, type: :service do
|
||||
allow(AccountSearchService).to receive(:new).and_return(service)
|
||||
|
||||
results = subject.call(query, nil, 10)
|
||||
expect(service).to have_received(:call).with(query, nil, limit: 10, offset: 0, resolve: false, use_searchable_text: true, following: false)
|
||||
expect(service).to have_received(:call).with(query, nil, limit: 10, offset: 0, resolve: false, start_with_hashtag: false, use_searchable_text: true, following: false)
|
||||
expect(results).to eq empty_results.merge(accounts: [account])
|
||||
end
|
||||
end
|
||||
@@ -92,15 +92,6 @@ describe SearchService, type: :service do
|
||||
expect(Tag).to_not have_received(:search_for)
|
||||
expect(results).to eq empty_results
|
||||
end
|
||||
|
||||
it 'does not include account when starts with # character' do
|
||||
query = '#tag'
|
||||
allow(AccountSearchService).to receive(:new)
|
||||
|
||||
results = subject.call(query, nil, 10)
|
||||
expect(AccountSearchService).to_not have_received(:new)
|
||||
expect(results).to eq empty_results
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user