* Missing files
* Work on post exploration code by traversing dates
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
Factory.define(:comment) do |f|
|
||||
f.creator {|x| x.association(:user)}
|
||||
f.post {|x| x.association(:post)}
|
||||
f.body {Faker::Lorem.sentences}
|
||||
f.ip_addr "127.0.0.1"
|
||||
f.score 0
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ require_relative '../test_helper'
|
||||
|
||||
class IpBanTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
user = Factory.create(:user)
|
||||
CurrentUser.user = user
|
||||
@user = Factory.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
@@ -20,8 +20,10 @@ class IpBanTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "be able to count any updates from a user, groupiny by IP address" do
|
||||
comment = Factory.create(:comment, :ip_addr => "1.2.3.4", :body => "aaa")
|
||||
counts = IpBan.search([comment.creator_id])
|
||||
assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts["comments"])
|
||||
CurrentUser.scoped(@user, "1.2.3.4") do
|
||||
comment = Factory.create(:comment, :body => "aaa")
|
||||
counts = IpBan.search([comment.creator_id])
|
||||
assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts["comments"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -589,11 +589,13 @@ class PostTest < ActiveSupport::TestCase
|
||||
should "not allow duplicate votes" do
|
||||
user = Factory.create(:user)
|
||||
post = Factory.create(:post)
|
||||
assert_nothing_raised {post.vote!(user, true)}
|
||||
assert_raise(PostVote::Error) {post.vote!(user, true)}
|
||||
post.reload
|
||||
assert_equal(1, PostVote.count)
|
||||
assert_equal(1, post.score)
|
||||
CurrentUser.scoped(user, "127.0.0.1") do
|
||||
assert_nothing_raised {post.vote!("up")}
|
||||
assert_raise(PostVote::Error) {post.vote!("up")}
|
||||
post.reload
|
||||
assert_equal(1, PostVote.count)
|
||||
assert_equal(1, post.score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user