update factories + tests
This commit is contained in:
@@ -89,7 +89,8 @@ class CommentTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "fail creation" do
|
||||
comment = FactoryBot.build(:comment)
|
||||
post = FactoryBot.create(:post)
|
||||
comment = FactoryBot.build(:comment, post: post)
|
||||
comment.save
|
||||
assert_equal(["You can not post comments within 1 week of sign up"], comment.errors.full_messages)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class NoteSanitizerTest < ActiveSupport::TestCase
|
||||
context "Sanitizing a note" do
|
||||
should "strip unsafe tags" do
|
||||
body = '<p>test</p> <script>alert("owned")</script>'
|
||||
assert_equal('<p>test</p> alert("owned")', NoteSanitizer.sanitize(body))
|
||||
assert_equal('<p>test</p> ', NoteSanitizer.sanitize(body))
|
||||
end
|
||||
|
||||
should "strip unsafe css" do
|
||||
|
||||
@@ -68,7 +68,7 @@ class NoteTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "not validate if the body is blank" do
|
||||
@note = FactoryBot.build(:note, body: " ")
|
||||
@note = FactoryBot.build(:note, body: " ", :post => @post)
|
||||
|
||||
assert_equal(false, @note.valid?)
|
||||
assert_equal(["Body can't be blank"], @note.errors.full_messages)
|
||||
|
||||
Reference in New Issue
Block a user