|
|
@ -8,38 +8,12 @@ RSpec.describe NotificationMailer do
|
|
|
|
let(:foreign_status) { Fabricate(:status, account: sender, text: 'The body of the foreign status') }
|
|
|
|
let(:foreign_status) { Fabricate(:status, account: sender, text: 'The body of the foreign status') }
|
|
|
|
let(:own_status) { Fabricate(:status, account: receiver.account, text: 'The body of the own status') }
|
|
|
|
let(:own_status) { Fabricate(:status, account: receiver.account, text: 'The body of the own status') }
|
|
|
|
|
|
|
|
|
|
|
|
shared_examples 'standard headers' do |type|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
|
|
|
|
expect(mail)
|
|
|
|
|
|
|
|
.to be_present
|
|
|
|
|
|
|
|
.and(have_header('To', "#{receiver.account.username} <#{receiver.email}>"))
|
|
|
|
|
|
|
|
.and(have_header('List-ID', "<#{type}.alice.cb6e6126.ngrok.io>"))
|
|
|
|
|
|
|
|
.and(have_header('List-Unsubscribe', %r{<https://cb6e6126.ngrok.io/unsubscribe\?token=.+>}))
|
|
|
|
|
|
|
|
.and(have_header('List-Unsubscribe', /&type=#{type}/))
|
|
|
|
|
|
|
|
.and(have_header('List-Unsubscribe-Post', 'List-Unsubscribe=One-Click'))
|
|
|
|
|
|
|
|
.and(deliver_to("#{receiver.account.username} <#{receiver.email}>"))
|
|
|
|
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared_examples 'thread headers' do
|
|
|
|
|
|
|
|
it 'renders the email with conversation thread headers' do
|
|
|
|
|
|
|
|
conversation_header_regex = /<conversation-\d+.\d\d\d\d-\d\d-\d\d@cb6e6126.ngrok.io>/
|
|
|
|
|
|
|
|
expect(mail)
|
|
|
|
|
|
|
|
.to be_present
|
|
|
|
|
|
|
|
.and(have_header('In-Reply-To', conversation_header_regex))
|
|
|
|
|
|
|
|
.and(have_header('References', conversation_header_regex))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'mention' do
|
|
|
|
describe 'mention' do
|
|
|
|
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
|
|
|
let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
|
|
|
|
let(:notification) { Notification.create!(account: receiver.account, activity: mention) }
|
|
|
|
let(:notification) { Notification.create!(account: receiver.account, activity: mention) }
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).mention }
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).mention }
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
|
|
|
include_examples 'localized subject', 'notification_mailer.mention.subject', name: 'bob'
|
|
|
|
include_examples 'standard headers', 'mention'
|
|
|
|
|
|
|
|
include_examples 'thread headers'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
expect(mail)
|
|
|
@ -47,6 +21,8 @@ RSpec.describe NotificationMailer do
|
|
|
|
.and(have_subject('You were mentioned by bob'))
|
|
|
|
.and(have_subject('You were mentioned by bob'))
|
|
|
|
.and(have_body_text('You were mentioned by bob'))
|
|
|
|
.and(have_body_text('You were mentioned by bob'))
|
|
|
|
.and(have_body_text('The body of the foreign status'))
|
|
|
|
.and(have_body_text('The body of the foreign status'))
|
|
|
|
|
|
|
|
.and have_thread_headers
|
|
|
|
|
|
|
|
.and have_standard_headers('mention').for(receiver)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -56,13 +32,13 @@ RSpec.describe NotificationMailer do
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).follow }
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).follow }
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
|
|
|
include_examples 'localized subject', 'notification_mailer.follow.subject', name: 'bob'
|
|
|
|
include_examples 'standard headers', 'follow'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.to be_present
|
|
|
|
.and(have_subject('bob is now following you'))
|
|
|
|
.and(have_subject('bob is now following you'))
|
|
|
|
.and(have_body_text('bob is now following you'))
|
|
|
|
.and(have_body_text('bob is now following you'))
|
|
|
|
|
|
|
|
.and have_standard_headers('follow').for(receiver)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -72,8 +48,6 @@ RSpec.describe NotificationMailer do
|
|
|
|
let(:mail) { prepared_mailer_for(own_status.account).favourite }
|
|
|
|
let(:mail) { prepared_mailer_for(own_status.account).favourite }
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
|
|
|
include_examples 'localized subject', 'notification_mailer.favourite.subject', name: 'bob'
|
|
|
|
include_examples 'standard headers', 'favourite'
|
|
|
|
|
|
|
|
include_examples 'thread headers'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
expect(mail)
|
|
|
@ -81,6 +55,8 @@ RSpec.describe NotificationMailer do
|
|
|
|
.and(have_subject('bob favorited your post'))
|
|
|
|
.and(have_subject('bob favorited your post'))
|
|
|
|
.and(have_body_text('Your post was favorited by bob'))
|
|
|
|
.and(have_body_text('Your post was favorited by bob'))
|
|
|
|
.and(have_body_text('The body of the own status'))
|
|
|
|
.and(have_body_text('The body of the own status'))
|
|
|
|
|
|
|
|
.and have_thread_headers
|
|
|
|
|
|
|
|
.and have_standard_headers('favourite').for(receiver)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -90,8 +66,6 @@ RSpec.describe NotificationMailer do
|
|
|
|
let(:mail) { prepared_mailer_for(own_status.account).reblog }
|
|
|
|
let(:mail) { prepared_mailer_for(own_status.account).reblog }
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
|
|
|
include_examples 'localized subject', 'notification_mailer.reblog.subject', name: 'bob'
|
|
|
|
include_examples 'standard headers', 'reblog'
|
|
|
|
|
|
|
|
include_examples 'thread headers'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
expect(mail)
|
|
|
@ -99,6 +73,8 @@ RSpec.describe NotificationMailer do
|
|
|
|
.and(have_subject('bob boosted your post'))
|
|
|
|
.and(have_subject('bob boosted your post'))
|
|
|
|
.and(have_body_text('Your post was boosted by bob'))
|
|
|
|
.and(have_body_text('Your post was boosted by bob'))
|
|
|
|
.and(have_body_text('The body of the own status'))
|
|
|
|
.and(have_body_text('The body of the own status'))
|
|
|
|
|
|
|
|
.and have_thread_headers
|
|
|
|
|
|
|
|
.and have_standard_headers('reblog').for(receiver)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -108,13 +84,13 @@ RSpec.describe NotificationMailer do
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).follow_request }
|
|
|
|
let(:mail) { prepared_mailer_for(receiver.account).follow_request }
|
|
|
|
|
|
|
|
|
|
|
|
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
|
|
|
include_examples 'localized subject', 'notification_mailer.follow_request.subject', name: 'bob'
|
|
|
|
include_examples 'standard headers', 'follow_request'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders the email' do
|
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.to be_present
|
|
|
|
.and(have_subject('Pending follower: bob'))
|
|
|
|
.and(have_subject('Pending follower: bob'))
|
|
|
|
.and(have_body_text('bob has requested to follow you'))
|
|
|
|
.and(have_body_text('bob has requested to follow you'))
|
|
|
|
|
|
|
|
.and have_standard_headers('follow_request').for(receiver)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|