From bb494203d263104e9f2ac13d18c438798f7a99f8 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sat, 19 Oct 2013 23:57:34 -0400 Subject: [PATCH] Cover the simple_sanitize helper --- app/helpers/application_helper.rb | 2 +- spec/helpers/application_helper_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e48889eb..ab98c894b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -192,7 +192,7 @@ module ApplicationHelper alt: "Sign in with #{provider.to_s.titleize}") end - def simple_sanitize str + def simple_sanitize(str) sanitize(str, tags: %w(a span)) end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0d066be5b..d63a2de88 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -123,4 +123,21 @@ describe ApplicationHelper do end end + describe "simple_sanitize" do + let(:a_tag) { 'Foo' } + + it "allows the a tag" do + simple_sanitize(a_tag).should == a_tag + end + + it "allows the span tag" do + input = 'Bar' + simple_sanitize(input).should == input + end + + it "disallows other tags" do + input = "#{a_tag}" + simple_sanitize(input).should == a_tag + end + end end -- 2.11.0