Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for multipart emails without a set content_type. #633

Merged
merged 1 commit into from
Nov 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mail/parts_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def sort!(order)
private

def get_order_value(part, order)
if part.respond_to?(:content_type)
if part.respond_to?(:content_type) && !part[:content_type].nil?
order.index(part[:content_type].string.downcase) || 10000
else
10000
Expand Down
19 changes: 18 additions & 1 deletion spec/mail/parts_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@
p << 'text/html'
p.sort!(order)
end
end

it "should not fail if we do not have a content_type" do
p = Mail::PartsList.new
order = ['text/plain', 'text/html']

no_content_type_part = Mail::Part.new
plain_text_part = Mail::Part.new
html_text_part = Mail::Part.new

no_content_type_part.content_type = nil
html_text_part.content_type = 'text/html'

p << no_content_type_part
p << plain_text_part
p << html_text_part
p.sort!(order).should eq [plain_text_part, html_text_part, no_content_type_part]
end
end