From 4a310b083189c7e17a0abb2224d83ba60cbae79b Mon Sep 17 00:00:00 2001 From: Scott Vlaminck Date: Wed, 3 Nov 2021 13:51:30 -0500 Subject: [PATCH] update Hubspot::Config.reset! to clear oauth header --- lib/hubspot/config.rb | 6 +++++- spec/lib/hubspot/config_spec.rb | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/hubspot/config.rb b/lib/hubspot/config.rb index 62885fea..69a9c342 100644 --- a/lib/hubspot/config.rb +++ b/lib/hubspot/config.rb @@ -42,7 +42,11 @@ def reset! @portal_id = nil @logger = DEFAULT_LOGGER @access_token = nil - Hubspot::Connection.headers({}) + @client_id = nil + @client_secret = nil + @redirect_uri = nil + + Hubspot::Connection.headers.clear end def ensure!(*params) diff --git a/spec/lib/hubspot/config_spec.rb b/spec/lib/hubspot/config_spec.rb index 006b278f..ef6813d6 100644 --- a/spec/lib/hubspot/config_spec.rb +++ b/spec/lib/hubspot/config_spec.rb @@ -61,6 +61,23 @@ expect(Hubspot::Config.hapikey).to be nil expect(Hubspot::Config.portal_id).to be nil end + + it "clears oauth token" do + Hubspot::Config.configure(client_id: "123abc", client_secret: "456def", redirect_uri: "https://example.com", access_token: "789ghi") + + expect(Hubspot::Connection.headers.size).to be 1 + + Hubspot::Config.reset! + + expect(Hubspot::Config.hapikey).to be nil + expect(Hubspot::Config.client_id).to be nil + expect(Hubspot::Config.client_secret).to be nil + expect(Hubspot::Config.redirect_uri).to be nil + expect(Hubspot::Config.access_token).to be nil + + expect(Hubspot::Connection.headers.empty?).to be true + + end end describe ".ensure!" do