From 089d64956fd36558a9631afbe769b849039d002f Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Thu, 2 May 2024 14:22:22 +0000 Subject: [PATCH] Refs #29991 - Fix tests --- test/models/token/puppetca_test.rb | 2 +- test/unit/foreman/http_proxy_test.rb | 10 +++++----- test/unit/net/dhcp_test.rb | 1 - test/unit/net/dns_test.rb | 2 -- test/unit/net/net_test.rb | 1 - test/unit/net/validations_test.rb | 1 - 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/test/models/token/puppetca_test.rb b/test/models/token/puppetca_test.rb index cd6a2cf243c5..78efb2baf78f 100644 --- a/test/models/token/puppetca_test.rb +++ b/test/models/token/puppetca_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class Token::PuppetcaTest < ActiveSupport::TestCase +class Token::PuppetCATest < ActiveSupport::TestCase should validate_uniqueness_of(:value) let(:host) { FactoryBot.create(:host) } diff --git a/test/unit/foreman/http_proxy_test.rb b/test/unit/foreman/http_proxy_test.rb index 107b9b7faf60..eadc797684d4 100644 --- a/test/unit/foreman/http_proxy_test.rb +++ b/test/unit/foreman/http_proxy_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class HttpProxyTest < ActiveSupport::TestCase +class Foreman::HttpProxyTest < ActiveSupport::TestCase class DummyHttpAdapter include Foreman::HttpProxy end @@ -106,10 +106,10 @@ class DummyHttpAdapter end describe 'Excon::Connection extension' do - let(:excon_connection) { Excon::Connection.new } + let(:excon_connection) { ::Excon::Connection.new } setup do - Excon::Connection.class_eval { prepend Foreman::HttpProxy::ExconConnectionExtension } if Excon::Connection.ancestors.first != Foreman::HttpProxy::ExconConnectionExtension + ::Excon::Connection.class_eval { prepend Foreman::HttpProxy::ExconConnectionExtension } if ::Excon::Connection.ancestors.first != Foreman::HttpProxy::ExconConnectionExtension excon_connection.stubs(:http_proxy).returns(http_proxy) excon_connection.stubs(:setup_proxy).returns excon_connection.stubs(:proxy_http_request?).returns(true) @@ -123,7 +123,7 @@ class DummyHttpAdapter test 'rescues requests and mentions proxy' do stub_request(:get, "http://#{request_host}/features").to_raise("AnException") - assert_raises_with_message Excon::Error::Socket, "AnException" do + assert_raises_with_message ::Excon::Error::Socket, "AnException" do excon_connection.request({host: request_host, path: "/features", headers: {}}) end end @@ -145,7 +145,7 @@ class DummyHttpAdapter test 'rescues requests and mentions proxy' do stub_request(:get, "http://#{request_host}/features") assert_raises_with_message StandardError.new, "Failed to open TCP connection" do - net_http.request(Net::HTTP::Get.new("/features")) + net_http.request(::Net::HTTP::Get.new("/features")) end end end diff --git a/test/unit/net/dhcp_test.rb b/test/unit/net/dhcp_test.rb index 20948b7efb9a..b9c6f43c8422 100644 --- a/test/unit/net/dhcp_test.rb +++ b/test/unit/net/dhcp_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'net' class DHCPTest < ActiveSupport::TestCase setup do diff --git a/test/unit/net/dns_test.rb b/test/unit/net/dns_test.rb index 6d1a77757c7b..d6ffcbaf39fb 100644 --- a/test/unit/net/dns_test.rb +++ b/test/unit/net/dns_test.rb @@ -1,6 +1,4 @@ require 'test_helper' -require 'net' -require 'net/dns' class DNSTest < ActiveSupport::TestCase setup do diff --git a/test/unit/net/net_test.rb b/test/unit/net/net_test.rb index f55b912e020c..79e5fc700830 100644 --- a/test/unit/net/net_test.rb +++ b/test/unit/net/net_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'net' class NetTest < ActiveSupport::TestCase test "Net record should auto assign attributes" do diff --git a/test/unit/net/validations_test.rb b/test/unit/net/validations_test.rb index 7715044f1816..706d74362494 100644 --- a/test/unit/net/validations_test.rb +++ b/test/unit/net/validations_test.rb @@ -1,5 +1,4 @@ require 'test_helper' -require 'net' class ValidationsTest < ActiveSupport::TestCase describe "validate_mac" do