Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add comments with urls for email previews

  • Loading branch information...
commit cbd4bc84afa354e9b4c50d53a0d6deb7141eb15d 1 parent 6f4a556
@pixeltrix pixeltrix authored
View
2  railties/lib/rails/generators/test_unit/mailer/templates/preview.rb
@@ -1,7 +1,9 @@
<% module_namespacing do -%>
+# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>
class <%= class_name %>Preview < ActionMailer::Preview
<% actions.each do |action| -%>
+ # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
def <%= action %>
<%= class_name %>.<%= action %>
end
View
17 railties/test/generators/mailer_generator_test.rb
@@ -36,12 +36,15 @@ def test_invokes_default_test_framework
assert_match(/test "foo"/, test)
assert_match(/test "bar"/, test)
end
- assert_file "test/mailers/previews/notifier_preview.rb" do |mailer|
- assert_match(/class NotifierPreview < ActionMailer::Preview/, mailer)
- assert_instance_method :foo, mailer do |foo|
+ assert_file "test/mailers/previews/notifier_preview.rb" do |preview|
+ assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/notifier/, preview)
+ assert_match(/class NotifierPreview < ActionMailer::Preview/, preview)
+ assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier\/foo/, preview)
+ assert_instance_method :foo, preview do |foo|
assert_match(/Notifier.foo/, foo)
end
- assert_instance_method :bar, mailer do |bar|
+ assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/notifier\/bar/, preview)
+ assert_instance_method :bar, preview do |bar|
assert_match(/Notifier.bar/, bar)
end
end
@@ -105,8 +108,10 @@ def test_mailer_with_namedspaced_mailer
assert_match(/class Farm::Animal < ActionMailer::Base/, mailer)
assert_match(/en\.farm\.animal\.moos\.subject/, mailer)
end
- assert_file "test/mailers/previews/farm/animal_preview.rb" do |mailer|
- assert_match(/class Farm::AnimalPreview < ActionMailer::Preview/, mailer)
+ assert_file "test/mailers/previews/farm/animal_preview.rb" do |preview|
+ assert_match(/\# Preview all emails at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal/, preview)
+ assert_match(/class Farm::AnimalPreview < ActionMailer::Preview/, preview)
+ assert_match(/\# Preview this email at http:\/\/localhost\:3000\/rails\/mailers\/farm\/animal\/moos/, preview)
end
assert_file "app/views/farm/animal/moos.text.erb"
assert_file "app/views/farm/animal/moos.html.erb"
Please sign in to comment.
Something went wrong with that request. Please try again.