Skip to content

Commit

Permalink
Merge pull request ryanb#13 from algorich/named_sender
Browse files Browse the repository at this point in the history
Add suport for named sender
  • Loading branch information
ryanb committed Sep 16, 2011
2 parents c33afdd + 288bf66 commit 29b17fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/letter_opener/message.html.erb
Expand Up @@ -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>
Expand Down Expand Up @@ -86,3 +86,4 @@
<% else %>
<%= body %>
<% end %>

5 changes: 5 additions & 0 deletions lib/letter_opener/message.rb
Expand Up @@ -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
Expand All @@ -40,3 +44,4 @@ def encoding
end
end
end

5 changes: 3 additions & 2 deletions spec/letter_opener/delivery_method_spec.rb
Expand Up @@ -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!")
Expand All @@ -47,3 +47,4 @@
html.should include("<h1>This is HTML</h1>")
end
end

0 comments on commit 29b17fe

Please sign in to comment.