Add upvote:/downvote: editing metatags.
This commit is contained in:
@@ -7,6 +7,7 @@ FactoryGirl.define do
|
||||
default_image_size "large"
|
||||
base_upload_limit 10
|
||||
level 20
|
||||
created_at {Time.now}
|
||||
last_logged_in_at {Time.now}
|
||||
favorite_count 0
|
||||
bit_prefs 0
|
||||
|
||||
@@ -800,6 +800,50 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "of" do
|
||||
setup do
|
||||
@gold = FactoryGirl.build(:gold_user)
|
||||
end
|
||||
|
||||
context "upvote:self or downvote:self" do
|
||||
context "by a member" do
|
||||
should "not upvote the post" do
|
||||
assert_raises PostVote::Error do
|
||||
@post.update(:tag_string => "upvote:self")
|
||||
end
|
||||
|
||||
assert_equal(0, @post.score)
|
||||
end
|
||||
|
||||
should "not downvote the post" do
|
||||
assert_raises PostVote::Error do
|
||||
@post.update(:tag_string => "downvote:self")
|
||||
end
|
||||
|
||||
assert_equal(0, @post.score)
|
||||
end
|
||||
end
|
||||
|
||||
context "by a gold user" do
|
||||
should "upvote the post" do
|
||||
CurrentUser.scoped(FactoryGirl.create(:gold_user)) do
|
||||
@post.update(:tag_string => "tag1 tag2 upvote:self")
|
||||
assert_equal(false, @post.errors.any?)
|
||||
assert_equal(1, @post.score)
|
||||
end
|
||||
end
|
||||
|
||||
should "downvote the post" do
|
||||
CurrentUser.scoped(FactoryGirl.create(:gold_user)) do
|
||||
@post.update(:tag_string => "tag1 tag2 downvote:self")
|
||||
assert_equal(false, @post.errors.any?)
|
||||
assert_equal(-1, @post.score)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "tagged with a negated tag" do
|
||||
@@ -1733,8 +1777,16 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "not allow members to vote" do
|
||||
@user = FactoryGirl.create(:user)
|
||||
@post = FactoryGirl.create(:post)
|
||||
CurrentUser.scoped(@user) do
|
||||
assert_raises(PostVote::Error) { @post.vote!("up") }
|
||||
end
|
||||
end
|
||||
|
||||
should "not allow duplicate votes" do
|
||||
user = FactoryGirl.create(:user)
|
||||
user = FactoryGirl.create(:gold_user)
|
||||
post = FactoryGirl.create(:post)
|
||||
CurrentUser.scoped(user, "127.0.0.1") do
|
||||
assert_nothing_raised {post.vote!("up")}
|
||||
@@ -1746,7 +1798,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "allow undoing of votes" do
|
||||
user = FactoryGirl.create(:user)
|
||||
user = FactoryGirl.create(:gold_user)
|
||||
post = FactoryGirl.create(:post)
|
||||
|
||||
# We deliberately don't call post.reload until the end to verify that
|
||||
|
||||
Reference in New Issue
Block a user