Skip to content

Commit

Permalink
Don't mutate that one variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gabebw committed Jun 5, 2015
1 parent 86acccb commit 0f4a583
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions lib/griddler/email.rb
Expand Up @@ -74,12 +74,10 @@ def clean_html(html)

def clean_invalid_utf8_bytes(text)
if text && !text.valid_encoding?
text = text
.force_encoding('ISO-8859-1')
.encode('UTF-8')
text.force_encoding('ISO-8859-1').encode('UTF-8')
else
text
end

text
end
end
end
9 changes: 4 additions & 5 deletions spec/griddler/email_spec.rb
Expand Up @@ -3,7 +3,6 @@
require 'spec_helper'

describe Griddler::Email, 'body formatting' do

it 'uses the html field and sanitizes it when text param missing' do
body = <<-EOF
<p>Hello.</p><span>Reply ABOVE THIS LINE</span><p>original message</p>
Expand Down Expand Up @@ -624,6 +623,10 @@ def header_from_email(header)
end

describe Griddler::Email, 'with custom configuration' do
before do
Griddler.configure
end

let(:params) do
{
to: ['Some Identifier <some-identifier@example.com>'],
Expand All @@ -639,10 +642,6 @@ def header_from_email(header)
}
end

before do
Griddler.configure
end

describe 'accepts and works with a string reply delimiter' do
it 'does not split on Reply ABOVE THIS LINE' do
allow(Griddler.configuration).to receive_messages(reply_delimiter: 'Stuff and things')
Expand Down

0 comments on commit 0f4a583

Please sign in to comment.