mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 02:51:13 +01:00
Move localized subject mailer shared example to separate file (#25889)
This commit is contained in:
parent
cabe1ea560
commit
285a3df56c
3 changed files with 14 additions and 26 deletions
|
@ -8,19 +8,6 @@ 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 'localized subject' do |*args, **kwrest|
|
|
||||||
it 'renders subject localized for the locale of the receiver' do
|
|
||||||
locale = :de
|
|
||||||
receiver.update!(locale: locale)
|
|
||||||
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: locale))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders subject localized for the default locale if the locale of the receiver is unavailable' do
|
|
||||||
receiver.update!(locale: nil)
|
|
||||||
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: I18n.default_locale))
|
|
||||||
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) }
|
||||||
|
|
|
@ -5,19 +5,6 @@ require 'rails_helper'
|
||||||
describe UserMailer do
|
describe UserMailer do
|
||||||
let(:receiver) { Fabricate(:user) }
|
let(:receiver) { Fabricate(:user) }
|
||||||
|
|
||||||
shared_examples 'localized subject' do |*args, **kwrest|
|
|
||||||
it 'renders subject localized for the locale of the receiver' do
|
|
||||||
locale = :de
|
|
||||||
receiver.update!(locale: locale)
|
|
||||||
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: locale))
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'renders subject localized for the default locale if the locale of the receiver is unavailable' do
|
|
||||||
receiver.update!(locale: nil)
|
|
||||||
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: I18n.default_locale))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'confirmation_instructions' do
|
describe 'confirmation_instructions' do
|
||||||
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
||||||
|
|
||||||
|
|
14
spec/support/examples/mailers.rb
Normal file
14
spec/support/examples/mailers.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
shared_examples 'localized subject' do |*args, **kwrest|
|
||||||
|
it 'renders subject localized for the locale of the receiver' do
|
||||||
|
locale = :de
|
||||||
|
receiver.update!(locale: locale)
|
||||||
|
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: locale))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders subject localized for the default locale if the locale of the receiver is unavailable' do
|
||||||
|
receiver.update!(locale: nil)
|
||||||
|
expect(mail.subject).to eq I18n.t(*args, **kwrest.merge(locale: I18n.default_locale))
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue