* Missing files

* Work on post exploration code by traversing dates
This commit is contained in:
albert
2010-10-27 20:16:43 -04:00
parent f9cdcef2c0
commit fc0a076aca
32 changed files with 371 additions and 189 deletions

View File

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

View File

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

View File

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