Commit 9b8228e7916180ebed861891c9266127a6e25324

Authored by Braulio Bhavamitra
1 parent c6d40a34

rails4: use ApplicationMailer pattern

app/mailers/application_mailer.rb 0 → 100644
... ... @@ -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 3 def notification(comment)
4 4 profile = comment.article.profile
... ...
app/mailers/contact.rb
... ... @@ -30,7 +30,7 @@ class Contact
30 30 Contact::Sender.notification(self).deliver
31 31 end
32 32  
33   - class Sender < Noosfero::Mailer
  33 + class Sender < ApplicationMailer
34 34  
35 35 def notification(contact)
36 36 self.environment = contact.dest.environment
... ...
app/mailers/mailing.rb
... ... @@ -48,7 +48,7 @@ class Mailing &lt; ActiveRecord::Base
48 48 end
49 49 end
50 50  
51   - class Sender < Noosfero::Mailer
  51 + class Sender < ApplicationMailer
52 52  
53 53 def notification(mailing, recipient)
54 54 @message = mailing.body
... ...
app/mailers/pending_task_notifier.rb
1   -class PendingTaskNotifier < Noosfero::Mailer
  1 +class PendingTaskNotifier < ApplicationMailer
2 2  
3 3 def notification(person)
4 4 self.environment = person.environment
... ...
app/mailers/scrap_notifier.rb
1   -class ScrapNotifier < Noosfero::Mailer
  1 +class ScrapNotifier < ApplicationMailer
2 2  
3 3 def notification(scrap)
4 4 sender, receiver = scrap.sender, scrap.receiver
... ...
app/mailers/task_mailer.rb
1   -class TaskMailer < Noosfero::Mailer
  1 +class TaskMailer < ApplicationMailer
2 2  
3 3 def target_notification(task, message)
4 4 self.environment = task.environment
... ...
app/mailers/user_mailer.rb
1   -class UserMailer < Noosfero::Mailer
  1 +class UserMailer < ApplicationMailer
2 2  
3 3 def activation_email_notify(user)
4 4 self.environment = user.environment
... ...
lib/noosfero/mailer.rb
... ... @@ -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 5 def self.plugin_name
4 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 28 WorkAssignmentPlugin::EmailContact::EmailSender.notification(self).deliver
29 29 end
30 30  
31   - class EmailSender < Noosfero::Mailer
  31 + class EmailSender < ApplicationMailer
32 32  
33 33 def notification(email_contact)
34 34 self.environment = email_contact.sender.environment
... ...