Skip to content

Commit f7c79f0

Browse files
committed
Add model tests for ThreadFollower and NewThreadFollower
1 parent 5da697b commit f7c79f0

2 files changed

Lines changed: 36 additions & 6 deletions

File tree

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
require 'test_helper'
22

33
class NewThreadFollowerTest < ActiveSupport::TestCase
4-
# test 'the truth' do
5-
# assert true
6-
# end
4+
test "save succeeds with user and post" do
5+
new_thread_follower=NewThreadFollower.new
6+
new_thread_follower.user=users(:basic_user)
7+
new_thread_follower.post=posts(:question_one)
8+
assert new_thread_follower.save
9+
end
10+
11+
test "save fails without user" do
12+
new_thread_follower=NewThreadFollower.new
13+
new_thread_follower.post=posts(:question_one)
14+
assert_not new_thread_follower.save
15+
end
16+
17+
test "save fails without post" do
18+
new_thread_follower=NewThreadFollower.new
19+
new_thread_follower.user=users(:basic_user)
20+
assert_not new_thread_follower.save
21+
end
722
end
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
require 'test_helper'
22

33
class ThreadFollowerTest < ActiveSupport::TestCase
4-
# test "the truth" do
5-
# assert true
6-
# end
4+
test "save succeeds with user and thread" do
5+
new_thread_follower=ThreadFollower.new
6+
new_thread_follower.user=users(:basic_user)
7+
new_thread_follower.comment_thread=comment_threads(:normal)
8+
assert new_thread_follower.save
9+
end
10+
11+
test "save fails without user" do
12+
new_thread_follower=ThreadFollower.new
13+
new_thread_follower.comment_thread=comment_threads(:normal)
14+
assert_not new_thread_follower.save
15+
end
16+
17+
test "save fails without thread" do
18+
new_thread_follower=ThreadFollower.new
19+
new_thread_follower.user=users(:basic_user)
20+
assert_not new_thread_follower.save
21+
end
722
end

0 commit comments

Comments
 (0)