updated tests, switched to rails 3.0.0rc2

This commit is contained in:
albert
2010-08-26 14:36:02 -04:00
parent 694b6f0813
commit ad39553aac
48 changed files with 898 additions and 406 deletions

View File

@@ -1,16 +1,27 @@
require File.dirname(__FILE__) + '/../test_helper'
require_relative '../test_helper'
class IpBanTest < ActiveSupport::TestCase
def test_count_by_ip_addr
comment = Factory.create(:comment)
counts = IpBan.count_by_ip_addr("comments", [comment.creator_id])
assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts)
setup do
user = Factory.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
end
def test_search
post = create_post()
comment = create_comment(post, :ip_addr => "1.2.3.4", :body => "aaa")
counts = IpBan.search([comment.user_id])
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "be able to count the number of comments an IP address is associated with" do
comment = Factory.create(:comment)
counts = IpBan.count_by_ip_addr("comments", [comment.creator_id], "creator_id", "ip_addr")
assert_equal([{"ip_addr" => "127.0.0.1", "count" => "1"}], counts)
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"])
end
end