refactored search
This commit is contained in:
@@ -7,6 +7,7 @@ FactoryGirl.define do
|
||||
uploader_ip_addr "127.0.0.1"
|
||||
tag_string "special"
|
||||
status "pending"
|
||||
server Socket.gethostname
|
||||
|
||||
factory(:source_upload) do
|
||||
source "http://www.google.com/intl/en_ALL/images/logo.gif"
|
||||
|
||||
@@ -19,7 +19,7 @@ class ArtistVersionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "get the index page when searching for something" do
|
||||
get :index, {:search => {:name_equals => @artist.name}}
|
||||
get :index, {:search => {:name => @artist.name}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class IpBansControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:ip_addr_equals => "1.2.3.4"}}, {:user_id => @admin.id}
|
||||
get :index, {:search => {:ip_addr => "1.2.3.4"}}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:user_name_equals => @user.name}}, {:user_id => @admin.id}
|
||||
get :index, {:search => {:user_name => @user.name}}, {:user_id => @admin.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,17 +12,17 @@ module Moderator
|
||||
end
|
||||
|
||||
should "find by ip addr" do
|
||||
get :index, {:search => {:ip_addr_eq => "127.0.0.1"}}, {:user_id => @user.id}
|
||||
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_eq => @user.id.to_s}}, {:user_id => @user.id}
|
||||
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_eq => @user.name}}, {:user_id => @user.id}
|
||||
get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class NoteVersionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:updater_id_equals => @user_2.id}}
|
||||
get :index, {:search => {:updater_id => @user_2.id}}
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:note_versions))
|
||||
assert_equal(1, assigns(:note_versions).size)
|
||||
|
||||
@@ -36,7 +36,7 @@ class PoolVersionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:updater_id_equals => @user_2.id}}
|
||||
get :index, {:search => {:updater_id => @user_2.id}}
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:pool_versions))
|
||||
assert_equal(1, assigns(:pool_versions).size)
|
||||
|
||||
@@ -33,7 +33,7 @@ class PostAppealsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:post_id_equals => @post_appeal.post_id}}, {:user_id => @user.id}
|
||||
get :index, {:search => {:post_id => @post_appeal.post_id}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ class PostFlagsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:post_id_equals => @post_flag.post_id}}, {:user_id => @user.id}
|
||||
get :index, {:search => {:post_id => @post_flag.post_id}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class PostVersionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:post_id_equals => @post.id}}
|
||||
get :index, {:search => {:post_id => @post.id}}
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:post_versions))
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all tag_aliass (with search)" do
|
||||
get :index, {:search => {:antecedent_name_matches => "aaa"}}
|
||||
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all tag_implications (with search)" do
|
||||
get :index, {:search => {:antecedent_name_matches => "aaa"}}
|
||||
get :index, {:search => {:antecedent_name => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ class TagsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:name_equals => "aaa"}}
|
||||
get :index, {:search => {:name_matches => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ class UploadsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:source_equals => @upload.source}}, {:user_id => @user.id}
|
||||
get :index, {:search => {:source => @upload.source}}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
||||
|
||||
context "with search parameters" do
|
||||
should "render" do
|
||||
get :index, {:search => {:user_id_equals => @user.id}}, {:user_id => @critic.id}
|
||||
get :index, {:search => {:user_id => @user.id}}, {:user_id => @critic.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class WikiPageVersionsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all versions that match the search criteria" do
|
||||
get :index, {:search => {:wiki_page_id_equals => @wiki_page.id}}
|
||||
get :index, {:search => {:wiki_page_id => @wiki_page.id}}
|
||||
assert_response :success
|
||||
assert_not_nil(assigns(:wiki_page_versions))
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list all wiki_pages (with search)" do
|
||||
get :index, {:search => {:title_matches => "abc"}}
|
||||
get :index, {:search => {:title => "abc"}}
|
||||
assert_redirected_to(wiki_page_path(@wiki_page_abc))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ require 'test_helper'
|
||||
class AdvertisementTest < ActiveSupport::TestCase
|
||||
context "An advertisement" do
|
||||
setup do
|
||||
Danbooru.config.stubs(:advertisement_path).returns("/tmp")
|
||||
@ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"))
|
||||
end
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
||||
cat_or_fish.reload
|
||||
assert_equal("yuu", cat_or_fish.member_names)
|
||||
assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first)
|
||||
assert_not_nil(Artist.search(:name => "group:cat_or_fish").first)
|
||||
end
|
||||
|
||||
should "have an associated wiki" do
|
||||
|
||||
@@ -27,7 +27,7 @@ module Sources
|
||||
first_tag = @site.tags.first
|
||||
assert_equal(2, first_tag.size)
|
||||
assert(first_tag[0] =~ /./)
|
||||
assert(first_tag[1] =~ /tags\.php\?tag=/)
|
||||
assert(first_tag[1] =~ /search\.php/)
|
||||
end
|
||||
|
||||
should "convert a page into a json representation" do
|
||||
|
||||
@@ -7,11 +7,13 @@ class UploadTest < ActiveSupport::TestCase
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
Delayed::Worker.delay_jobs = false
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
Delayed::Worker.delay_jobs = true
|
||||
|
||||
@upload.delete_temp_file if @upload
|
||||
end
|
||||
@@ -122,7 +124,7 @@ class UploadTest < ActiveSupport::TestCase
|
||||
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
||||
assert_equal(6197, File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)))
|
||||
assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
||||
assert_equal(117877, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
||||
assert_equal(108224, File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user