Fix error when generating checkout email when distributor_info is nil

This commit is contained in:
Rohan Mitchell
2013-08-20 09:19:23 +10:00
parent 8f67f385b7
commit 7b5eca3a50
2 changed files with 28 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
module HtmlHelper
def strip_html(html)
strip_tags(html).gsub(/ /i, ' ').gsub(/&/i, '&')
strip_tags(html).andand.gsub(/ /i, ' ').andand.gsub(/&/i, '&')
end
end

View File

@@ -0,0 +1,27 @@
require 'spec_helper'
describe HtmlHelper do
class HelperStub
extend ActionView::Helpers::SanitizeHelper::ClassMethods
include ActionView::Helpers::SanitizeHelper
end
subject do
obj = HelperStub.new
obj.extend HtmlHelper
end
describe "stripping html from a string" do
it "strips tags" do
subject.strip_html('<p><b>Hello</b> <em>world</em>!</p>').should == 'Hello world!'
end
it "removes nbsp and amp entities" do
subject.strip_html('Hello&nbsp;world&amp;&amp;').should == 'Hello world&&'
end
it "returns nil for nil input" do
subject.strip_html(nil).should be_nil
end
end
end