From e26fb61ee956291635d80cb046fbcdcfc01273d7 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 6 Feb 2017 01:56:14 -0600 Subject: [PATCH] tests: add explore/posts controller tests. --- .../explore/posts_controller_test.rb | 21 +++++++++++++++++++ test/helpers/reportbooru_helper.rb | 12 +++++++++++ test/test_helper.rb | 10 +++++++++ 3 files changed, 43 insertions(+) create mode 100644 test/helpers/reportbooru_helper.rb 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