From 90ad9ff8875ec537b16149db801523c32e7e3b73 Mon Sep 17 00:00:00 2001 From: Stas Date: Tue, 17 Nov 2015 16:56:53 +0200 Subject: [PATCH] 107821878-que_mailer --- app/mailers/contact_mailer.rb | 3 +-- app/models/contact.rb | 2 +- spec/mailers/contact_mailer_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index 7905b0451..2f858a585 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -1,8 +1,7 @@ class ContactMailer < ApplicationMailer include Que::Mailer - def email_updated(email_id, contact_id) - email = Email.find_by(id: email_id) + def email_updated(email, contact_id) @contact = Contact.find_by(id: contact_id) return unless email || @contact return if delivery_off?(contact) diff --git a/app/models/contact.rb b/app/models/contact.rb index 3c1e0d274..9f623a262 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -50,7 +50,7 @@ class Contact < ActiveRecord::Base emails << domains.map(&:registrant_email) if domains.present? emails = emails.flatten.uniq emails.each do |e| - ContactMailer.email_updated(e.id, id).deliver + ContactMailer.email_updated(e, id).deliver end end diff --git a/spec/mailers/contact_mailer_spec.rb b/spec/mailers/contact_mailer_spec.rb index 033843b50..f0402e3db 100644 --- a/spec/mailers/contact_mailer_spec.rb +++ b/spec/mailers/contact_mailer_spec.rb @@ -8,7 +8,7 @@ describe ContactMailer do describe 'email changed notification when delivery turned off' do before :all do @contact = Fabricate(:contact, email: 'test@example.ee') - @mail = ContactMailer.email_updated('test@example.com', @contact) + @mail = ContactMailer.email_updated('test@example.com', @contact.id) end it 'should not render email subject' do @@ -34,7 +34,7 @@ describe ContactMailer do @contact = @domain.registrant @contact.reload # until figured out why registrant_domains not loaded @contact.deliver_emails = true - @mail = ContactMailer.email_updated('info@example.org', @contact) + @mail = ContactMailer.email_updated('info@example.org', @contact.id) end it 'should render email subject' do @@ -60,7 +60,7 @@ describe ContactMailer do @contact = @domain.registrant @contact.reload # until figured out why registrant_domains not loaded @contact.deliver_emails = true - @mail = ContactMailer.email_updated('info@ääöü.org', @contact) + @mail = ContactMailer.email_updated('info@ääöü.org', @contact.id) end it 'should render email subject' do