-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from damien/4-mark-cleaned-strings-as-html-safe
Mark cleaned strings as html safe, bootstrap test suite
- Loading branch information
Showing
8 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
html | ||
pkg | ||
.*.sw? | ||
.DS_Store | ||
*.sublime-* | ||
Gemfile.lock | ||
html | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: ruby | ||
cache: bundler | ||
rvm: | ||
- 2.0.0 | ||
- 1.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require 'test_helper' | ||
|
||
require 'action_view' | ||
require 'sanitize' | ||
require 'sanitize/rails' | ||
|
||
# Test suite for Sanitize::Rails::Engine | ||
class SanitizeRailsEngineTest < MiniTest::Unit::TestCase | ||
def setup | ||
@engine = Sanitize::Rails::Engine | ||
end | ||
|
||
def test_respond_to_configure | ||
assert_respond_to @engine, :configure | ||
end | ||
|
||
def test_respond_to_cleaner | ||
assert_respond_to @engine, :cleaner | ||
end | ||
|
||
def test_cleaner_returns_instance_of_sanitize | ||
assert_kind_of Sanitize, @engine.cleaner | ||
end | ||
|
||
def test_respond_to_clean_bang | ||
assert_respond_to @engine, :clean! | ||
end | ||
|
||
def test_clean_bang_modifies_string_in_place | ||
string = %Q|<script>alert("hello world")</script>| | ||
@engine.clean! string | ||
assert_equal string, %q|alert("hello world")| | ||
end | ||
|
||
def test_respond_to_clean | ||
assert_respond_to @engine, :clean | ||
end | ||
|
||
def test_clean_does_not_modify_string_in_place | ||
string = %Q|<script>alert("hello world")</script>| | ||
new_string = @engine.clean string | ||
assert_equal string, %Q|<script>alert("hello world")</script>| | ||
assert_equal new_string, 'alert("hello world")' | ||
end | ||
|
||
def test_clean_returns_safe_buffers | ||
string = %Q|<script>alert("hello world")</script>| | ||
assert_instance_of String, string | ||
|
||
new_string = @engine.clean string | ||
assert_instance_of ::ActiveSupport::SafeBuffer, new_string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'test_helper' | ||
|
||
require 'action_view' | ||
require 'sanitize' | ||
require 'sanitize/rails' | ||
|
||
# Test suite for Sanitize::Rails::Engine | ||
class SanitizeRailsStringExtensionTest < MiniTest::Unit::TestCase | ||
SanitizableString = Class.new(String) { include Sanitize::Rails::String } | ||
|
||
def setup | ||
@string = SanitizableString.new %Q|<script>alert("hello world")</script>| | ||
end | ||
|
||
def test_respond_to_sanitize_as_html_bang | ||
assert_respond_to @string, :sanitize_as_html! | ||
end | ||
|
||
def test_sanitize_as_html_bang_does_not_return_safe_buffers | ||
sanitizable_string = @string.dup | ||
assert_instance_of SanitizableString, sanitizable_string | ||
|
||
new_string = sanitizable_string.sanitize_as_html! | ||
assert_instance_of String, new_string | ||
end | ||
|
||
def test_respond_to_sanitize_as_html | ||
assert_respond_to @string, :sanitize_as_html | ||
end | ||
|
||
def test_sanitize_as_html_returns_safe_buffers | ||
sanitizable_string = @string.dup | ||
assert_instance_of SanitizableString, sanitizable_string | ||
|
||
new_string = sanitizable_string.sanitize_as_html | ||
assert_instance_of ::ActiveSupport::SafeBuffer, new_string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'minitest/unit' | ||
require 'minitest/autorun' |