require "rails_helper" describe Mailer do describe "#comment" do it "sends emails in the user's locale" do user = create(:user, locale: "es") proposal = create(:proposal, author: user) comment = create(:comment, commentable: proposal) email = I18n.with_locale :en do Mailer.comment(comment) end expect(email.subject).to include("comentado") end it "reads the from address at runtime" do Setting["mailer_from_name"] = "New organization" Setting["mailer_from_address"] = "new@consul.dev" email = Mailer.comment(create(:comment)) expect(email).to deliver_from "New organization " end it "sends emails for comments on legislation proposals" do email = Mailer.comment(create(:legislation_proposal_comment)) expect(email.subject).to include("commented on your proposal") end end describe "#user_invite" do it "uses the default locale setting" do Setting["locales.default"] = "es" Mailer.user_invite("invited@consul.dev").deliver_now expect(ActionMailer::Base.deliveries.last.body.to_s).to match "