From dba64199dced5ba72cc3bc7b34973425b3aaf5a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aleksandrs=20=C4=BBedovskis?=
Date: Sat, 7 Jul 2018 18:39:08 +0300
Subject: [PATCH] Refactor MJML layout/template support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Aleksandrs Ļedovskis
---
Gemfile | 3 +-
Gemfile.lock | 137 ++++++++++--------
README.md | 70 ++++-----
.../mjml/mailer/mailer_generator.rb | 15 +-
.../mjml/mailer/templates/layout.html.mjml | 5 +
.../mjml/mailer/templates/layout.mjml | 1 -
.../templates/{view.mjml => view.html.erb} | 0
lib/mjml.rb | 10 +-
test/generator_test.rb | 16 +-
test/mjml_subdir_test.rb | 76 ----------
test/mjml_test.rb | 136 +++++------------
test/views/layouts/_email_tracking_code.ruby | 6 +
test/views/layouts/default.html.mjml | 19 +++
test/views/layouts/default.text.ruby | 1 +
test/views/no_layout_mailer/_user_header.mjml | 5 +
.../no_layout_mailer/inform_contact.mjml | 14 ++
test/views/notifier/_link.mjml | 1 -
test/views/notifier/_user_info.mjml | 1 -
test/views/notifier/contact.mjml | 10 --
test/views/notifier/no_partial.mjml | 9 --
test/views/notifier/user.mjml | 10 --
.../notifier_mailer/_user_header.html.erb | 5 +
.../notifier_mailer/inform_contact.html.erb | 8 +
.../views/notifier_mailer/inform_contact.text | 4 +
test/views/template_subdir/simple.mjml | 9 --
.../simple_block_and_path.mjml | 9 --
.../template_subdir/simple_with_path.mjml | 9 --
27 files changed, 245 insertions(+), 344 deletions(-)
create mode 100644 lib/generators/mjml/mailer/templates/layout.html.mjml
delete mode 100644 lib/generators/mjml/mailer/templates/layout.mjml
rename lib/generators/mjml/mailer/templates/{view.mjml => view.html.erb} (100%)
delete mode 100644 test/mjml_subdir_test.rb
create mode 100644 test/views/layouts/_email_tracking_code.ruby
create mode 100644 test/views/layouts/default.html.mjml
create mode 100644 test/views/layouts/default.text.ruby
create mode 100644 test/views/no_layout_mailer/_user_header.mjml
create mode 100644 test/views/no_layout_mailer/inform_contact.mjml
delete mode 100644 test/views/notifier/_link.mjml
delete mode 100644 test/views/notifier/_user_info.mjml
delete mode 100644 test/views/notifier/contact.mjml
delete mode 100644 test/views/notifier/no_partial.mjml
delete mode 100644 test/views/notifier/user.mjml
create mode 100644 test/views/notifier_mailer/_user_header.html.erb
create mode 100644 test/views/notifier_mailer/inform_contact.html.erb
create mode 100644 test/views/notifier_mailer/inform_contact.text
delete mode 100644 test/views/template_subdir/simple.mjml
delete mode 100644 test/views/template_subdir/simple_block_and_path.mjml
delete mode 100644 test/views/template_subdir/simple_with_path.mjml
diff --git a/Gemfile b/Gemfile
index 950d932..5f659a1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,8 @@ source 'https://rubygems.org'
gemspec
-gem 'rails', '4.2.6'
+gem 'rails', '~> 5.2'
+gem 'byebug'
group :development do
# gem 'guard' # NOTE: this is necessary in newer versions
diff --git a/Gemfile.lock b/Gemfile.lock
index cf26c0f..4a82dd3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -6,93 +6,104 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- actionmailer (4.2.6)
- actionpack (= 4.2.6)
- actionview (= 4.2.6)
- activejob (= 4.2.6)
+ actioncable (5.2.0)
+ actionpack (= 5.2.0)
+ nio4r (~> 2.0)
+ websocket-driver (>= 0.6.1)
+ actionmailer (5.2.0)
+ actionpack (= 5.2.0)
+ actionview (= 5.2.0)
+ activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- actionpack (4.2.6)
- actionview (= 4.2.6)
- activesupport (= 4.2.6)
- rack (~> 1.6)
- rack-test (~> 0.6.2)
- rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.2.0)
+ actionview (= 5.2.0)
+ activesupport (= 5.2.0)
+ rack (~> 2.0)
+ rack-test (>= 0.6.3)
+ rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (4.2.6)
- activesupport (= 4.2.6)
+ actionview (5.2.0)
+ activesupport (= 5.2.0)
builder (~> 3.1)
- erubis (~> 2.7.0)
- rails-dom-testing (~> 1.0, >= 1.0.5)
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
- activejob (4.2.6)
- activesupport (= 4.2.6)
- globalid (>= 0.3.0)
- activemodel (4.2.6)
- activesupport (= 4.2.6)
- builder (~> 3.1)
- activerecord (4.2.6)
- activemodel (= 4.2.6)
- activesupport (= 4.2.6)
- arel (~> 6.0)
- activesupport (4.2.6)
- i18n (~> 0.7)
- json (~> 1.7, >= 1.7.7)
+ erubi (~> 1.4)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.2.0)
+ activesupport (= 5.2.0)
+ globalid (>= 0.3.6)
+ activemodel (5.2.0)
+ activesupport (= 5.2.0)
+ activerecord (5.2.0)
+ activemodel (= 5.2.0)
+ activesupport (= 5.2.0)
+ arel (>= 9.0)
+ activestorage (5.2.0)
+ actionpack (= 5.2.0)
+ activerecord (= 5.2.0)
+ marcel (~> 0.3.1)
+ activesupport (5.2.0)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
minitest (~> 5.1)
- thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
- arel (6.0.4)
+ arel (9.0.0)
builder (3.2.3)
+ byebug (10.0.2)
concurrent-ruby (1.0.5)
crass (1.0.4)
- erubis (2.7.0)
+ erubi (1.7.1)
globalid (0.4.1)
activesupport (>= 4.2.0)
- i18n (0.9.5)
+ i18n (1.0.1)
concurrent-ruby (~> 1.0)
- json (1.8.6)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
+ marcel (0.3.2)
+ mimemagic (~> 0.3.2)
metaclass (0.0.4)
+ method_source (0.9.0)
+ mimemagic (0.3.2)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
mocha (1.4.0)
metaclass (~> 0.0.1)
- nokogiri (1.8.2)
+ nio4r (2.3.1)
+ nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
- rack (1.6.10)
- rack-test (0.6.3)
- rack (>= 1.0)
- rails (4.2.6)
- actionmailer (= 4.2.6)
- actionpack (= 4.2.6)
- actionview (= 4.2.6)
- activejob (= 4.2.6)
- activemodel (= 4.2.6)
- activerecord (= 4.2.6)
- activesupport (= 4.2.6)
- bundler (>= 1.3.0, < 2.0)
- railties (= 4.2.6)
- sprockets-rails
- rails-deprecated_sanitizer (1.0.3)
- activesupport (>= 4.2.0.alpha)
- rails-dom-testing (1.0.9)
- activesupport (>= 4.2.0, < 5.0)
- nokogiri (~> 1.6)
- rails-deprecated_sanitizer (>= 1.0.1)
+ rack (2.0.5)
+ rack-test (1.0.0)
+ rack (>= 1.0, < 3)
+ rails (5.2.0)
+ actioncable (= 5.2.0)
+ actionmailer (= 5.2.0)
+ actionpack (= 5.2.0)
+ actionview (= 5.2.0)
+ activejob (= 5.2.0)
+ activemodel (= 5.2.0)
+ activerecord (= 5.2.0)
+ activestorage (= 5.2.0)
+ activesupport (= 5.2.0)
+ bundler (>= 1.3.0)
+ railties (= 5.2.0)
+ sprockets-rails (>= 2.0.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
- railties (4.2.6)
- actionpack (= 4.2.6)
- activesupport (= 4.2.6)
+ railties (5.2.0)
+ actionpack (= 5.2.0)
+ activesupport (= 5.2.0)
+ method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
- sprockets (3.7.1)
+ sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
@@ -103,14 +114,18 @@ GEM
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
+ websocket-driver (0.7.0)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
+ byebug
mjml-rails!
mocha (= 1.4.0)
- rails (= 4.2.6)
+ rails (~> 5.2)
BUNDLED WITH
- 1.16.1
+ 1.16.2
diff --git a/README.md b/README.md
index 03b93fe..f250e8f 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
An example template might look like:
```erb
-
+
Hello World
@@ -16,7 +16,7 @@ An example template might look like:
Hello World
- <%= render :partial => 'info', :formats => [:html] %>
+ <%= render partial: "info" %>
@@ -26,19 +26,19 @@ An example template might look like:
And the partial `_info.mjml`:
```erb
-
+
This is <%= @user.username %>
```
-* Notice you can use ERb and partials inside the template.
+* Notice you can use ERB and partials inside the template.
Your `user_mailer.rb` might look like this::
```ruby
# ./app/mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
- def user_signup_confirmation()
- mail(to: 'test@example.com', subject: 'test') do |format|
+ def user_signup_confirmation
+ mail(to: "user@example.com", from: "app@example.com") do |format|
format.text
format.mjml
end
@@ -118,65 +118,53 @@ npm install -g mjml@3.3.5
Mailer:
```ruby
-# mailers/foo_mailer.rb
+# mailers/my_mailer.rb
class MyMailer < ActionMailer::Base
layout "default"
- def mail_template(template_name, recipient, subject, **params)
- mail(
- to: recipient.email,
- from: ENV["MAILER_FROM"],
- subject: subject
- ) do |format|
- format.mjml { render template_name, locals: { recipient: recipient }.merge(params) }
- end
- end
+ def foo_bar(user)
+ @recipient = user
- # this function is called to send the email
- def foo(item, user)
- mail_template(
- "foo_bar",
- user,
- "email subject",
- request: item
- )
+ mail(to: user.email, from: "app@example.com") do |format|
+ format.html
+ end
end
end
```
Email layout:
```html
-
+
-
- <%= yield %>
-
+
+ <%= yield %>
+
```
Email view:
```html
-
-<%= render partial: "to", formats: [:html], locals: { name: recipient.name } %>
+
+<%= render partial: "to" %>
-
-
- Hello <%= recipient.name %>!
-
-
+
+
+ Something foo regarding bar!
+
+
```
Email partial:
```html
-
+
-
-
- <%= name %>,
-
-
+
+
+ Hello <%= @recipient.name %>,
+
+
```
diff --git a/lib/generators/mjml/mailer/mailer_generator.rb b/lib/generators/mjml/mailer/mailer_generator.rb
index 85c8d3d..16d8ed9 100644
--- a/lib/generators/mjml/mailer/mailer_generator.rb
+++ b/lib/generators/mjml/mailer/mailer_generator.rb
@@ -5,10 +5,10 @@ module Generators
class MailerGenerator < Erb::Generators::MailerGenerator
source_root File.expand_path("../templates", __FILE__)
- protected
+ private
def format
- nil # Our templates have no format
+ :html
end
def formats
@@ -18,6 +18,17 @@ def formats
def handler
:mjml
end
+
+ def view_handler
+ Mjml.template_language
+ end
+
+ def filename_with_extensions(name, file_format = format)
+ # Due to MJML single-pass processing nature
+ # layout files MUST have .mjml extension, but views/templates cannot
+ is_layout_file = name.in?([:layout, "mailer"])
+ [name, file_format, is_layout_file ? handler : view_handler].compact.join(".")
+ end
end
end
end
diff --git a/lib/generators/mjml/mailer/templates/layout.html.mjml b/lib/generators/mjml/mailer/templates/layout.html.mjml
new file mode 100644
index 0000000..d5c434d
--- /dev/null
+++ b/lib/generators/mjml/mailer/templates/layout.html.mjml
@@ -0,0 +1,5 @@
+
+
+ <%%= yield %>
+
+
diff --git a/lib/generators/mjml/mailer/templates/layout.mjml b/lib/generators/mjml/mailer/templates/layout.mjml
deleted file mode 100644
index 6363733..0000000
--- a/lib/generators/mjml/mailer/templates/layout.mjml
+++ /dev/null
@@ -1 +0,0 @@
-<%%= yield %>
diff --git a/lib/generators/mjml/mailer/templates/view.mjml b/lib/generators/mjml/mailer/templates/view.html.erb
similarity index 100%
rename from lib/generators/mjml/mailer/templates/view.mjml
rename to lib/generators/mjml/mailer/templates/view.html.erb
diff --git a/lib/mjml.rb b/lib/mjml.rb
index eb68fa6..81ac65a 100644
--- a/lib/mjml.rb
+++ b/lib/mjml.rb
@@ -41,7 +41,15 @@ def template_handler
def call(template)
compiled_source = template_handler.call(template)
- if template.formats.include?(:mjml)
+
+ # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with root tag
+ # If we get here and template source doesn't start with one it means
+ # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
+ # Therefore we skip MJML processing and return raw compiled source. It will be processed
+ # by MJML library when top-level layout/template is rendered
+ #
+ # [0] - https://github.com/mjmlio/mjml/blob/master/doc/guide.md#mjml
+ if template.source =~ //
"Mjml::Mjmltemplate.to_html(begin;#{compiled_source};end).html_safe"
else
compiled_source
diff --git a/test/generator_test.rb b/test/generator_test.rb
index 88cc531..3c2e6c4 100644
--- a/test/generator_test.rb
+++ b/test/generator_test.rb
@@ -9,8 +9,18 @@ class GeneratorTest < Rails::Generators::TestCase
test "assert all views are properly created with given name" do
run_generator %w(notifier foo bar baz)
- assert_file "app/views/notifier/foo.mjml"
- assert_file "app/views/notifier/bar.mjml"
- assert_file "app/views/notifier/baz.mjml"
+ assert_file "app/views/layouts/mailer.html.mjml" do |mailer|
+ assert_match "", mailer
+ assert_match "", mailer
+ assert_match "<%= yield %>", mailer
+ end
+
+ assert_file "app/views/notifier_mailer/foo.html.erb" do |template|
+ assert_match "<%= @greeting %>", template
+ assert_match "app/views/notifier_mailer/foo.html.erb", template
+ end
+
+ assert_file "app/views/notifier_mailer/bar.html.erb"
+ assert_file "app/views/notifier_mailer/baz.html.erb"
end
end
diff --git a/test/mjml_subdir_test.rb b/test/mjml_subdir_test.rb
deleted file mode 100644
index 51f0921..0000000
--- a/test/mjml_subdir_test.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-require "test_helper"
-
-class SubdirNotifier < ActionMailer::Base
- self.view_paths = File.expand_path("../views", __FILE__)
-
- layout false
-
- def simple_block(format_type)
- mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
- format.send(format_type)
- end
- end
-
- def simple_block_and_path(format_type)
- mail(:template_path => 'template_subdir',:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
- format.send(format_type)
- end
- end
-
- def simple_with_path(format_type)
- mail(:template_path => 'template_subdir',:to => 'foo@bar.com', :from => "john.doe@example.com")
- end
-
-end
-
-# class TestRenderer < ActionView::PartialRenderer
-# attr_accessor :show_text
-# def initialize(render_options = {})
-# @show_text = render_options.delete(:show_text)
-# super(render_options)
-# end
-
-# def normal_text(text)
-# show_text ? "TEST #{text}" : "TEST"
-# end
-# end
-
-class MjmlTest < ActiveSupport::TestCase
-
- setup do
- @original_renderer = Mjml.renderer
- @original_processing_options = Mjml.processing_options
- end
-
- teardown do
- Mjml.renderer = @original_renderer
- Mjml.processing_options = @original_processing_options
- end
-
-
- test 'in a subdir with a block fails' do
- assert_raises(ActionView::MissingTemplate) do
- email = SubdirNotifier.simple_block(:mjml)
- assert_equal "text/html", email.mime_type
- assert_match(/alternate sub-directory/, email.body.encoded.strip)
- assert_no_match(/mj-text/, email.body.encoded.strip)
- end
- end
-
- test 'in a subdir with a block and template_path option fails' do
- assert_raises(ActionView::MissingTemplate) do
- email = SubdirNotifier.simple_block_and_path(:mjml)
- assert_equal "text/html", email.mime_type
- assert_match(/alternate sub-directory/, email.body.encoded.strip)
- assert_no_match(/mj-text/, email.body.encoded.strip)
- end
- end
-
- test 'in a subdir with path' do
- email = SubdirNotifier.simple_with_path(:mjml)
- assert_equal "text/html", email.mime_type
- assert_match(/alternate sub-directory/, email.body.encoded.strip)
- assert_no_match(/mj-text/, email.body.encoded.strip)
- end
-
-end
diff --git a/test/mjml_test.rb b/test/mjml_test.rb
index a778b9e..b881875 100644
--- a/test/mjml_test.rb
+++ b/test/mjml_test.rb
@@ -1,127 +1,63 @@
require "test_helper"
-class Notifier < ActionMailer::Base
+class NotifierMailer < ActionMailer::Base
self.view_paths = File.expand_path("../views", __FILE__)
- layout false
+ layout "default"
- def contact(recipient, format_type)
+ def inform_contact(recipient)
@recipient = recipient
- mail(:to => @recipient, :from => "john.doe@example.com") do |format|
- format.send(format_type)
- end
- end
- def link(format_type)
- mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
- format.send(format_type)
+ mail(to: @recipient, from: "app@example.com") do |format|
+ format.text
+ format.html
end
end
+end
- def user(format_type)
- mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
- format.send(format_type)
- end
- end
+class NoLayoutMailer < ActionMailer::Base
+ self.view_paths = File.expand_path("../views", __FILE__)
- def no_partial(format_type)
- mail(:to => 'foo@bar.com', :from => "john.doe@example.com") do |format|
- format.send(format_type)
- end
- end
+ layout nil
- def multiple_format_contact(recipient)
+ def inform_contact(recipient)
@recipient = recipient
- mail(:to => @recipient, :from => "john.doe@example.com", :template => "contact") do |format|
- format.text { render 'contact' }
- format.html { render 'contact' }
+
+ mail(to: @recipient, from: "app@example.com") do |format|
+ format.mjml
end
end
end
-# class TestRenderer < ActionView::PartialRenderer
-# attr_accessor :show_text
-# def initialize(render_options = {})
-# @show_text = render_options.delete(:show_text)
-# super(render_options)
-# end
+class NotifierMailerTest < ActiveSupport::TestCase
+ test "MJML layout based multipart email is generated correctly" do
+ email = NotifierMailer.inform_contact("user@example.com")
-# def normal_text(text)
-# show_text ? "TEST #{text}" : "TEST"
-# end
-# end
+ assert_equal "multipart/alternative", email.mime_type
-class MjmlTest < ActiveSupport::TestCase
-
- setup do
- @original_renderer = Mjml.renderer
- @original_processing_options = Mjml.processing_options
- end
+ refute email.html_part.body.match(%r{?mj.+?>})
+ assert email.html_part.body.match(//)
+ assert email.html_part.body.match(/Hello, user@example.com!/)
+ assert email.html_part.body.match(%r{We inform you about something
})
+ assert email.html_part.body.match(%r{this link})
+ assert email.html_part.body.match(/tracking-code-123/)
- teardown do
- Mjml.renderer = @original_renderer
- Mjml.processing_options = @original_processing_options
+ assert email.text_part.body.match(/We inform you about something/)
+ assert email.text_part.body.match(%r{Please visit https://www.example.com})
end
+end
- test "html should be sent as html" do
- email = Notifier.contact("you@example.com", :mjml)
- assert_equal "text/html", email.mime_type
- assert_no_match(//, email.body.encoded.strip)
- assert_match(/Hello from sighmon.com
', email.body.encoded.strip)
- end
+class NotifierMailerTest < ActiveSupport::TestCase
+ test "old mjml-rails configuration style MJML template is rendered correctly" do
+ email = NoLayoutMailer.inform_contact("user@example.com")
- test 'with partial' do
- email = Notifier.user(:mjml)
assert_equal "text/html", email.mime_type
- assert_match(/Hello Partial/, email.body.encoded.strip)
- assert_no_match(/mj-text/, email.body.encoded.strip)
- end
- test 'without a partial' do
- email = Notifier.no_partial(:mjml)
- assert_equal "text/html", email.mime_type
- assert_match(/Hello World/, email.body.encoded.strip)
- assert_no_match(/mj-text/, email.body.encoded.strip)
+ refute email.body.match(%r{?mj.+?>})
+ assert email.body.match(//)
+ assert email.body.match(/Welcome, user@example.com!/)
+ assert email.body.match(%r{We inform you about something
})
+ assert email.body.match(%r{this link})
+ refute email.body.match(/tracking-code-123/)
end
-
- # test "plain text should be sent as a plain text" do
- # email = Notifier.contact("you@example.com", :text)
- # assert_equal "text/plain", email.mime_type
- # assert_equal "", email.body.encoded.strip
- # end
-
- # test 'dealing with multipart e-mails' do
- # email = Notifier.multiple_format_contact("you@example.com")
- # assert_equal 2, email.parts.size
- # assert_equal "multipart/alternative", email.mime_type
- # assert_equal "text/plain", email.parts[0].mime_type
- # assert_equal "",
- # email.parts[0].body.encoded.strip
- # assert_equal "text/html", email.parts[1].mime_type
- # assert_not_equal "",
- # email.parts[1].body.encoded.strip
- # end
-
- # test "with a custom renderer" do
- # Mjml.renderer = TestRenderer
- # email = Notifier.contact("you@example.com", :html)
- # assert_equal "text/html", email.mime_type
- # assert_equal "TESTTESTTEST
", email.body.encoded.strip
- # end
-
- # test "with a custom renderer and options" do
- # Mjml.renderer = TestRenderer.new(:show_text => true)
- # email = Notifier.contact("you@example.com", :html)
- # assert_equal "text/html", email.mime_type
- # assert_equal "TEST Dual templates TEST rocksTEST !
", email.body.encoded.strip
- # end
-
- # test 'with custom mjml processing options' do
- # Mjml.processing_options = {:autolink => true}
- # email = Notifier.link(:html)
- # assert_equal "text/html", email.mime_type
- # assert_equal 'Hello from http://www.sighmon.com
', email.body.encoded.strip
- # end
-
end
diff --git a/test/views/layouts/_email_tracking_code.ruby b/test/views/layouts/_email_tracking_code.ruby
new file mode 100644
index 0000000..aabb4dd
--- /dev/null
+++ b/test/views/layouts/_email_tracking_code.ruby
@@ -0,0 +1,6 @@
+def render_code
+ # tracking-code-123
+ Base64.decode64("dHJhY2tpbmctY29kZS0xMjM=")
+end
+
+render_code
diff --git a/test/views/layouts/default.html.mjml b/test/views/layouts/default.html.mjml
new file mode 100644
index 0000000..6f60ea3
--- /dev/null
+++ b/test/views/layouts/default.html.mjml
@@ -0,0 +1,19 @@
+
+
+
+
+ Home
+ Contacts
+
+
+
+
+ <%= yield %>
+
+
+
+
+
+
+
+
diff --git a/test/views/layouts/default.text.ruby b/test/views/layouts/default.text.ruby
new file mode 100644
index 0000000..fcd1a85
--- /dev/null
+++ b/test/views/layouts/default.text.ruby
@@ -0,0 +1 @@
+yield
diff --git a/test/views/no_layout_mailer/_user_header.mjml b/test/views/no_layout_mailer/_user_header.mjml
new file mode 100644
index 0000000..97da6dc
--- /dev/null
+++ b/test/views/no_layout_mailer/_user_header.mjml
@@ -0,0 +1,5 @@
+
+
+ Welcome, <%= @recipient %>!
+
+
diff --git a/test/views/no_layout_mailer/inform_contact.mjml b/test/views/no_layout_mailer/inform_contact.mjml
new file mode 100644
index 0000000..0e403ed
--- /dev/null
+++ b/test/views/no_layout_mailer/inform_contact.mjml
@@ -0,0 +1,14 @@
+
+
+
+ <%= render partial: "user_header", formats: [:html] %>
+
+
+
+ We inform you about something
+
+ Please visit this link
+
+
+
+
diff --git a/test/views/notifier/_link.mjml b/test/views/notifier/_link.mjml
deleted file mode 100644
index 3d306d3..0000000
--- a/test/views/notifier/_link.mjml
+++ /dev/null
@@ -1 +0,0 @@
-Hello from sighmon.com
\ No newline at end of file
diff --git a/test/views/notifier/_user_info.mjml b/test/views/notifier/_user_info.mjml
deleted file mode 100644
index ce2b2d6..0000000
--- a/test/views/notifier/_user_info.mjml
+++ /dev/null
@@ -1 +0,0 @@
-Hello Partial
\ No newline at end of file
diff --git a/test/views/notifier/contact.mjml b/test/views/notifier/contact.mjml
deleted file mode 100644
index 237e1b6..0000000
--- a/test/views/notifier/contact.mjml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- Hello World
- <%= render :partial => 'link', :formats => [:html] %>
-
-
-
-
diff --git a/test/views/notifier/no_partial.mjml b/test/views/notifier/no_partial.mjml
deleted file mode 100644
index fc826c0..0000000
--- a/test/views/notifier/no_partial.mjml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- Hello World
-
-
-
-
diff --git a/test/views/notifier/user.mjml b/test/views/notifier/user.mjml
deleted file mode 100644
index 337b660..0000000
--- a/test/views/notifier/user.mjml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
- Hello World
- <%= render :partial => 'user_info', :formats => [:html] %>
-
-
-
-
diff --git a/test/views/notifier_mailer/_user_header.html.erb b/test/views/notifier_mailer/_user_header.html.erb
new file mode 100644
index 0000000..7bc35bb
--- /dev/null
+++ b/test/views/notifier_mailer/_user_header.html.erb
@@ -0,0 +1,5 @@
+
+
+ Hello, <%= @recipient %>!
+
+
diff --git a/test/views/notifier_mailer/inform_contact.html.erb b/test/views/notifier_mailer/inform_contact.html.erb
new file mode 100644
index 0000000..6f49bb1
--- /dev/null
+++ b/test/views/notifier_mailer/inform_contact.html.erb
@@ -0,0 +1,8 @@
+<%= render "user_header" %>
+
+
+ We inform you about something
+
+ Please visit this link
+
+
diff --git a/test/views/notifier_mailer/inform_contact.text b/test/views/notifier_mailer/inform_contact.text
new file mode 100644
index 0000000..1dce85e
--- /dev/null
+++ b/test/views/notifier_mailer/inform_contact.text
@@ -0,0 +1,4 @@
+We inform you about something
+-----------------------------
+
+Please visit https://www.example.com
diff --git a/test/views/template_subdir/simple.mjml b/test/views/template_subdir/simple.mjml
deleted file mode 100644
index 413ff6f..0000000
--- a/test/views/template_subdir/simple.mjml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- This template is in an alternate sub-directory
-
-
-
-
diff --git a/test/views/template_subdir/simple_block_and_path.mjml b/test/views/template_subdir/simple_block_and_path.mjml
deleted file mode 100644
index 413ff6f..0000000
--- a/test/views/template_subdir/simple_block_and_path.mjml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- This template is in an alternate sub-directory
-
-
-
-
diff --git a/test/views/template_subdir/simple_with_path.mjml b/test/views/template_subdir/simple_with_path.mjml
deleted file mode 100644
index 413ff6f..0000000
--- a/test/views/template_subdir/simple_with_path.mjml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
- This template is in an alternate sub-directory
-
-
-
-