mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Fix error when generating checkout email when distributor_info is nil
This commit is contained in:
@@ -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
|
||||
|
||||
27
spec/helpers/html_helper_spec.rb
Normal file
27
spec/helpers/html_helper_spec.rb
Normal 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 world&&').should == 'Hello world&&'
|
||||
end
|
||||
|
||||
it "returns nil for nil input" do
|
||||
subject.strip_html(nil).should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user