blob: e84a2a9ba053b46f7d20350d2823a02d9d5fc980 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
$:.unshift "../lib"
require 'th_mauve'
require 'mauve/history'
require 'mauve/server'
class TcMauveHistory < Mauve::UnitTest
include Mauve
def setup
super
setup_database
end
def teardown
teardown_database
super
end
def test_save
Server.instance.setup
#
# Make sure events save without nasty html
#
h = History.new(:alerts => [], :type => "note", :event => "Hello <script>alert(\"arse\");</script>")
assert(h.save)
h.reload
assert_equal("Hello ",h.event, "HTML not stripped correctly on save.")
h = History.new(:alerts => [], :type => nil, :event => "Hello")
assert_raise(DataMapper::SaveFailureError, "History saved with blank type -- validation not working"){h.save}
#
# pop off the error message
#
logger_pop
assert_equal([:type], h.errors.keys, "Just the type field should be invalid")
end
end
|