Skip to content

Commit

Permalink
fix: mailer generation with namespaces
Browse files Browse the repository at this point in the history
Fixes #272
  • Loading branch information
flavorjones committed Jan 7, 2024
1 parent 08e5442 commit 2cbf5cc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/generators/tailwindcss/mailer/templates/layout.html.erb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
</head>

<body>
<%%= yield %>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%%= yield %>
32 changes: 31 additions & 1 deletion test/lib/generators/tailwindcss/mailer_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "generators/tailwindcss/mailer/mailer_generator"

class Tailwindcss::Generators::MailerGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::MailerGenerator
tests Tailwindcss::Generators::MailerGenerator
destination Dir.mktmpdir

arguments %w(Notifications invoice)
Expand All @@ -20,6 +20,36 @@ class Tailwindcss::Generators::MailerGeneratorTest < Rails::Generators::TestCase
assert_match %r(app/views/notifications_mailer/invoice\.text\.erb), view
assert_match(/\= @greeting/, view)
end

assert_file "app/views/layouts/mailer.text.erb" do |view|
assert_match("<%= yield %>", view)
end

assert_file "app/views/layouts/mailer.html.erb" do |view|
assert_match("<%= yield %>", view)
end
end

test "generates correct mailer view templates with namespace" do
run_generator ["admin/notifications", "invoice"]

assert_file "app/views/admin/notifications_mailer/invoice.html.erb" do |view|
assert_match %r(app/views/admin/notifications_mailer/invoice\.html\.erb), view
assert_match(/\= @greeting/, view)
end

assert_file "app/views/admin/notifications_mailer/invoice.text.erb" do |view|
assert_match %r(app/views/admin/notifications_mailer/invoice\.text\.erb), view
assert_match(/\= @greeting/, view)
end

assert_file "app/views/layouts/admin/mailer.text.erb" do |view|
assert_match("<%= yield %>", view)
end

assert_file "app/views/layouts/admin/mailer.html.erb" do |view|
assert_match("<%= yield %>", view)
end
end
end

0 comments on commit 2cbf5cc

Please sign in to comment.