update factories + tests

This commit is contained in:
Albert Yi
2019-05-10 17:31:07 -07:00
parent 32b4e0a01e
commit 04edc3f533
26 changed files with 81 additions and 83 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)