Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mailer generation with namespaces #308

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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