Commit 9b8228e7916180ebed861891c9266127a6e25324

Authored by Braulio Bhavamitra
1 parent c6d40a34

rails4: use ApplicationMailer pattern

app/mailers/application_mailer.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +class ApplicationMailer < ActionMailer::Base
  2 +
  3 + attr_accessor :environment
  4 +
  5 + def default_url_options options = nil
  6 + options ||= {}
  7 + options[:host] = environment.default_hostname if environment
  8 + options
  9 + end
  10 +
  11 +end
  12 +
app/mailers/comment_notifier.rb
1 -class CommentNotifier < Noosfero::Mailer 1 +class CommentNotifier < ApplicationMailer
2 2
3 def notification(comment) 3 def notification(comment)
4 profile = comment.article.profile 4 profile = comment.article.profile
app/mailers/contact.rb
@@ -30,7 +30,7 @@ class Contact @@ -30,7 +30,7 @@ class Contact
30 Contact::Sender.notification(self).deliver 30 Contact::Sender.notification(self).deliver
31 end 31 end
32 32
33 - class Sender < Noosfero::Mailer 33 + class Sender < ApplicationMailer
34 34
35 def notification(contact) 35 def notification(contact)
36 self.environment = contact.dest.environment 36 self.environment = contact.dest.environment
app/mailers/mailing.rb
@@ -48,7 +48,7 @@ class Mailing &lt; ActiveRecord::Base @@ -48,7 +48,7 @@ class Mailing &lt; ActiveRecord::Base
48 end 48 end
49 end 49 end
50 50
51 - class Sender < Noosfero::Mailer 51 + class Sender < ApplicationMailer
52 52
53 def notification(mailing, recipient) 53 def notification(mailing, recipient)
54 @message = mailing.body 54 @message = mailing.body
app/mailers/pending_task_notifier.rb
1 -class PendingTaskNotifier < Noosfero::Mailer 1 +class PendingTaskNotifier < ApplicationMailer
2 2
3 def notification(person) 3 def notification(person)
4 self.environment = person.environment 4 self.environment = person.environment
app/mailers/scrap_notifier.rb
1 -class ScrapNotifier < Noosfero::Mailer 1 +class ScrapNotifier < ApplicationMailer
2 2
3 def notification(scrap) 3 def notification(scrap)
4 sender, receiver = scrap.sender, scrap.receiver 4 sender, receiver = scrap.sender, scrap.receiver
app/mailers/task_mailer.rb
1 -class TaskMailer < Noosfero::Mailer 1 +class TaskMailer < ApplicationMailer
2 2
3 def target_notification(task, message) 3 def target_notification(task, message)
4 self.environment = task.environment 4 self.environment = task.environment
app/mailers/user_mailer.rb
1 -class UserMailer < Noosfero::Mailer 1 +class UserMailer < ApplicationMailer
2 2
3 def activation_email_notify(user) 3 def activation_email_notify(user)
4 self.environment = user.environment 4 self.environment = user.environment
lib/noosfero/mailer.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -  
2 -class Noosfero::Mailer < ActionMailer::Base  
3 -  
4 - attr_accessor :environment  
5 -  
6 - def default_url_options options = nil  
7 - options ||= {}  
8 - options[:host] = environment.default_hostname if environment  
9 - options  
10 - end  
11 -  
12 -end  
13 -  
lib/noosfero/plugin/mailer_base.rb
1 -class Noosfero::Plugin::MailerBase < ActionMailer::Base 1 +require_relative '../../../app/mailers/application_mailer'
  2 +
  3 +class Noosfero::Plugin::MailerBase < ApplicationMailer
2 4
3 def self.plugin_name 5 def self.plugin_name
4 name.split('::').first.gsub(/Plugin$/, '').underscore 6 name.split('::').first.gsub(/Plugin$/, '').underscore
plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb
@@ -28,7 +28,7 @@ class WorkAssignmentPlugin::EmailContact @@ -28,7 +28,7 @@ class WorkAssignmentPlugin::EmailContact
28 WorkAssignmentPlugin::EmailContact::EmailSender.notification(self).deliver 28 WorkAssignmentPlugin::EmailContact::EmailSender.notification(self).deliver
29 end 29 end
30 30
31 - class EmailSender < Noosfero::Mailer 31 + class EmailSender < ApplicationMailer
32 32
33 def notification(email_contact) 33 def notification(email_contact)
34 self.environment = email_contact.sender.environment 34 self.environment = email_contact.sender.environment