Skip to content

Commit c3177f4

Browse files
authored
Generator: Mailer and styles (#84)
Testing only mailer wasn't working from the default rails generators, so this PR adds mailer also. Also, fixes pointer on the submit button and small fix on controller h1 style to match the one from the scaffold index.
1 parent 9941df2 commit c3177f4

File tree

6 files changed

+50
-2
lines changed

6 files changed

+50
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div>
2-
<h1 class="text-xl font-bold"><%= class_name %>#<%= @action %></h1>
2+
<h1 class="text-lg font-bold text-4xl"><%= class_name %>#<%= @action %></h1>
33
<p>Find me in <%= @path %></p>
44
<div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "rails/generators/erb/mailer/mailer_generator"
2+
3+
module Tailwindcss
4+
module Generators
5+
class MailerGenerator < Erb::Generators::MailerGenerator
6+
source_root File.expand_path("../templates", __FILE__)
7+
end
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<h1><%= class_name %>#<%= @action %></h1>
2+
3+
<p>
4+
<%%= @greeting %>, find me in <%= @path %>
5+
</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%= class_name %>#<%= @action %>
2+
3+
<%%= @greeting %>, find me in <%= @path %>

lib/generators/tailwindcss/scaffold/templates/_form.html.erb.tt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838

3939
<% end -%>
4040
<div class="inline">
41-
<%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium" %>
41+
<%%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
4242
</div>
4343
<%% end %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require "test_helper"
2+
require "rails/generators/mailer/mailer_generator"
3+
require "generators/tailwindcss/mailer/mailer_generator"
4+
5+
class Tailwindcss::Generators::MailerGeneratorTest < Rails::Generators::TestCase
6+
GENERATION_PATH = File.expand_path("../mailer_tmp", File.dirname(__FILE__))
7+
8+
tests Rails::Generators::MailerGenerator
9+
destination GENERATION_PATH
10+
11+
arguments %w(Notifications invoice)
12+
13+
Minitest.after_run do
14+
FileUtils.rm_rf GENERATION_PATH
15+
end
16+
17+
test "generates correct mailer view templates" do
18+
run_generator
19+
20+
assert_file "app/views/notifications_mailer/invoice.html.erb" do |view|
21+
assert_match %r(app/views/notifications_mailer/invoice\.html\.erb), view
22+
assert_match(/\= @greeting/, view)
23+
end
24+
25+
assert_file "app/views/notifications_mailer/invoice.text.erb" do |view|
26+
assert_match %r(app/views/notifications_mailer/invoice\.text\.erb), view
27+
assert_match(/\= @greeting/, view)
28+
end
29+
end
30+
end
31+

0 commit comments

Comments
 (0)