diff --git a/test/functional/explore/posts_controller_test.rb b/test/functional/explore/posts_controller_test.rb index 5288923d4..7d7b6fb1b 100644 --- a/test/functional/explore/posts_controller_test.rb +++ b/test/functional/explore/posts_controller_test.rb @@ -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 diff --git a/test/helpers/reportbooru_helper.rb b/test/helpers/reportbooru_helper.rb new file mode 100644 index 000000000..1591c1ef4 --- /dev/null +++ b/test/helpers/reportbooru_helper.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index cf155a94d..d428a5de4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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