Sha256: 490611eb821cdb72935a5d5ff8c106d445aa016eeb0efecfff0ea706d5eadca3
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) require 'loofah/active_record' class TestActiveRecord < Test::Unit::TestCase HTML_STRING = "<div>omgwtfbbq</div>" PLAIN_TEXT = "vanilla text" context "with a Post model" do setup do ActsAsFu.build_model(:posts) do string :plain_text string :html_string end end context "scrubbing field as a fragment" do setup do Post.html_fragment :html_string, :scrub => :prune @post = Post.new :html_string => HTML_STRING, :plain_text => PLAIN_TEXT end should "scrub the specified field" do Loofah.expects(:scrub_fragment).with(HTML_STRING, :prune).once Loofah.expects(:scrub_fragment).with(PLAIN_TEXT, :prune).never @post.save end end context "scrubbing field as a document" do setup do Post.html_document :html_string, :scrub => :strip @post = Post.new :html_string => HTML_STRING, :plain_text => PLAIN_TEXT end should "scrub the specified field, but not other fields" do Loofah.expects(:scrub_document).with(HTML_STRING, :strip).once Loofah.expects(:scrub_document).with(PLAIN_TEXT, :strip).never @post.save end end context "not passing any options" do should "raise ArgumentError" do assert_raises(ArgumentError) { Post.html_fragment :foo } end end context "not passing :scrub option" do should "raise ArgumentError" do assert_raise(ArgumentError) { Post.html_fragment :foo, :bar => :quux } end end context "passing a :scrub option" do should "not raise ArgumentError" do assert_nothing_raised { Post.html_fragment :foo, :scrub => :quux } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loofah-0.2.0 | test/test_active_record.rb |