From 73ade323c8993451199a965ec2330d9c7334c2e2 Mon Sep 17 00:00:00 2001
From: Robert Speicher <rspeicher@gmail.com>
Date: Tue, 19 Jun 2018 15:45:39 -0500
Subject: [PATCH] Make the stubbed methods for SAML authorize paths more
 specific

Globally stubbing any instance of `Object` seems like a very bad idea,
and it led to test failures here:

- https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/76025159
- https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/76024972
---
 spec/support/helpers/login_helpers.rb | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb
index f7b71bf42e3..329f18cd288 100644
--- a/spec/support/helpers/login_helpers.rb
+++ b/spec/support/helpers/login_helpers.rb
@@ -152,8 +152,13 @@ module LoginHelpers
   end
 
   def stub_saml_authorize_path_helpers
-    allow_any_instance_of(Object).to receive(:user_saml_omniauth_authorize_path).and_return('/users/auth/saml')
-    allow_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml')
+    allow_any_instance_of(ActionDispatch::Routing::RoutesProxy)
+      .to receive(:user_saml_omniauth_authorize_path)
+      .and_return('/users/auth/saml')
+    allow(Devise::OmniAuth::UrlHelpers)
+      .to receive(:omniauth_authorize_path)
+      .with(:user, "saml")
+      .and_return('/users/auth/saml')
   end
 
   def stub_omniauth_config(messages)
-- 
2.30.9