html_terminator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/html_terminator/version.rb +1 -1
- data/lib/html_terminator.rb +5 -1
- data/spec/html_terminator_spec.rb +18 -12
- data/spec/support/active_record.rb +4 -4
- metadata +2 -2
data/lib/html_terminator.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe HtmlTerminator do
|
4
|
-
it "
|
5
|
-
@user =
|
4
|
+
it "sanitizes only fields specified" do
|
5
|
+
@user = OnlyFirstName.new
|
6
6
|
|
7
7
|
@user.first_name = "Hello <img>"
|
8
8
|
@user.first_name.should == "Hello"
|
@@ -14,19 +14,25 @@ describe HtmlTerminator do
|
|
14
14
|
@user.age.should == 3
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
@
|
17
|
+
it "sanitizes all except what is specified" do
|
18
|
+
@user = ExceptFirstName.new
|
19
19
|
|
20
|
-
@
|
21
|
-
@
|
20
|
+
@user.first_name = "Hello <img>"
|
21
|
+
@user.first_name.should == "Hello <img>"
|
22
|
+
|
23
|
+
@user.last_name = "Hello <img>"
|
24
|
+
@user.last_name.should == "Hello"
|
25
|
+
end
|
22
26
|
|
23
|
-
|
24
|
-
@
|
27
|
+
it "doesn't blow up if value is nil" do
|
28
|
+
@user = ExceptFirstName.new
|
29
|
+
@user.first_name = nil
|
30
|
+
@user.first_name.should == nil
|
25
31
|
end
|
26
32
|
|
27
|
-
it "
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
33
|
+
it "doesn't blow up if value is not a string" do
|
34
|
+
@user = OnlyFirstName.new
|
35
|
+
@user.first_name = 1
|
36
|
+
@user.first_name.should == 1
|
31
37
|
end
|
32
38
|
end
|
@@ -7,26 +7,26 @@ ActiveRecord::Base.establish_connection({
|
|
7
7
|
})
|
8
8
|
|
9
9
|
ActiveRecord::Schema.define do
|
10
|
-
create_table "
|
10
|
+
create_table "only_first_names", :force => true do |t|
|
11
11
|
t.column "first_name", :text
|
12
12
|
t.column "last_name", :text
|
13
13
|
t.column "age", :integer
|
14
14
|
end
|
15
15
|
|
16
|
-
create_table "
|
16
|
+
create_table "except_first_names", :force => true do |t|
|
17
17
|
t.column "first_name", :text
|
18
18
|
t.column "last_name", :text
|
19
19
|
t.column "age", :integer
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
class
|
23
|
+
class OnlyFirstName < ActiveRecord::Base
|
24
24
|
include HtmlTerminator
|
25
25
|
|
26
26
|
terminate_html :first_name
|
27
27
|
end
|
28
28
|
|
29
|
-
class
|
29
|
+
class ExceptFirstName < ActiveRecord::Base
|
30
30
|
include HtmlTerminator
|
31
31
|
|
32
32
|
terminate_html :except => [:first_name]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_terminator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|