tests: add explore/posts controller tests.

This commit is contained in:
evazion
2017-02-06 01:56:14 -06:00
parent 443c41cff2
commit e26fb61ee9
3 changed files with 43 additions and 0 deletions

View File

@@ -15,6 +15,27 @@ module Explore
assert_response :success
end
end
context "#searches" do
should "render" do
get :searches
assert_response :success
end
end
context "#missed_searches" do
should "render" do
get :missed_searches
assert_response :success
end
end
context "#intro" do
should "render" do
get :intro
assert_response :success
end
end
end
end
end

View File

@@ -0,0 +1,12 @@
module ReportbooruHelper
def mock_popular_search_service!
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")
FakeWeb.register_uri(:get, "http://localhost:3003/hits/day?date=#{Date.today}", body: "kantai_collection 1000.0\ntouhou 500.0")
end
def mock_missed_search_service!
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")
end
end

View File

@@ -26,3 +26,13 @@ end
MEMCACHE = MemcacheMock.new
Delayed::Worker.delay_jobs = false
require "helpers/reportbooru_helper"
class ActiveSupport::TestCase
include ReportbooruHelper
setup do
mock_popular_search_service!
mock_missed_search_service!
end
end