From 7ce0f81fbbd9c2b35e9fe35f5ef040626e284a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Sat, 29 Oct 2022 02:47:14 +0200 Subject: [rubygems/rubygems] Use file in XDG_STATE_HOME directory to store last update check timestamp. https://github.com/rubygems/rubygems/commit/0fbc4ace8a --- test/rubygems/helper.rb | 3 +++ test/rubygems/test_gem_update_suggestion.rb | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index 43423dc101..8d94f82d8e 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -307,6 +307,7 @@ class Gem::TestCase < Test::Unit::TestCase ENV["XDG_CACHE_HOME"] = nil ENV["XDG_CONFIG_HOME"] = nil ENV["XDG_DATA_HOME"] = nil + ENV["XDG_STATE_HOME"] = nil ENV["SOURCE_DATE_EPOCH"] = nil ENV["BUNDLER_VERSION"] = nil ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "true" @@ -327,6 +328,7 @@ class Gem::TestCase < Test::Unit::TestCase @gemhome = File.join @tempdir, "gemhome" @userhome = File.join @tempdir, "userhome" + @statehome = File.join @tempdir, "statehome" ENV["GEM_SPEC_CACHE"] = File.join @tempdir, "spec_cache" @orig_ruby = if ENV["RUBY"] @@ -361,6 +363,7 @@ class Gem::TestCase < Test::Unit::TestCase Gem.instance_variable_set :@user_home, nil Gem.instance_variable_set :@config_home, nil Gem.instance_variable_set :@data_home, nil + Gem.instance_variable_set :@state_home, @statehome Gem.instance_variable_set :@gemdeps, nil Gem.instance_variable_set :@env_requirements_by_name, nil Gem.send :remove_instance_variable, :@ruby_version if diff --git a/test/rubygems/test_gem_update_suggestion.rb b/test/rubygems/test_gem_update_suggestion.rb index aefebf41cf..ba54059ee7 100644 --- a/test/rubygems/test_gem_update_suggestion.rb +++ b/test/rubygems/test_gem_update_suggestion.rb @@ -27,7 +27,7 @@ class TestUpdateSuggestion < Gem::TestCase original_config, Gem.configuration[:prevent_update_suggestion] = Gem.configuration[:prevent_update_suggestion], nil original_env, ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"], nil original_disable, Gem.disable_system_update_message = Gem.disable_system_update_message, nil - Gem.configuration[:last_update_check] = nil + Gem.configuration.last_update_check = 0 Gem.ui.stub :tty?, tty do Gem.stub :rubygems_version, rubygems_version do @@ -61,10 +61,10 @@ class TestUpdateSuggestion < Gem::TestCase with_eglible_environment(cmd: @cmd) do Time.stub :now, 123456789 do assert @cmd.eglible_for_update? - assert_equal Gem.configuration[:last_update_check], 123456789 + assert_equal Gem.configuration.last_update_check, 123456789 # test last check is written to config file - assert File.read(Gem.configuration.config_file_name).match("last_update_check: 123456789") + assert File.read(Gem.configuration.state_file_name).match("123456789") end end end @@ -122,7 +122,7 @@ class TestUpdateSuggestion < Gem::TestCase def test_eglible_for_update_unwrittable_config with_eglible_environment(ci: true, cmd: @cmd) do - Gem.configuration.stub :config_file_writable?, false do + Gem.configuration.stub :state_file_writable?, false do refute @cmd.eglible_for_update? end end @@ -130,7 +130,7 @@ class TestUpdateSuggestion < Gem::TestCase def test_eglible_for_update_notification_delay with_eglible_environment(cmd: @cmd) do - Gem.configuration[:last_update_check] = Time.now.to_i + Gem.configuration.last_update_check = Time.now.to_i refute @cmd.eglible_for_update? end end -- cgit v1.2.3