{"id":2813,"date":"2015-09-25T17:02:06","date_gmt":"2015-09-25T15:02:06","guid":{"rendered":"https:\/\/sgaul.de\/?p=2813"},"modified":"2015-09-23T13:13:03","modified_gmt":"2015-09-23T11:13:03","slug":"action-mailer-previews-im-spec-verzeichnis","status":"publish","type":"post","link":"https:\/\/sgaul.de\/2015\/09\/25\/action-mailer-previews-im-spec-verzeichnis\/","title":{"rendered":"Action-Mailer-Previews im Spec-Verzeichnis"},"content":{"rendered":"
Die Mailer-Previews in Rails 4 sind ein Segen.\u00a0Wer Rspec statt der \u00fcblichen\u00a0Testsuite verwendet kann\u00a0das Verzeichnis von test in spec \u00e4ndern, so dass alle Testdateien zusammen bleiben:<\/p>\n
# config\/application.rb\r\n\r\n# ...\r\nconfig.action_mailer.preview_path = \"#{Rails.root}\/spec\/mailers\/previews\"<\/pre>\nNach einem Serverneustart sollten die Previews gefunden werden:<\/p>\n
# spec\/mailers\/previews\/user_mailer_preview.rb\r\n\r\nclass UserMailerPreview < ActionMailer::Preview\r\n def send_invitation\r\n UserMailer.send_invitation(Invitation.first!)\r\n end\r\nend<\/pre>\nDie Vorschau kann man dann unter den \u00fcblichen URLs betrachten, z.B.:<\/p>\n
http:\/\/localhost:3000\/rails\/mailers\/user_mailer\/send_invitation<\/pre>\n","protected":false},"excerpt":{"rendered":"Die Mailer-Previews in Rails 4 sind ein Segen.\u00a0Wer Rspec statt der \u00fcblichen\u00a0Testsuite verwendet kann\u00a0das Verzeichnis von test in spec \u00e4ndern, so dass alle Testdateien zusammen bleiben: # config\/application.rb # … config.action_mailer.preview_path = „#{Rails.root}\/spec\/mailers\/previews“ Nach einem Serverneustart sollten die Previews gefunden werden: # spec\/mailers\/previews\/user_mailer_preview.rb class UserMailerPreview < ActionMailer::Preview def send_invitation UserMailer.send_invitation(Invitation.first!) end end Die Vorschau kann… Action-Mailer-Previews im Spec-Verzeichnis<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[91],"tags":[613,527,553,552],"_links":{"self":[{"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/posts\/2813"}],"collection":[{"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/comments?post=2813"}],"version-history":[{"count":1,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/posts\/2813\/revisions"}],"predecessor-version":[{"id":2814,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/posts\/2813\/revisions\/2814"}],"wp:attachment":[{"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/media?parent=2813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/categories?post=2813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sgaul.de\/wp-json\/wp\/v2\/tags?post=2813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}