Permalink
Browse files

Add suport for named sender

  • Loading branch information...
1 parent c33afdd commit 288bf66e1889951c0507a8a35c6c23a2d49249b5 @hugomaiavieira hugomaiavieira committed Sep 16, 2011
Showing with 10 additions and 3 deletions.
  1. +2 −1 lib/letter_opener/message.html.erb
  2. +5 −0 lib/letter_opener/message.rb
  3. +3 −2 spec/letter_opener/delivery_method_spec.rb
View
3 lib/letter_opener/message.html.erb
@@ -58,7 +58,7 @@
<div id="message_headers">
<dl>
<dt>From:</dt>
- <dd><%= mail.from.join(", ") %></dd>
+ <dd><%= from %></dd>
<dt>Subject:</dt>
<dd><strong><%= mail.subject %></strong></dd>
@@ -86,3 +86,4 @@
<% else %>
<%= body %>
<% end %>
+
View
5 lib/letter_opener/message.rb
@@ -31,6 +31,10 @@ def body
@body ||= (@part && @part.body || @mail.body).to_s
end
+ def from
+ @from ||= @mail.from.kind_of?(Array) && @mail.from.join(", ") || @mail.from
+ end
+
def type
content_type =~ /html/ ? "rich" : "plain"
end
@@ -40,3 +44,4 @@ def encoding
end
end
end
+
View
5 spec/letter_opener/delivery_method_spec.rb
@@ -14,13 +14,13 @@
it "saves text into html document" do
Launchy.should_receive(:open)
mail = Mail.deliver do
- from 'foo@example.com'
+ from 'Foo foo@example.com'
to 'bar@example.com'
subject 'Hello'
body 'World!'
end
text = File.read(Dir["#{@location}/*/plain.html"].first)
- text.should include("foo@example.com")
+ text.should include("Foo foo@example.com")
text.should include("bar@example.com")
text.should include("Hello")
text.should include("World!")
@@ -47,3 +47,4 @@
html.should include("<h1>This is HTML</h1>")
end
end
+

0 comments on commit 288bf66

Please sign in to comment.