Skip to content

Generator: Mailer and styles #84

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

Merged
merged 1 commit into from
Oct 13, 2021
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<h1 class="text-xl font-bold"><%= class_name %>#<%= @action %></h1>
<h1 class="text-lg font-bold text-4xl"><%= class_name %>#<%= @action %></h1>
<p>Find me in <%= @path %></p>
<div>
9 changes: 9 additions & 0 deletions lib/generators/tailwindcss/mailer/mailer_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rails/generators/erb/mailer/mailer_generator"

module Tailwindcss
module Generators
class MailerGenerator < Erb::Generators::MailerGenerator
source_root File.expand_path("../templates", __FILE__)
end
end
end
5 changes: 5 additions & 0 deletions lib/generators/tailwindcss/mailer/templates/view.html.erb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1><%= class_name %>#<%= @action %></h1>

<p>
<%%= @greeting %>, find me in <%= @path %>
</p>
3 changes: 3 additions & 0 deletions lib/generators/tailwindcss/mailer/templates/view.text.erb.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= class_name %>#<%= @action %>

<%%= @greeting %>, find me in <%= @path %>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@

<% end -%>
<div class="inline">
<%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium" %>
<%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
</div>
<%% end %>
31 changes: 31 additions & 0 deletions test/lib/generators/tailwindcss/mailer_generator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require "test_helper"
require "rails/generators/mailer/mailer_generator"
require "generators/tailwindcss/mailer/mailer_generator"

class Tailwindcss::Generators::MailerGeneratorTest < Rails::Generators::TestCase
GENERATION_PATH = File.expand_path("../mailer_tmp", File.dirname(__FILE__))

tests Rails::Generators::MailerGenerator
destination GENERATION_PATH

arguments %w(Notifications invoice)

Minitest.after_run do
FileUtils.rm_rf GENERATION_PATH
end

test "generates correct mailer view templates" do
run_generator

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

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