From dea5db0e25058ae81f9a5120e4154458768a28cb Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 4 May 2020 13:52:41 +0200 Subject: Fix PgHero Content-Security-Policy when CDN_HOST is used (#13595) --- config/initializers/content_security_policy.rb | 5 +++++ config/pghero.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 654e2e8cd..f26d9c8ea 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -46,3 +46,8 @@ end # For further information see the following documentation: # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only # Rails.application.config.content_security_policy_report_only = true + +PgHero::HomeController.content_security_policy do |p| + p.script_src :self, :unsafe_inline, assets_host + p.style_src :self, :unsafe_inline, assets_host +end diff --git a/config/pghero.yml b/config/pghero.yml index 244245d0d..84d0d7eef 100644 --- a/config/pghero.yml +++ b/config/pghero.yml @@ -38,4 +38,4 @@ databases: # aws_secret_access_key: ... # aws_region: us-east-1 -override_csp: true +override_csp: false -- cgit From e1629a77585245493d4b0ffb8d612d19b53d9087 Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 8 May 2020 21:22:57 +0200 Subject: Remove 'unsafe-inline' from Content-Security-Policy style-src (#13679) * Make sure wicg-inert doesn't rely on inline CSS * Remove unsafe-inline from style-src --- app/views/layouts/application.html.haml | 2 ++ config/initializers/content_security_policy.rb | 2 +- public/inert.css | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 public/inert.css (limited to 'config') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 25d001337..39fa0678f 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -26,6 +26,8 @@ = javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous' = csrf_meta_tags + = stylesheet_link_tag '/inert.css', skip_pipeline: true, media: 'all', id: 'inert-style' + - if Setting.custom_css.present? = stylesheet_link_tag custom_css_path, media: 'all' diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f26d9c8ea..7dcc028ab 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -22,7 +22,7 @@ Rails.application.config.content_security_policy do |p| p.frame_ancestors :none p.font_src :self, assets_host p.img_src :self, :https, :data, :blob, assets_host - p.style_src :self, :unsafe_inline, assets_host + p.style_src :self, assets_host p.media_src :self, :https, :data, assets_host p.frame_src :self, :https p.manifest_src :self, assets_host diff --git a/public/inert.css b/public/inert.css new file mode 100644 index 000000000..275fad2e6 --- /dev/null +++ b/public/inert.css @@ -0,0 +1,11 @@ +[inert] { + pointer-events: none; + cursor: default; +} + +[inert], [inert] * { + user-select: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; +} -- cgit From ad9c862bb1247b5a1724f59d009b9bb4eb86193e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 8 May 2020 21:29:03 +0200 Subject: Bump capistrano from 3.13.0 to 3.14.0 (#13624) * Bump capistrano from 3.13.0 to 3.14.0 Bumps [capistrano](https://github.com/capistrano/capistrano) from 3.13.0 to 3.14.0. - [Release notes](https://github.com/capistrano/capistrano/releases) - [Commits](https://github.com/capistrano/capistrano/compare/v3.13.0...v3.14.0) Signed-off-by: dependabot-preview[bot] * Update deploy.rb Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Eugen Rochko --- Gemfile | 2 +- Gemfile.lock | 4 ++-- config/deploy.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'config') diff --git a/Gemfile b/Gemfile index 81dc10af5..890b0ee97 100644 --- a/Gemfile +++ b/Gemfile @@ -144,7 +144,7 @@ group :development do gem 'brakeman', '~> 4.8', require: false gem 'bundler-audit', '~> 0.6', require: false - gem 'capistrano', '~> 3.13' + gem 'capistrano', '~> 3.14' gem 'capistrano-rails', '~> 1.4' gem 'capistrano-rbenv', '~> 2.1' gem 'capistrano-yarn', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 2ffaa9673..1e0df7483 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,7 +128,7 @@ GEM bundler (>= 1.2.0, < 3) thor (~> 0.18) byebug (11.1.3) - capistrano (3.13.0) + capistrano (3.14.0) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -682,7 +682,7 @@ DEPENDENCIES browser bullet (~> 6.1) bundler-audit (~> 0.6) - capistrano (~> 3.13) + capistrano (~> 3.14) capistrano-rails (~> 1.4) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) diff --git a/config/deploy.rb b/config/deploy.rb index 79550baed..31d142275 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -lock '3.12.1' +lock '3.14.0' set :repo_url, ENV.fetch('REPO', 'https://github.com/tootsuite/mastodon.git') set :branch, ENV.fetch('BRANCH', 'master') -- cgit From 34756cc4e095fa4d3add5ea94c1453e6a2f33064 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 9 May 2020 21:06:55 +0200 Subject: Fix "tootctl media remove-orphans" crashing on “Import” files (#13685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix "tootctl media remove-orphans" crashing on “Import” files * Also remove empty directories when removing orphaned media --- config/initializers/inflections.rb | 2 ++ lib/mastodon/media_cli.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index c65153b0a..0667a542c 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -19,4 +19,6 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'ActivityStreams' inflect.acronym 'JsonLd' inflect.acronym 'NodeInfo' + + inflect.singular 'data', 'data' end diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb index 424d65a5f..506544446 100644 --- a/lib/mastodon/media_cli.rb +++ b/lib/mastodon/media_cli.rb @@ -144,7 +144,14 @@ module Mastodon begin size = File.size(path) - File.delete(path) unless options[:dry_run] + unless options[:dry_run] + File.delete(path) + begin + FileUtils.rmdir(File.dirname(path), parents: true) + rescue Errno::ENOTEMPTY + # OK + end + end reclaimed_bytes += size removed += 1 -- cgit From e09e225e5c1b0ccf28cf608f0fc9aa14ed30e3e7 Mon Sep 17 00:00:00 2001 From: Bèr Kessels Date: Sun, 10 May 2020 10:19:49 +0200 Subject: Include capistrano tasks that reload the services after deploying. (#12642) After a successfull deploy, I need the services to switch over to use the new code. I need to restart the services. These capistrano tasks do that. --- config/deploy.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'config') diff --git a/config/deploy.rb b/config/deploy.rb index 31d142275..76e6b2815 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -12,3 +12,21 @@ set :migration_role, :app append :linked_files, '.env.production', 'public/robots.txt' append :linked_dirs, 'vendor/bundle', 'node_modules', 'public/system' + +namespace :systemd do + %i[sidekiq streaming web].each do |service| + %i[reload restart status].each do |action| + desc "Perform a #{action} on #{service} service" + task "#{service}:#{action}".to_sym do + on roles(:app) do + # runs e.g. "sudo restart mastodon-sidekiq.service" + sudo :systemctl, action, "#{fetch(:application)}-#{service}.service" + end + end + end + end +end + +after 'deploy:publishing', 'systemd:web:reload' +after 'deploy:publishing', 'systemd:sidekiq:restart' +after 'deploy:publishing', 'systemd:streaming:restart' -- cgit From 8be4c2ba21c6a8e4abb0522dac398645c71d8e94 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 10 May 2020 11:21:10 +0200 Subject: Add ability to remove identity proofs from account (#13682) Fix #12613 --- .../settings/identity_proofs_controller.rb | 12 ++++++++---- app/views/settings/identity_proofs/_proof.html.haml | 1 + config/locales/en.yml | 4 +++- config/routes.rb | 2 +- .../settings/identity_proofs_controller_spec.rb | 20 +++++++++++++++++++- 5 files changed, 32 insertions(+), 7 deletions(-) (limited to 'config') diff --git a/app/controllers/settings/identity_proofs_controller.rb b/app/controllers/settings/identity_proofs_controller.rb index a749d8020..3a90b7c4d 100644 --- a/app/controllers/settings/identity_proofs_controller.rb +++ b/app/controllers/settings/identity_proofs_controller.rb @@ -21,8 +21,7 @@ class Settings::IdentityProofsController < Settings::BaseController if current_account.username.casecmp(params[:username]).zero? render layout: 'auth' else - flash[:alert] = I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username) - redirect_to settings_identity_proofs_path + redirect_to settings_identity_proofs_path, alert: I18n.t('identity_proofs.errors.wrong_user', proving: params[:username], current: current_account.username) end end @@ -34,11 +33,16 @@ class Settings::IdentityProofsController < Settings::BaseController PostStatusService.new.call(current_user.account, text: post_params[:status_text]) if publish_proof? redirect_to @proof.on_success_path(params[:user_agent]) else - flash[:alert] = I18n.t('identity_proofs.errors.failed', provider: @proof.provider.capitalize) - redirect_to settings_identity_proofs_path + redirect_to settings_identity_proofs_path, alert: I18n.t('identity_proofs.errors.failed', provider: @proof.provider.capitalize) end end + def destroy + @proof = current_account.identity_proofs.find(params[:id]) + @proof.destroy! + redirect_to settings_identity_proofs_path, success: I18n.t('identity_proofs.removed') + end + private def check_required_params diff --git a/app/views/settings/identity_proofs/_proof.html.haml b/app/views/settings/identity_proofs/_proof.html.haml index 524827ad7..14e8e91be 100644 --- a/app/views/settings/identity_proofs/_proof.html.haml +++ b/app/views/settings/identity_proofs/_proof.html.haml @@ -18,3 +18,4 @@ %td = table_link_to 'external-link', t('identity_proofs.view_proof'), proof.badge.proof_url if proof.badge.proof_url + = table_link_to 'trash', t('identity_proofs.remove'), settings_identity_proof_path(proof), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') } diff --git a/config/locales/en.yml b/config/locales/en.yml index 8a7cf070f..cc34b9094 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -844,12 +844,14 @@ en: invalid_token: Keybase tokens are hashes of signatures and must be 66 hex characters verification_failed: Keybase does not recognize this token as a signature of Keybase user %{kb_username}. Please retry from Keybase. wrong_user: Cannot create a proof for %{proving} while logged in as %{current}. Log in as %{proving} and try again. - explanation_html: Here you can cryptographically connect your other identities, such as a Keybase profile. This lets other people send you encrypted messages and trust content you send them. + explanation_html: Here you can cryptographically connect your other identities from other platforms, such as Keybase. This lets other people send you encrypted messages on those platforms and allows them to trust that the content you send them comes from you. i_am_html: I am %{username} on %{service}. identity: Identity inactive: Inactive publicize_checkbox: 'And toot this:' publicize_toot: 'It is proven! I am %{username} on %{service}: %{url}' + remove: Remove proof from account + removed: Successfully removed proof from account status: Verification status view_proof: View proof imports: diff --git a/config/routes.rb b/config/routes.rb index fa6639138..920a48fe7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -130,7 +130,7 @@ Rails.application.routes.draw do resource :confirmation, only: [:new, :create] end - resources :identity_proofs, only: [:index, :show, :new, :create, :update] + resources :identity_proofs, only: [:index, :new, :create, :destroy] resources :applications, except: [:edit] do member do diff --git a/spec/controllers/settings/identity_proofs_controller_spec.rb b/spec/controllers/settings/identity_proofs_controller_spec.rb index 261e980d4..16f236227 100644 --- a/spec/controllers/settings/identity_proofs_controller_spec.rb +++ b/spec/controllers/settings/identity_proofs_controller_spec.rb @@ -151,7 +151,7 @@ describe Settings::IdentityProofsController do @proof1 = Fabricate(:account_identity_proof, account: user.account) @proof2 = Fabricate(:account_identity_proof, account: user.account) allow_any_instance_of(AccountIdentityProof).to receive(:badge) { double(avatar_url: '', profile_url: '', proof_url: '') } - allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) { } + allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) {} end it 'has the first proof username on the page' do @@ -165,4 +165,22 @@ describe Settings::IdentityProofsController do end end end + + describe 'DELETE #destroy' do + before do + allow_any_instance_of(ProofProvider::Keybase::Verifier).to receive(:valid?) { true } + @proof1 = Fabricate(:account_identity_proof, account: user.account) + allow_any_instance_of(AccountIdentityProof).to receive(:badge) { double(avatar_url: '', profile_url: '', proof_url: '') } + allow_any_instance_of(AccountIdentityProof).to receive(:refresh!) {} + delete :destroy, params: { id: @proof1.id } + end + + it 'redirects to :index' do + expect(response).to redirect_to settings_identity_proofs_path + end + + it 'removes the proof' do + expect(AccountIdentityProof.where(id: @proof1.id).count).to eq 0 + end + end end -- cgit From 4a2ea2e51b22558bf62216b6be932a5d64014164 Mon Sep 17 00:00:00 2001 From: taicv Date: Sun, 10 May 2020 16:25:35 +0700 Subject: Add `vi` to available locales (#13542) * Enable selecting Vietnamese language in Admin Dashboard * Update settings_helper.rb Co-authored-by: Eugen Rochko --- app/helpers/settings_helper.rb | 1 + config/application.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'config') diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 74544bad9..87718dc05 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -68,6 +68,7 @@ module SettingsHelper tr: 'Türkçe', uk: 'Українська', ur: 'اُردُو', + vi: 'Tiếng Việt', 'zh-CN': '简体中文', 'zh-HK': '繁體中文(香港)', 'zh-TW': '繁體中文(臺灣)', diff --git a/config/application.rb b/config/application.rb index 4c34efa15..d1980cd68 100644 --- a/config/application.rb +++ b/config/application.rb @@ -106,6 +106,7 @@ module Mastodon :tr, :uk, :ur, + :vi, :'zh-CN', :'zh-HK', :'zh-TW', -- cgit From 4b766f984689311523b89e1b68d2a11dff3fc396 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 10 May 2020 11:41:43 +0200 Subject: Refactor monkey-patching of Goldfinger (#12561) --- app/helpers/webfinger_helper.rb | 19 +++++++++++++++++++ app/models/remote_follow.rb | 3 ++- .../activitypub/fetch_remote_account_service.rb | 5 +++-- app/services/resolve_account_service.rb | 3 ++- config/initializers/http_client_proxy.rb | 20 +++++++++----------- spec/controllers/remote_follow_controller_spec.rb | 10 +++++----- 6 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 app/helpers/webfinger_helper.rb (limited to 'config') diff --git a/app/helpers/webfinger_helper.rb b/app/helpers/webfinger_helper.rb new file mode 100644 index 000000000..70c493210 --- /dev/null +++ b/app/helpers/webfinger_helper.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module WebfingerHelper + def webfinger!(uri) + hidden_service_uri = /\.(onion|i2p)(:\d+)?$/.match(uri) + + raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if !Rails.configuration.x.access_to_hidden_service && hidden_service_uri + + opts = { + ssl: !hidden_service_uri, + + headers: { + 'User-Agent': Mastodon::Version.user_agent, + }, + } + + Goldfinger::Client.new(uri, opts.merge(Rails.configuration.x.http_client_proxy)).finger + end +end diff --git a/app/models/remote_follow.rb b/app/models/remote_follow.rb index 5ea535287..30b84f7d5 100644 --- a/app/models/remote_follow.rb +++ b/app/models/remote_follow.rb @@ -3,6 +3,7 @@ class RemoteFollow include ActiveModel::Validations include RoutingHelper + include WebfingerHelper attr_accessor :acct, :addressable_template @@ -71,7 +72,7 @@ class RemoteFollow end def acct_resource - @acct_resource ||= Goldfinger.finger("acct:#{acct}") + @acct_resource ||= webfinger!("acct:#{acct}") rescue Goldfinger::Error, HTTP::ConnectionError nil end diff --git a/app/services/activitypub/fetch_remote_account_service.rb b/app/services/activitypub/fetch_remote_account_service.rb index d65c8f951..83fbf6d07 100644 --- a/app/services/activitypub/fetch_remote_account_service.rb +++ b/app/services/activitypub/fetch_remote_account_service.rb @@ -3,6 +3,7 @@ class ActivityPub::FetchRemoteAccountService < BaseService include JsonLdHelper include DomainControlHelper + include WebfingerHelper SUPPORTED_TYPES = %w(Application Group Organization Person Service).freeze @@ -35,12 +36,12 @@ class ActivityPub::FetchRemoteAccountService < BaseService private def verified_webfinger? - webfinger = Goldfinger.finger("acct:#{@username}@#{@domain}") + webfinger = webfinger!("acct:#{@username}@#{@domain}") confirmed_username, confirmed_domain = split_acct(webfinger.subject) return webfinger.link('self')&.href == @uri if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero? - webfinger = Goldfinger.finger("acct:#{confirmed_username}@#{confirmed_domain}") + webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}") @username, @domain = split_acct(webfinger.subject) self_reference = webfinger.link('self') diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb index 1ad9ed407..17ace100c 100644 --- a/app/services/resolve_account_service.rb +++ b/app/services/resolve_account_service.rb @@ -3,6 +3,7 @@ class ResolveAccountService < BaseService include JsonLdHelper include DomainControlHelper + include WebfingerHelper class WebfingerRedirectError < StandardError; end @@ -76,7 +77,7 @@ class ResolveAccountService < BaseService end def process_webfinger!(uri, redirected = false) - @webfinger = Goldfinger.finger("acct:#{uri}") + @webfinger = webfinger!("acct:#{uri}") confirmed_username, confirmed_domain = @webfinger.subject.gsub(/\Aacct:/, '').split('@') if confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero? diff --git a/config/initializers/http_client_proxy.rb b/config/initializers/http_client_proxy.rb index 9d7b16e69..7a9b7b86d 100644 --- a/config/initializers/http_client_proxy.rb +++ b/config/initializers/http_client_proxy.rb @@ -1,24 +1,22 @@ Rails.application.configure do config.x.http_client_proxy = {} + if ENV['http_proxy'].present? proxy = URI.parse(ENV['http_proxy']) + raise "Unsupported proxy type: #{proxy.scheme}" unless %w(http https).include? proxy.scheme raise "No proxy host" unless proxy.host host = proxy.host host = host[1...-1] if host[0] == '[' # for IPv6 address - config.x.http_client_proxy[:proxy] = { proxy_address: host, proxy_port: proxy.port, proxy_username: proxy.user, proxy_password: proxy.password }.compact + + config.x.http_client_proxy[:proxy] = { + proxy_address: host, + proxy_port: proxy.port, + proxy_username: proxy.user, + proxy_password: proxy.password, + }.compact end config.x.access_to_hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true' end - -module Goldfinger - def self.finger(uri, opts = {}) - to_hidden = /\.(onion|i2p)(:\d+)?$/.match(uri) - raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if !Rails.configuration.x.access_to_hidden_service && to_hidden - opts = { ssl: !to_hidden, headers: {} }.merge(Rails.configuration.x.http_client_proxy).merge(opts) - opts[:headers]['User-Agent'] ||= Mastodon::Version.user_agent - Goldfinger::Client.new(uri, opts).finger - end -end diff --git a/spec/controllers/remote_follow_controller_spec.rb b/spec/controllers/remote_follow_controller_spec.rb index d79dd2949..3ef8f14d9 100644 --- a/spec/controllers/remote_follow_controller_spec.rb +++ b/spec/controllers/remote_follow_controller_spec.rb @@ -35,7 +35,7 @@ describe RemoteFollowController do context 'when webfinger values are wrong' do it 'renders new when redirect url is nil' do resource_with_nil_link = double(link: nil) - allow(Goldfinger).to receive(:finger).with('acct:user@example.com').and_return(resource_with_nil_link) + allow_any_instance_of(WebfingerHelper).to receive(:webfinger!).with('acct:user@example.com').and_return(resource_with_nil_link) post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@example.com' } } expect(response).to render_template(:new) @@ -45,7 +45,7 @@ describe RemoteFollowController do it 'renders new when template is nil' do link_with_nil_template = double(template: nil) resource_with_link = double(link: link_with_nil_template) - allow(Goldfinger).to receive(:finger).with('acct:user@example.com').and_return(resource_with_link) + allow_any_instance_of(WebfingerHelper).to receive(:webfinger!).with('acct:user@example.com').and_return(resource_with_link) post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@example.com' } } expect(response).to render_template(:new) @@ -57,7 +57,7 @@ describe RemoteFollowController do before do link_with_template = double(template: 'http://example.com/follow_me?acct={uri}') resource_with_link = double(link: link_with_template) - allow(Goldfinger).to receive(:finger).with('acct:user@example.com').and_return(resource_with_link) + allow_any_instance_of(WebfingerHelper).to receive(:webfinger!).with('acct:user@example.com').and_return(resource_with_link) post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@example.com' } } end @@ -79,7 +79,7 @@ describe RemoteFollowController do end it 'renders new with error when goldfinger fails' do - allow(Goldfinger).to receive(:finger).with('acct:user@example.com').and_raise(Goldfinger::Error) + allow_any_instance_of(WebfingerHelper).to receive(:webfinger!).with('acct:user@example.com').and_raise(Goldfinger::Error) post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@example.com' } } expect(response).to render_template(:new) @@ -87,7 +87,7 @@ describe RemoteFollowController do end it 'renders new when occur HTTP::ConnectionError' do - allow(Goldfinger).to receive(:finger).with('acct:user@unknown').and_raise(HTTP::ConnectionError) + allow_any_instance_of(WebfingerHelper).to receive(:webfinger!).with('acct:user@unknown').and_raise(HTTP::ConnectionError) post :create, params: { account_username: @account.to_param, remote_follow: { acct: 'user@unknown' } } expect(response).to render_template(:new) -- cgit