fixes #3039
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -76,6 +76,6 @@ group :test do
|
|||||||
gem "ffaker"
|
gem "ffaker"
|
||||||
gem "simplecov", :require => false
|
gem "simplecov", :require => false
|
||||||
gem "timecop"
|
gem "timecop"
|
||||||
gem "fakeweb"
|
gem "webmock"
|
||||||
gem "test_after_commit" # XXX remove me after upgrading to rails 5.
|
gem "test_after_commit" # XXX remove me after upgrading to rails 5.
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ GEM
|
|||||||
cityhash (0.8.1)
|
cityhash (0.8.1)
|
||||||
coderay (1.1.1)
|
coderay (1.1.1)
|
||||||
colorize (0.7.7)
|
colorize (0.7.7)
|
||||||
|
crack (0.4.2)
|
||||||
|
safe_yaml (~> 1.0.0)
|
||||||
crass (1.0.2)
|
crass (1.0.2)
|
||||||
daemons (1.2.3)
|
daemons (1.2.3)
|
||||||
dalli (2.7.6)
|
dalli (2.7.6)
|
||||||
@@ -128,7 +130,6 @@ GEM
|
|||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
factory_girl (4.8.0)
|
factory_girl (4.8.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
fakeweb (1.3.0)
|
|
||||||
faraday (0.10.1)
|
faraday (0.10.1)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffaker (2.5.0)
|
ffaker (2.5.0)
|
||||||
@@ -294,6 +295,7 @@ GEM
|
|||||||
rmagick (2.16.0)
|
rmagick (2.16.0)
|
||||||
ruby-prof (0.15.8)
|
ruby-prof (0.15.8)
|
||||||
rubyzip (1.1.7)
|
rubyzip (1.1.7)
|
||||||
|
safe_yaml (1.0.4)
|
||||||
sanitize (4.5.0)
|
sanitize (4.5.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.4.4)
|
nokogiri (>= 1.4.4)
|
||||||
@@ -380,6 +382,9 @@ GEM
|
|||||||
unicorn-worker-killer (0.4.4)
|
unicorn-worker-killer (0.4.4)
|
||||||
get_process_mem (~> 0)
|
get_process_mem (~> 0)
|
||||||
unicorn (>= 4, < 6)
|
unicorn (>= 4, < 6)
|
||||||
|
webmock (1.21.0)
|
||||||
|
addressable (>= 2.3.6)
|
||||||
|
crack (>= 0.3.2)
|
||||||
webrobots (0.1.2)
|
webrobots (0.1.2)
|
||||||
whenever (0.9.7)
|
whenever (0.9.7)
|
||||||
chronic (>= 0.6.3)
|
chronic (>= 0.6.3)
|
||||||
@@ -409,7 +414,6 @@ DEPENDENCIES
|
|||||||
dotenv-rails
|
dotenv-rails
|
||||||
dtext_rb!
|
dtext_rb!
|
||||||
factory_girl
|
factory_girl
|
||||||
fakeweb
|
|
||||||
ffaker
|
ffaker
|
||||||
gctools
|
gctools
|
||||||
google-api-client
|
google-api-client
|
||||||
@@ -452,6 +456,7 @@ DEPENDENCIES
|
|||||||
uglifier
|
uglifier
|
||||||
unicorn
|
unicorn
|
||||||
unicorn-worker-killer
|
unicorn-worker-killer
|
||||||
|
webmock
|
||||||
whenever
|
whenever
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ module IqdbTestHelper
|
|||||||
url = "http://localhost:3004/similar?key=hunter2&url=#{CGI.escape source}&ref"
|
url = "http://localhost:3004/similar?key=hunter2&url=#{CGI.escape source}&ref"
|
||||||
body = matches.map { |post| { post_id: post.id } }.to_json
|
body = matches.map { |post| { post_id: post.id } }.to_json
|
||||||
|
|
||||||
FakeWeb.register_uri(:get, url, body: body)
|
stub_request(:get, url).to_return(body: body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
module ReportbooruHelper
|
module ReportbooruHelper
|
||||||
def mock_popular_search_service!
|
def mock_popular_search_service!
|
||||||
Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:3003")
|
Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:3003")
|
||||||
FakeWeb.register_uri(:get, "http://localhost:3003/hits/month?date=#{Date.today}", body: "kantai_collection 1000.0\ntouhou 500.0")
|
stub_request(:get, "http://localhost:3003/hits/month?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
|
||||||
FakeWeb.register_uri(:get, "http://localhost:3003/hits/day?date=#{Date.today}", body: "kantai_collection 1000.0\ntouhou 500.0")
|
stub_request(:get, "http://localhost:3003/hits/day?date=#{Date.today}").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_missed_search_service!
|
def mock_missed_search_service!
|
||||||
Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:3003")
|
Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:3003")
|
||||||
FakeWeb.register_uri(:get, "http://localhost:3003/missed_searches", body: "kantai_collection 1000.0\ntouhou 500.0")
|
stub_request(:get, "http://localhost:3003/missed_searches").to_return(body: "kantai_collection 1000.0\ntouhou 500.0")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ end
|
|||||||
require File.expand_path('../../config/environment', __FILE__)
|
require File.expand_path('../../config/environment', __FILE__)
|
||||||
require 'rails/test_help'
|
require 'rails/test_help'
|
||||||
require 'cache'
|
require 'cache'
|
||||||
|
require 'webmock/minitest'
|
||||||
|
|
||||||
Dir[File.expand_path(File.dirname(__FILE__) + "/factories/*.rb")].each {|file| require file}
|
Dir[File.expand_path(File.dirname(__FILE__) + "/factories/*.rb")].each {|file| require file}
|
||||||
Dir[File.expand_path(File.dirname(__FILE__) + "/helpers/*.rb")].each {|file| require file}
|
Dir[File.expand_path(File.dirname(__FILE__) + "/helpers/*.rb")].each {|file| require file}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'helpers/saved_search_test_helper'
|
require 'helpers/saved_search_test_helper'
|
||||||
require 'fakeweb'
|
|
||||||
|
|
||||||
class SavedSearchTest < ActiveSupport::TestCase
|
class SavedSearchTest < ActiveSupport::TestCase
|
||||||
include SavedSearchTestHelper
|
include SavedSearchTestHelper
|
||||||
@@ -46,14 +45,10 @@ class SavedSearchTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Fetching the post ids for a search" do
|
context "Fetching the post ids for a search" do
|
||||||
teardown do
|
|
||||||
FakeWeb.clean_registry
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with a label" do
|
context "with a label" do
|
||||||
setup do
|
setup do
|
||||||
SavedSearch.expects(:queries_for).with(1, "blah").returns(%w(a b c))
|
SavedSearch.expects(:queries_for).with(1, "blah").returns(%w(a b c))
|
||||||
FakeWeb.register_uri(:post, "http://localhost:3001/v2/search", :body => "1 2 3 4")
|
stub_request(:post, "http://localhost:3001/v2/search").to_return(:body => "1 2 3 4")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return a list of ids" do
|
should "return a list of ids" do
|
||||||
@@ -65,7 +60,7 @@ class SavedSearchTest < ActiveSupport::TestCase
|
|||||||
context "without a label" do
|
context "without a label" do
|
||||||
setup do
|
setup do
|
||||||
SavedSearch.expects(:queries_for).with(1, nil).returns(%w(a b c))
|
SavedSearch.expects(:queries_for).with(1, nil).returns(%w(a b c))
|
||||||
FakeWeb.register_uri(:post, "http://localhost:3001/v2/search", :body => "1 2 3 4")
|
stub_request(:post, "http://localhost:3001/v2/search").to_return(:body => "1 2 3 4")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return a list of ids" do
|
should "return a list of ids" do
|
||||||
|
|||||||
Reference in New Issue
Block a user