Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ApplicationMailer < ActionMailer::Base

layout "mailer"

around_action :use_default_locale
after_deliver :record_delivery

def record_delivery
Expand All @@ -26,4 +27,10 @@ def record_delivery
mailer: mailer_name)
end
end

private

def use_default_locale(&block)
I18n.with_locale(I18n.default_locale, &block)
end
end
12 changes: 12 additions & 0 deletions test/mailers/owners_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ class OwnersMailerTest < ActionMailer::TestCase
assert_equal email.subject, "Your role was updated for the #{@rubygem.name} gem"
end
end

context "#owner_added" do
should "use default locale regardless of ambient I18n.locale" do
I18n.with_locale(:de) do
email = OwnersMailer.owner_added(@owner.id, @maintainer.id, @owner.id, @rubygem.id)

assert_emails(1) { email.deliver_now }
assert_equal "User #{@maintainer.display_handle} was added as an owner to the #{@rubygem.name} gem", email.subject
assert_match "OWNER ADDED", email.body.to_s
end
end
end
end
Loading