start on news mailer
This commit is contained in:
parent
cee41a571e
commit
b5a63df629
|
@ -1,4 +1,5 @@
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
||||||
layout "mailer"
|
layout "mailer"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class FormMailer < ApplicationMailer
|
class FormMailer < ApplicationMailer
|
||||||
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
|
||||||
|
|
||||||
def received(data)
|
def received(data )
|
||||||
@data = data
|
@data = data
|
||||||
mail(to: data['Email'] , subject: "We have received your request")
|
mail(to: data['Email'] , subject: "We have received your request")
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
class NewsMailer < ApplicationMailer
|
||||||
|
helper Merged::ViewHelper
|
||||||
|
|
||||||
|
def letter
|
||||||
|
@page = Merged::Page.find_by_type("blog")
|
||||||
|
|
||||||
|
mail( to: "to@example.org" )
|
||||||
|
end
|
||||||
|
|
||||||
|
def subscribed
|
||||||
|
@greeting = "Hi"
|
||||||
|
|
||||||
|
mail to: "to@example.org"
|
||||||
|
end
|
||||||
|
|
||||||
|
def unsubscribed
|
||||||
|
@greeting = "Hi"
|
||||||
|
|
||||||
|
mail to: "to@example.org"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -2,7 +2,6 @@
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
|
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}/
|
||||||
:css
|
= stylesheet_link_tag "tailwind"
|
||||||
/* Email styles need to be inline */
|
%body.wide
|
||||||
%body
|
|
||||||
= yield
|
= yield
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
- @page.sections.each do |section|
|
||||||
|
= render_section( section )
|
|
@ -0,0 +1,4 @@
|
||||||
|
%h1= class_name + "#" + @action
|
||||||
|
|
||||||
|
%p
|
||||||
|
= @greeting + ", find me in app/views/news_mailer/subscribed.html.haml"
|
|
@ -0,0 +1,3 @@
|
||||||
|
News#subscribed
|
||||||
|
|
||||||
|
= @greeting + ", find me in app/views/news_mailer/subscribed.text.haml"
|
|
@ -0,0 +1,4 @@
|
||||||
|
%h1= class_name + "#" + @action
|
||||||
|
|
||||||
|
%p
|
||||||
|
= @greeting + ", find me in app/views/news_mailer/unsubscribed.html.haml"
|
|
@ -0,0 +1,3 @@
|
||||||
|
News#unsubscribed
|
||||||
|
|
||||||
|
= @greeting + ", find me in app/views/news_mailer/unsubscribed.text.haml"
|
|
@ -0,0 +1,28 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class NewsMailerTest < ActionMailer::TestCase
|
||||||
|
test "letter" do
|
||||||
|
mail = NewsMailer.letter
|
||||||
|
assert_equal "Letter", mail.subject
|
||||||
|
assert_equal ["to@example.org"], mail.to
|
||||||
|
assert_equal ["from@example.com"], mail.from
|
||||||
|
assert_match "Hi", mail.body.encoded
|
||||||
|
end
|
||||||
|
|
||||||
|
test "subscribed" do
|
||||||
|
mail = NewsMailer.subscribed
|
||||||
|
assert_equal "Subscribed", mail.subject
|
||||||
|
assert_equal ["to@example.org"], mail.to
|
||||||
|
assert_equal ["from@example.com"], mail.from
|
||||||
|
assert_match "Hi", mail.body.encoded
|
||||||
|
end
|
||||||
|
|
||||||
|
test "unsubscribed" do
|
||||||
|
mail = NewsMailer.unsubscribed
|
||||||
|
assert_equal "Unsubscribed", mail.subject
|
||||||
|
assert_equal ["to@example.org"], mail.to
|
||||||
|
assert_equal ["from@example.com"], mail.from
|
||||||
|
assert_match "Hi", mail.body.encoded
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -3,7 +3,7 @@ class FormMailerPreview < ActionMailer::Preview
|
||||||
|
|
||||||
# Preview this email at http://localhost:3000/rails/mailers/form_mailer/received
|
# Preview this email at http://localhost:3000/rails/mailers/form_mailer/received
|
||||||
def received
|
def received
|
||||||
FormMailer.received
|
FormMailer.received name: "Me" , email: "You"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class NewsMailerPreview < ActionMailer::Preview
|
||||||
|
|
||||||
|
def letter
|
||||||
|
NewsMailer.letter
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue