require 'test_helper' class NoteSanitizerTest < ActiveSupport::TestCase context "Sanitizing a note" do should "strip unsafe tags" do body = '

test

' assert_equal('

test

', NoteSanitizer.sanitize(body)) end should "strip unsafe css" do body = '

test

' assert_equal("

test

", NoteSanitizer.sanitize(body)) end should "allow style attributes on every tag" do body = '

test

' assert_equal('

test

', NoteSanitizer.sanitize(body)) end should "mark links as nofollow" do body = 'google' assert_equal('google', NoteSanitizer.sanitize(body)) end should "rewrite absolute links to relative links" do Danbooru.config.stubs(:hostname).returns("sonohara.donmai.us") body = 'touhou' assert_equal('touhou', NoteSanitizer.sanitize(body)) end should "not fail when rewriting bad links" do body = %{google} assert_equal(%{google}, NoteSanitizer.sanitize(body)) end end end