From fabc4af7fff41f4b586b45713ae74680087764ee Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Mon, 22 Jan 2018 22:24:22 +0900 Subject: [PATCH] Rename FetchRemoteResourceService to ResolveURLService (#6328) The service used to be named FetchRemoteResourceService resolves local URL as well. --- ..._resource_service.rb => resolve_url_service.rb} | 2 +- app/services/search_service.rb | 14 +++++++------- ...service_spec.rb => resolve_url_service_spec.rb} | 2 +- spec/services/search_service_spec.rb | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) rename app/services/{fetch_remote_resource_service.rb => resolve_url_service.rb} (97%) rename spec/services/{fetch_remote_resource_service_spec.rb => resolve_url_service_spec.rb} (97%) diff --git a/app/services/fetch_remote_resource_service.rb b/app/services/resolve_url_service.rb similarity index 97% rename from app/services/fetch_remote_resource_service.rb rename to app/services/resolve_url_service.rb index 6d40796f24..1f2b24524a 100644 --- a/app/services/fetch_remote_resource_service.rb +++ b/app/services/resolve_url_service.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class FetchRemoteResourceService < BaseService +class ResolveURLService < BaseService include JsonLdHelper attr_reader :url diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 85ad94463b..5f763b8f77 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -8,7 +8,7 @@ class SearchService < BaseService default_results.tap do |results| if url_query? - results.merge!(remote_resource_results) unless remote_resource.nil? + results.merge!(url_resource_results) unless url_resource.nil? elsif query.present? results[:accounts] = AccountSearchService.new.call(query, limit, account, resolve: resolve) results[:hashtags] = Tag.search_for(query.gsub(/\A#/, ''), limit) unless query.start_with?('@') @@ -24,15 +24,15 @@ class SearchService < BaseService query =~ /\Ahttps?:\/\// end - def remote_resource_results - { remote_resource_symbol => [remote_resource] } + def url_resource_results + { url_resource_symbol => [url_resource] } end - def remote_resource - @_remote_resource ||= FetchRemoteResourceService.new.call(query) + def url_resource + @_url_resource ||= ResolveURLService.new.call(query) end - def remote_resource_symbol - remote_resource.class.name.downcase.pluralize.to_sym + def url_resource_symbol + url_resource.class.name.downcase.pluralize.to_sym end end diff --git a/spec/services/fetch_remote_resource_service_spec.rb b/spec/services/resolve_url_service_spec.rb similarity index 97% rename from spec/services/fetch_remote_resource_service_spec.rb rename to spec/services/resolve_url_service_spec.rb index b80fb24750..1e9be4c07a 100644 --- a/spec/services/fetch_remote_resource_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe FetchRemoteResourceService do +describe ResolveURLService do subject { described_class.new } describe '#call' do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 3ffcc389b1..957b60c7dd 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -26,7 +26,7 @@ describe SearchService do context 'that does not find anything' do it 'returns the empty results' do service = double(call: nil) - allow(FetchRemoteResourceService).to receive(:new).and_return(service) + allow(ResolveURLService).to receive(:new).and_return(service) results = subject.call(@query, 10) expect(service).to have_received(:call).with(@query) @@ -38,7 +38,7 @@ describe SearchService do it 'includes the account in the results' do account = Account.new service = double(call: account) - allow(FetchRemoteResourceService).to receive(:new).and_return(service) + allow(ResolveURLService).to receive(:new).and_return(service) results = subject.call(@query, 10) expect(service).to have_received(:call).with(@query) @@ -50,7 +50,7 @@ describe SearchService do it 'includes the status in the results' do status = Status.new service = double(call: status) - allow(FetchRemoteResourceService).to receive(:new).and_return(service) + allow(ResolveURLService).to receive(:new).and_return(service) results = subject.call(@query, 10) expect(service).to have_received(:call).with(@query)