added ip addr search

This commit is contained in:
albert 2011-07-29 18:04:50 -04:00
parent 5da43c54f0
commit c8afd34d15
55 changed files with 406 additions and 189 deletions

View File

@ -342,6 +342,12 @@ div.clearfix {
}
/*** Post previews ***/
div.post-previews {
overflow: hidden;
}
/*** Paginator ***/
div.paginator {
display: block;

View File

@ -1,4 +1,6 @@
class FavoritesController < ApplicationController
before_filter :member_only
def index
if params[:tags]
redirect_to(posts_path(:tags => "fav:#{CurrentUser.name} #{params[:tags]}"))

View File

@ -1,6 +1,7 @@
module Moderator
class IpAddrsController < ApplicationController
def index
@search = IpAddrSearch.new(params[:search])
end
def search

View File

@ -40,6 +40,12 @@ class TagSubscriptionsController < ApplicationController
respond_with(@tag_subscription)
end
def posts
@user = User.find(params[:id])
@post_set = PostSets::Post.new("sub:#{@user.name} #{params[:tags]}", params[:page])
@posts = @post_set.posts
end
private
def check_privilege(tag_subscription)
raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user)

View File

@ -73,7 +73,13 @@ protected
when "artist_versions"
/^\/artist/
when "moderator/post/dashboards"
/^\/post/
when "moderator/dashboards"
/^\/moderator/
else
/^\/#{controller}/
end

View File

@ -1,6 +1,6 @@
module PaginationHelper
def sequential_paginator(records)
html = "<menu>"
html = '<div class="paginator"><menu>'
if records.any?
if params[:page] =~ /[ab]/
@ -10,7 +10,7 @@ module PaginationHelper
html << '<li>' + link_to("Next >", params.merge(:page => "b#{records[-1].id}")) + '</li>'
end
html << "</menu>"
html << "</menu></div>"
html.html_safe
end
@ -23,7 +23,7 @@ module PaginationHelper
return sequential_paginator(records)
end
html = "<menu>"
html = '<div class="paginator"><menu>'
window = 3
if records.total_pages <= (window * 2) + 5
1.upto(records.total_pages) do |page|
@ -50,7 +50,7 @@ module PaginationHelper
html << numbered_paginator_item("...", records.current_page)
html << numbered_paginator_final_item(records.total_pages, records.current_page)
end
html << "</menu>"
html << "</menu></div>"
html.html_safe
end

View File

@ -0,0 +1,59 @@
module Moderator
class IpAddrSearch
attr_reader :params
def initialize(params)
@params = params
end
def execute
if params[:user_id]
search_by_user_id(params[:user_id].split(/,/))
elsif params[:user_name]
search_by_user_name(params[:user_name].split(/,/))
elsif params[:ip_addr]
search_by_ip_addr(params[:ip_addr].split(/,/))
end
end
private
def select_all_sql(sql, *params)
ActiveRecord::Base.select_all_sql(sql, *params)
end
def search_by_ip_addr(ip_addrs)
sums = Hash.new {|h, k| h[k] = 0}
add_row(sums, "select creator_id as k, count(*) from comments where ip_addr in (?) group by k", ip_addrs)
add_row(sums, "select updater_id as k, count(*) from post_versions where updater_ip_addr in (?) group by k", ip_addrs)
add_row(sums, "select updater_id as k, count(*) from note_versions where updater_ip_addr in (?) group by k", ip_addrs)
add_row(sums, "select updater_id as k, count(*) from pool_versions where updater_ip_addr in (?) group by k", ip_addrs)
add_row(sums, "select updater_id as k, count(*) from wiki_page_versions where updater_ip_addr in (?) group by k", ip_addrs)
sums
end
def search_by_user_name(user_names)
users = User.where("name in (?)", user_names)
search_by_user_id(users.map(&:id))
end
def search_by_user_id(user_ids)
sums = Hash.new {|h, k| h[k] = 0}
add_row(sums, "select ip_addr as k, count(*) from comments where creator_id in (?) group by k", user_ids)
add_row(sums, "select updater_ip_addr as k, count(*) from post_versions where updater_id in (?) group by k", user_ids)
add_row(sums, "select updater_ip_addr as k, count(*) from note_versions where updater_id in (?) group by k", user_ids)
add_row(sums, "select updater_ip_addr as k, count(*) from pool_versions where updater_id in (?) group by k", user_ids)
add_row(sums, "select updater_ip_addr as k, count(*) from wiki_page_versions where updater_id in (?) group by k", user_ids)
sums
end
def add_row(sums, sql, ip_addrs)
select_all_sql(sql, ip_addrs).each do |row|
sums[row["k"]] += row["count"].to_i
end
end
end
end

View File

@ -15,7 +15,7 @@ class PostSetPresenter < Presenter
end
def post_previews_html(template)
html = ""
html = "<div class='post-previews'>"
if posts.empty?
return template.render(:partial => "post_sets/blank")
@ -25,6 +25,8 @@ class PostSetPresenter < Presenter
html << PostPresenter.preview(post)
end
html << '</div>'
html.html_safe
end
end

View File

@ -31,9 +31,7 @@
</table>
</div>
<div class="paginator">
<%= sequential_paginator(@artist_versions) %>
</div>
<%= sequential_paginator(@artist_versions) %>
</div>
</div>

View File

@ -1,6 +1,6 @@
<div id="c-artists">
<div id="a-edit">
<h3>Edit Artist</h3>
<h1>Edit Artist</h1>
<%= render "form" %>
</div>
</div>

View File

@ -34,9 +34,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@artists) %>
</div>
<%= numbered_paginator(@artists) %>
<%= render "secondary_links" %>
</div>

View File

@ -8,9 +8,7 @@
</div>
</div>
<div class="paginator">
<%= sequential_paginator(@comments) %>
</div>
<%= sequential_paginator(@comments) %>
</div>
</div>

View File

@ -16,9 +16,7 @@
</div>
<% end %>
<div class="paginator">
<%= sequential_paginator(@posts) %>
</div>
<%= sequential_paginator(@posts) %>
</div>
</div>

View File

@ -1,13 +1,7 @@
<div id="c-favorites">
<div id="a-index">
<aside id="sidebar">
<section id="search-box">
<h1>Search Favorites</h1>
<%= form_tag(favorites_path, :method => "get") do %>
<%= text_field_tag("tags", @favorite_set.tag_string, :size => 20) %>
<%= submit_tag "Go" %>
<% end %>
</section>
<%= render :partial => "posts/partials/common/search", :locals => {:path => favorites_path, :tags => @favorite_set.tag_string} %>
<% if CurrentUser.is_privileged? %>
<section id="mode-box">
@ -25,13 +19,10 @@
<section id="content">
<h1>Posts</h1>
<%= @favorite_set.presenter.post_previews_html(self) %>
<div class="clearfix"></div>
<div class="paginator">
<%= sequential_paginator(@favorite_set.favorites) %>
</div>
<%= sequential_paginator(@favorite_set.favorites) %>
</section>
<% content_for(:page_title) do %>

View File

@ -1,6 +1,6 @@
<div id="c-forum-topics">
<div id="a-edit">
<h3>Edit Forum Post</h3>
<h1>Edit Forum Post</h1>
<%= render "form" %>
</div>

View File

@ -1,28 +1,28 @@
<table width="100%" class="striped">
<thead>
<tr>
<th>Topic</th>
<th>Excerpt</th>
<th>Creator</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<% @forum_posts.each do |forum_post| %>
<tr>
<td><%= link_to forum_post.topic.title, forum_topic_path(forum_post.topic) %></td>
<td><%= link_to truncate(forum_post.body, :length => 50), forum_post_path(forum_post) %></td>
<td><%= forum_post.creator.name %></td>
<td><%= time_ago_in_words forum_post.created_at %> ago</td>
</tr>
<% end %>
</tbody>
</table>
<div id="c-forum-posts">
<div id="a-index">
<table width="100%" class="striped">
<thead>
<tr>
<th>Topic</th>
<th>Excerpt</th>
<th>Creator</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<% @forum_posts.each do |forum_post| %>
<tr>
<td><%= link_to forum_post.topic.title, forum_topic_path(forum_post.topic) %></td>
<td><%= link_to truncate(forum_post.body, :length => 50), forum_post_path(forum_post) %></td>
<td><%= forum_post.creator.name %></td>
<td><%= time_ago_in_words forum_post.created_at %> ago</td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= numbered_paginator(@forum_posts) do |page| %>
<%= link_to(page, forum_posts_path(:search => params[:search], :page => page)) %>
<% end %>
<%= numbered_paginator(@forum_posts) %>
</div>
</div>
<%= render "forum_topics/secondary_links" %>

View File

@ -1,6 +1,6 @@
<div id="c-forum-topics">
<div id="a-new">
<h3>New Forum Post</h3>
<h1>New Forum Post</h1>
<%= render "form" %>
<%= error_messages_for "forum_post" %>
</div>

View File

@ -1,6 +1,6 @@
<div id="c-forum-topics">
<div id="a-search">
<h3>Search Forum Posts</h3>
<h1>Search Forum Posts</h1>
<%= simple_form_for @search do |f| %>
<%= f.input :topic_title_matches, :label => "Title" %>
<%= f.input :body_matches, :label => "Body" %>

View File

@ -1,3 +1 @@
<div class="paginator">
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>
</div>
<%= @forum_topic.presenter(@forum_posts).pagination_html(self) %>

View File

@ -1,6 +1,6 @@
<div id="c-forum-topics">
<div id="a-edit">
<h3>Edit Forum Topic</h3>
<h1>Edit Forum Topic</h1>
<%= render "form" %>
</div>

View File

@ -1,6 +1,6 @@
<div id="c-forum-topics">
<div id="a-new">
<h3>New Forum Topic</h3>
<h1>New Forum Topic</h1>
<%= render "form" %>
</div>

View File

@ -0,0 +1,22 @@
<div id="c-moderator-ip-addrs">
<div id="a-index">
<h1>IP Addresses</h1>
<table>
<thead>
<tr>
<th>Key</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<% @search.execute.each do |k, count| %>
<tr>
<td><%= k %></td>
<td><%= count %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,19 @@
<div id="c-moderator-ip-addrs">
<div id="a-search">
<h1>IP Address Search</h1>
<%= form_tag(moderator_ip_addrs_path) do %>
<div class="input">
<label>User</label>
<%= text_field :search, :user_name %>
</div>
<div class="input">
<label>IP Addr</label>
<%= text_field :search, :ip_addr %>
</div>
<%= submit_tag %>
<% end %>
</div>
</div>

View File

@ -38,3 +38,4 @@
</div>
</div>
<%= render :partial => "posts/partials/common/secondary_links" %>

View File

@ -33,12 +33,9 @@
</tbody>
</table>
<div class="paginator">
<%= sequential_paginator(@note_versions) %>
</div>
<%= sequential_paginator(@note_versions) %>
<%= render :partial => "notes/secondary_links" %>
</div>
</div>

View File

@ -23,9 +23,7 @@
</tbody>
</table>
<div class="paginator">
<%= sequential_paginator(@notes) %>
</div>
<%= sequential_paginator(@notes) %>
</div>
</div>

View File

@ -2,9 +2,7 @@
<div id="a-index">
<%= @post_set.presenter.post_previews_html(self) %>
<div class="paginator">
<%= numbered_paginator(@posts, false) %>
</div>
<%= numbered_paginator(@posts, false) %>
</div>
</div>

View File

@ -1,6 +1,6 @@
<div id="c-pools">
<div id="a-index">
<h3>Pool History</h3>
<h1>Pool History</h1>
<table width="100%">
<thead>
@ -33,9 +33,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@pool_versions) %>
</div>
<%= numbered_paginator(@pool_versions) %>
</div>
</div>

View File

@ -25,9 +25,7 @@
</tbody>
</table>
<div class="paginator">
<%= sequential_paginator(@pools) %>
</div>
<%= numbered_paginator(@pools) %>
<%= render "secondary_links" %>
</div>

View File

@ -9,11 +9,7 @@
<section id="content">
<%= @post_set.presenter.post_previews_html(self) %>
<div class="clearfix"></div>
<div class="paginator">
<%= numbered_paginator(@post_set) %>
</div>
<%= numbered_paginator(@post_set) %>
</section>
</div>
</div>

View File

@ -39,6 +39,4 @@
</table>
</div>
<div class="paginator">
<%= sequential_paginator(post_versions) %>
</div>
<%= sequential_paginator(post_versions) %>

View File

@ -1,26 +1,11 @@
<div id="c-posts">
<div id="a-index">
<aside id="sidebar">
<section id="search-box">
<h1>Search</h1>
<%= form_tag(posts_path, :method => "get") do %>
<%= text_field_tag("tags", params[:tags], :size => 20) %>
<%= submit_tag "Go" %>
<% end %>
</section>
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_path, :tags => params[:tags]} %>
<% if CurrentUser.user.is_privileged? %>
<section id="mode-box">
<%= render :partial => "posts/partials/index/mode_menu" %>
</section>
<% end %>
<%= render :partial => "posts/partials/index/mode_menu" %>
<section id="blacklist-box">
<h1>Blacklist</h1>
<%= link_to "Hidden", "#" %>
<ul>
</ul>
</section>
<%= render :partial => "posts/partials/index/blacklist" %>
<section id="tag-box">
<h1>Tags</h1>

View File

@ -1,4 +1,12 @@
<%= form_tag(posts_path, :method => "get") do %>
<%= text_field_tag("tags", params[:tags]) %>
<%= submit_tag "Go" %>
<% end %>
<!--
- path
- tags
-->
<section id="search-box">
<h1>Search</h1>
<%= form_tag(path, :method => "get") do %>
<%= text_field_tag("tags", tags, :size => 20) %>
<%= submit_tag "Go" %>
<% end %>
</section>

View File

@ -6,11 +6,10 @@
<li><%= link_to "Hot", explore_post_hot_path %></li>
<% unless CurrentUser.is_anonymous? %>
<li><%= link_to "Favorites", favorites_path %></li>
<li><%= link_to "Subscriptions", tag_subscriptions_path(:user_id => CurrentUser.id) %></li>
<li><%= link_to "Subscriptions", posts_tag_subscription_path(CurrentUser.id) %></li>
<% end %>
<li><%= link_to "Changes", post_versions_path %></li>
<li>Approvals</li>
<li><%= link_to "Moderate", moderator_post_dashboard_path %></li>
<li>Help</li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:posts") %></li>
</menu>
<% end %>

View File

@ -0,0 +1,6 @@
<section id="blacklist-box">
<h1>Blacklisted</h1>
<%= link_to "Hidden", "#" %>
<ul>
</ul>
</section>

View File

@ -1,21 +1,25 @@
<h1>Mode</h1>
<form action="/">
<select name="mode">
<option value="view">View</option>
<option value="edit">Edit</option>
<option value="add-fav">Favorite</option>
<option value="remove-fav">Unfavorite</option>
<option value="rating-s">Rate safe</option>
<option value="rating-q">Rate questionable</option>
<option value="rating-e">Rate explicit</option>
<option value="vote-up">Vote up</option>
<option value="vote-down">Vote down</option>
<option value="lock-rating">Lock rating</option>
<option value="lock-note">Lock notes</option>
<option value="edit-tag-script">Edit tag script</option>
<option value="apply-tag-script">Apply tag script</option>
<% if CurrentUser.user.is_janitor? %>
<option value="approve">Approve</option>
<% end %>
</select>
</form>
<% if CurrentUser.is_privileged? %>
<section id="mode-box">
<h1>Mode</h1>
<form action="/">
<select name="mode">
<option value="view">View</option>
<option value="edit">Edit</option>
<option value="add-fav">Favorite</option>
<option value="remove-fav">Unfavorite</option>
<option value="rating-s">Rate safe</option>
<option value="rating-q">Rate questionable</option>
<option value="rating-e">Rate explicit</option>
<option value="vote-up">Vote up</option>
<option value="vote-down">Vote down</option>
<option value="lock-rating">Lock rating</option>
<option value="lock-note">Lock notes</option>
<option value="edit-tag-script">Edit tag script</option>
<option value="apply-tag-script">Apply tag script</option>
<% if CurrentUser.user.is_janitor? %>
<option value="approve">Approve</option>
<% end %>
</select>
</form>
</section>
<% end %>

View File

@ -2,8 +2,4 @@
<%= post_set.presenter.post_previews_html(self) %>
<div class="clearfix"></div>
<div class="paginator">
<%= numbered_paginator(post_set.posts) %>
</div>
<%= numbered_paginator(post_set.posts) %>

View File

@ -1,10 +1,7 @@
<div id="c-posts">
<div id="a-show">
<aside id="sidebar">
<section>
<h1>Search</h1>
<%= render :partial => "posts/partials/common/search" %>
</section>
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_path, :tags => params[:tags]} %>
<% if @post.pools.any? %>
<section id="pool-sidebar">

View File

@ -36,11 +36,9 @@
<% end %>
</tbody>
</table>
<%= numbered_paginator(@tag_aliases) %>
</div>
</div>
<div class="paginator">
<%= numbered_paginator(@tag_aliases) %>
</div>
<%= render "secondary_links" %>

View File

@ -36,11 +36,9 @@
<% end %>
</tbody>
</table>
<%= numbered_paginator(@tag_implications) %>
</div>
</div>
<div class="paginator">
<%= numbered_paginator(@tag_implications) %>
</div>
<%= render "secondary_links" %>

View File

@ -0,0 +1,26 @@
<div id="c-tag-subscriptions">
<div id="a-posts">
<aside id="sidebar">
<%= render :partial => "posts/partials/common/search", :locals => {:path => posts_tag_subscription_path, :tags => @post_set.tag_string} %>
<%= render :partial => "posts/partials/index/mode_menu" %>
<%= render :partial => "posts/partials/index/blacklist" %>
</aside>
<section id="content">
<h1>Posts</h1>
<%= @post_set.presenter.post_previews_html(self) %>
<%= numbered_paginator(@posts) %>
</section>
<% content_for(:page_title) do %>
/fav:<%= CurrentUser.name %>
<% end %>
<%= render :partial => "posts/partials/common/secondary_links" %>
</div>
</div>

View File

@ -1,25 +1,27 @@
<table width="100%" class="striped">
<thead>
<tr>
<th>Count</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<% @tags.each do |tag| %>
<tr>
<td><%= tag.post_count %></td>
<td class="tag-category-<%= tag.category_name %>">
<%= link_to("?", wiki_pages_path(:title => tag.name)) %>
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="c-tags">
<div id="a-index">
<table width="100%" class="striped">
<thead>
<tr>
<th>Count</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<% @tags.each do |tag| %>
<tr>
<td><%= tag.post_count %></td>
<td class="tag-category-<%= tag.category_name %>">
<%= link_to("?", wiki_pages_path(:title => tag.name)) %>
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@tags) %>
<%= numbered_paginator(@tags) %>
</div>
</div>
<%= render "secondary_links" %>

View File

@ -23,9 +23,7 @@
</tbody>
</table>
<div class="paginator">
<%= sequential_paginator(@uploads) %>
</div>
<%= sequential_paginator(@uploads) %>
</div>
</div>

View File

@ -23,9 +23,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@user_feedbacks) %>
</div>
<%= numbered_paginator(@user_feedbacks) %>
<%= render "secondary_links" %>
</div>

View File

@ -29,3 +29,5 @@
<% content_for(:page_title) do %>
/Users/<%= @user.name %>/Settings
<% end %>
<%= render "secondary_links" %>

View File

@ -48,9 +48,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@users) %>
</div>
<%= numbered_paginator(@users) %>
<%= render "secondary_links" %>
</div>

View File

@ -32,9 +32,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@wiki_page_versions) %>
</div>
<%= numbered_paginator(@wiki_page_versions) %>
</section>
</div>
</div>

View File

@ -22,9 +22,7 @@
</tbody>
</table>
<div class="paginator">
<%= numbered_paginator(@wiki_pages) %>
</div>
<%= numbered_paginator(@wiki_pages) %>
</section>
</div>
</div>

View File

@ -9,6 +9,7 @@ Danbooru::Application.routes.draw do
get :search
end
end
resource :tag
namespace :post do
resource :dashboard, :only => [:show]
resource :approval, :only => [:create]
@ -107,7 +108,11 @@ Danbooru::Application.routes.draw do
end
end
resources :tag_implications
resources :tag_subscriptions
resources :tag_subscriptions do
member do
get :posts
end
end
resources :uploads
resources :users
resources :user_feedbacks

View File

@ -5,6 +5,14 @@ if User.count == 0
:password => "password1",
:password_confirmation => "password1"
)
0.upto(100) do |i|
User.create(
:name => i.to_s * 5,
:password => i.to_s * 5,
:password_confirmation => i.to_s * 5
)
end
else
puts "Skipping users"
user = User.first
@ -93,3 +101,27 @@ if Pool.count == 0
end
end
end
if Favorite.count == 0
puts "Creating favorites"
Post.order("random()").limit(50).each do |post|
user = User.order("random()").first
post.add_favorite!(user)
post.add_favorite!(CurrentUser.user)
end
else
puts "Skipping favorites"
end
if TagSubscription.count == 0
puts "Creating tag subscriptions"
TagSubscription.create(:name => "0", :tag_query => Tag.order("random()").first.name)
1.upto(50) do |i|
CurrentUser.user = User.order("random()").first
TagSubscription.create(:name => i.to_s, :tag_query => Tag.order("random()").first.name)
end
else
puts "Skipping tag subscriptions"
end

View 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

View File

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

View File

@ -1,4 +1,4 @@
require_relative '../test_helper'
require 'test_helper'
class IpBanTest < ActiveSupport::TestCase
setup do

View 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