added ip addr search
This commit is contained in:
35
test/functional/moderator/ip_addrs_controller_test.rb
Normal file
35
test/functional/moderator/ip_addrs_controller_test.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require 'test_helper'
|
||||
|
||||
module Moderator
|
||||
class IpAddrsControllerTest < ActionController::TestCase
|
||||
context "The ip addrs controller" do
|
||||
setup do
|
||||
@user = Factory.create(:moderator_user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
Factory.create(:comment)
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
should "find by ip addr" do
|
||||
get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "find by user id" do
|
||||
get :index, {:search => {:user_id => @user.id.to_s}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "find by user name" do
|
||||
get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "render the search page" do
|
||||
get :search, {}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -23,6 +23,17 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "posts action" do
|
||||
setup do
|
||||
@tag_subscription = Factory.create(:tag_subscription, :name => "aaa")
|
||||
end
|
||||
|
||||
should "list all visible tag subscriptions" do
|
||||
get :posts, {:id => @tag_subscription.creator_id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require_relative '../test_helper'
|
||||
require 'test_helper'
|
||||
|
||||
class IpBanTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
|
||||
35
test/unit/moderator/ip_addr_search_test.rb
Normal file
35
test/unit/moderator/ip_addr_search_test.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "test_helper"
|
||||
|
||||
module Moderator
|
||||
class IpAddrSearchTest < ActiveSupport::TestCase
|
||||
context "an ip addr search" do
|
||||
setup do
|
||||
@user = Factory.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
Factory.create(:comment)
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "find by ip addr" do
|
||||
@search = IpAddrSearch.new(:ip_addr => "127.0.0.1")
|
||||
assert_equal({@user.id.to_s => 2}, @search.execute)
|
||||
end
|
||||
|
||||
should "find by user id" do
|
||||
@search = IpAddrSearch.new(:user_id => @user.id.to_s)
|
||||
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||
end
|
||||
|
||||
should "find by user name" do
|
||||
@search = IpAddrSearch.new(:user_name => @user.name)
|
||||
assert_equal({"127.0.0.1" => 2}, @search.execute)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user