form mailer

This commit is contained in:
Torsten 2023-02-09 12:49:33 +02:00
parent 454a3de3f2
commit a04c860354
8 changed files with 74 additions and 6 deletions

View File

@ -1,6 +1,6 @@
GIT
remote: https://github.com/HubFeenixMakers/merged
revision: b44c29ff50bbfc07b04a6064804ac3684eed151d
revision: 5b0ccafc0e78cc72d95865abf001c7b65b69a96f
specs:
merged (0.1.0)
active_hash
@ -146,7 +146,7 @@ GEM
formatador (1.1.0)
friendly_id (5.5.0)
activerecord (>= 4.0.0)
git (1.13.1)
git (1.13.2)
addressable (~> 2.8)
rchardet (~> 1.8)
globalid (1.1.0)
@ -224,7 +224,7 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.8)
mail (2.8.0.1)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
@ -256,7 +256,7 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.5.8)
nokogiri (1.14.0-x86_64-linux)
nokogiri (1.14.1-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)

View File

@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
layout "mailer"
end

View File

@ -0,0 +1,8 @@
class FormMailer < ApplicationMailer
default from: "info@hubfeenix.fi" , bcc: "info@hubfeenix.fi"
def received(data)
@data = data
mail(subject: "We have received your request")
end
end

View File

@ -0,0 +1,21 @@
%h1 Hello
= @data["name"]
%p
This is an automated message confirming that we have receievd your request
%p
Your form input is listed below. If you need to amend or correct, you may reply
to this email.
%p
You will hear from us in the next few days
%p
Your friendly Feenix Bot
%h3 Data received
- @data.each do |name , value|
%p
= "#{name}: #{value}"

View File

@ -0,0 +1,17 @@
="Hello #{@data['name']}"
This is an automated message confirming that we have receievd your request
Your form input is listed below. If you need to amend or correct, you may reply
to this email.
You will hear from us in the next few days
Your friendly Feenix Bot
Data received
-------------
- @data.each do |name , value|
= "#{name}: #{value}"

View File

@ -1,10 +1,11 @@
class FormHandler
def handle_form(section , data )
puts "Section on page : #{section.page.name}"
@data = data
data.each do |name , value|
puts "#{name}: #{value}"
end
FormMailer.received(data).deliver_later
end
end

View File

@ -0,0 +1,12 @@
require "test_helper"
class FormMailerTest < ActionMailer::TestCase
test "received" do
mail = FormMailer.received
assert_equal "Received", mail.subject
assert_equal ["to@example.org"], mail.to
assert_equal ["from@example.com"], mail.from
assert_match "Hi", mail.body.encoded
end
end

View File

@ -0,0 +1,9 @@
# Preview all emails at http://localhost:3000/rails/mailers/form_mailer
class FormMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/form_mailer/received
def received
FormMailer.received
end
end