From 1c8199d5b874d8d0005cf4d7e90a046cb4c3e24f Mon Sep 17 00:00:00 2001 From: Jenny Shen Date: Wed, 1 May 2024 12:48:39 -0400 Subject: [PATCH] Fix flaky tests SSLPoster was leaking changes in state to other tests --- test/unit/posts_data_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit/posts_data_test.rb b/test/unit/posts_data_test.rb index 4cade9a..ca19d64 100644 --- a/test/unit/posts_data_test.rb +++ b/test/unit/posts_data_test.rb @@ -2,7 +2,6 @@ require 'active_support/core_ext/class' class PostsDataTest < Minitest::Test - class SSLPoster include PostsData @@ -44,6 +43,8 @@ def test_logger_warns_if_ssl_strict_disabled SSLPoster.ssl_strict = false @poster.raw_ssl_request(:post, "https://shopify.com", "", {}) + ensure + SSLPoster.ssl_strict = true end def test_logger_warns_can_handle_non_string_endpoints @@ -65,10 +66,15 @@ def test_logger_no_warning_if_ssl_strict_enabled end def test_set_proxy_address_and_port + original_proxy_address = SSLPoster.proxy_address + original_proxy_port = SSLPoster.proxy_port SSLPoster.proxy_address = 'http://proxy.example.com' SSLPoster.proxy_port = '8888' assert_equal @poster.proxy_address, 'http://proxy.example.com' assert_equal @poster.proxy_port, '8888' + ensure + SSLPoster.proxy_address = original_proxy_address + SSLPoster.proxy_port = original_proxy_port end class HttpConnectionAbort < StandardError; end