mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-04-30 05:35:29 +08:00
Change post vote value to boolean
This commit is contained in:
@@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
class PostVoteTest < ActiveSupport::TestCase
|
||||
test "should create post vote" do
|
||||
vote = create(:post_vote, value: 'up')
|
||||
vote = create(:post_vote, up: true)
|
||||
assert_not_nil vote
|
||||
assert_equal 'up', vote.value
|
||||
assert vote.up?
|
||||
@@ -12,12 +12,12 @@ class PostVoteTest < ActiveSupport::TestCase
|
||||
post = create(:post)
|
||||
assert_equal 0, post.votes
|
||||
|
||||
create(:post_vote, post: post, value: 'up')
|
||||
create(:post_vote, post: post, up: true)
|
||||
post.reload
|
||||
assert_equal 1, post.votes_up
|
||||
assert_equal 0, post.votes_down
|
||||
|
||||
create(:post_vote, post: post, value: 'down')
|
||||
create(:post_vote, post: post, up: false)
|
||||
post.reload
|
||||
assert_equal 1, post.votes_up
|
||||
assert_equal 1, post.votes_down
|
||||
@@ -26,17 +26,17 @@ class PostVoteTest < ActiveSupport::TestCase
|
||||
test "should inc post votes after vote update" do
|
||||
post = create(:post)
|
||||
|
||||
vote = create(:post_vote, post: post, value: 'up')
|
||||
vote = create(:post_vote, post: post, up: true)
|
||||
post.reload
|
||||
assert_equal 1, post.votes_up
|
||||
assert_equal 0, post.votes_down
|
||||
|
||||
vote.update_attribute :value, 'down'
|
||||
vote.update_attribute :up, false
|
||||
post.reload
|
||||
assert_equal 0, post.votes_up
|
||||
assert_equal 1, post.votes_down
|
||||
|
||||
vote.update_attribute :value, 'up'
|
||||
vote.update_attribute :up, true
|
||||
post.reload
|
||||
assert_equal 1, post.votes_up
|
||||
assert_equal 0, post.votes_down
|
||||
|
||||
Reference in New Issue
Block a user