Refactor Reportbooru API clients.
* Combine MissedSearchService, PostViewCountService, and PopularSearchService into single ReportbooruService class. * Use Danbooru::Http for these services instead of HTTParty.
This commit is contained in:
@@ -28,8 +28,17 @@ module Explore
|
||||
end
|
||||
end
|
||||
|
||||
context "#viewed" do
|
||||
should "render" do
|
||||
mock_post_view_rankings(Date.today, [[@post.id, 100]])
|
||||
get viewed_explore_posts_path
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "#searches" do
|
||||
should "render" do
|
||||
mock_post_search_rankings(Date.today, [["1girl", 100], ["original", 50]])
|
||||
get searches_explore_posts_path
|
||||
assert_response :success
|
||||
end
|
||||
@@ -37,6 +46,7 @@ module Explore
|
||||
|
||||
context "#missed_searches" do
|
||||
should "render" do
|
||||
mock_missed_search_rankings([["1girl", 100], ["original", 50]])
|
||||
get missed_searches_explore_posts_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -3,13 +3,15 @@ require "test_helper"
|
||||
class PostsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The posts controller" do
|
||||
setup do
|
||||
PopularSearchService.stubs(:enabled?).returns(false)
|
||||
|
||||
@user = travel_to(1.month.ago) {create(:user)}
|
||||
@post = as(@user) { create(:post, tag_string: "aaaa") }
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
mock_post_search_rankings(Date.today, [["1girl", 100], ["original", 50]])
|
||||
end
|
||||
|
||||
should "render" do
|
||||
get posts_path
|
||||
assert_response :success
|
||||
|
||||
@@ -16,6 +16,7 @@ class StaticControllerTest < ActionDispatch::IntegrationTest
|
||||
context "sitemap action" do
|
||||
should "work" do
|
||||
create_list(:post, 3)
|
||||
mock_post_search_rankings(Time.zone.yesterday, [["1girl", 100.0], ["2girls", 50.0]])
|
||||
get sitemap_path, as: :xml
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user