Commit bb494203d263104e9f2ac13d18c438798f7a99f8

Authored by Robert Speicher
1 parent 898e2acd

Cover the simple_sanitize helper

app/helpers/application_helper.rb
... ... @@ -192,7 +192,7 @@ module ApplicationHelper
192 192 alt: "Sign in with #{provider.to_s.titleize}")
193 193 end
194 194  
195   - def simple_sanitize str
  195 + def simple_sanitize(str)
196 196 sanitize(str, tags: %w(a span))
197 197 end
198 198  
... ...
spec/helpers/application_helper_spec.rb
... ... @@ -123,4 +123,21 @@ describe ApplicationHelper do
123 123 end
124 124 end
125 125  
  126 + describe "simple_sanitize" do
  127 + let(:a_tag) { '<a href="#">Foo</a>' }
  128 +
  129 + it "allows the a tag" do
  130 + simple_sanitize(a_tag).should == a_tag
  131 + end
  132 +
  133 + it "allows the span tag" do
  134 + input = '<span class="foo">Bar</span>'
  135 + simple_sanitize(input).should == input
  136 + end
  137 +
  138 + it "disallows other tags" do
  139 + input = "<strike><b>#{a_tag}</b></strike>"
  140 + simple_sanitize(input).should == a_tag
  141 + end
  142 + end
126 143 end
... ...