Skip to content

Commit

Permalink
add sample mailer
Browse files Browse the repository at this point in the history
  • Loading branch information
ihatov08 committed Oct 28, 2021
1 parent e91eeed commit 648f953
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/mailers/sample_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SampleMailer < ApplicationMailer

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.sample_mailer.hello.subject
#
def hello
@greeting = "Hi"

mail to: "to@example.org"
end
end
5 changes: 5 additions & 0 deletions app/views/sample_mailer/hello.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Sample#hello</h1>

<p>
<%= @greeting %>, find me in app/views/sample_mailer/hello.html.erb
</p>
3 changes: 3 additions & 0 deletions app/views/sample_mailer/hello.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sample#hello

<%= @greeting %>, find me in app/views/sample_mailer/hello.text.erb
9 changes: 9 additions & 0 deletions test/mailers/previews/sample_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Preview all emails at http://localhost:3000/rails/mailers/sample_mailer
class SampleMailerPreview < ActionMailer::Preview

# Preview this email at http://localhost:3000/rails/mailers/sample_mailer/hello
def hello
SampleMailer.hello
end

end
12 changes: 12 additions & 0 deletions test/mailers/sample_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "test_helper"

class SampleMailerTest < ActionMailer::TestCase
test "hello" do
mail = SampleMailer.hello
assert_equal "Hello", mail.subject
assert_equal ["to@example.org"], mail.to
assert_equal ["from@example.com"], mail.from
assert_match "Hi", mail.body.encoded
end

end

0 comments on commit 648f953

Please sign in to comment.