summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_install_update_options.rb
diff options
context:
space:
mode:
authorEllen Marie Dash <me@duckie.co>2022-01-31 23:20:58 -0500
committergit <svn-admin@ruby-lang.org>2023-10-11 19:07:26 +0000
commit7aebe2a52bac2a925c475c511640ad13a7d20490 (patch)
treec9f44963bf299a9bacb2dd19c05c6e6bf1fced54 /test/rubygems/test_gem_install_update_options.rb
parent9af5abd23acf567f5a5a88c3dbdd7676342256fa (diff)
[rubygems/rubygems] If GEM_HOME exists + isn't writable, use --user-install.
https://github.com/rubygems/rubygems/commit/6d20585645
Diffstat (limited to 'test/rubygems/test_gem_install_update_options.rb')
-rw-r--r--test/rubygems/test_gem_install_update_options.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb
index f3bd1c6d5e..7342def5e9 100644
--- a/test/rubygems/test_gem_install_update_options.rb
+++ b/test/rubygems/test_gem_install_update_options.rb
@@ -159,6 +159,33 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
FileUtils.chmod 0o755, @gemhome
end
+ def test_auto_user_install_unless_gem_home_writable
+ if Process.uid.zero?
+ pend("test_auto_user_install_unless_gem_home_writable test skipped in root privilege")
+ return
+ end
+
+ @spec = quick_gem "a" do |spec|
+ util_make_exec spec
+ end
+
+ util_build_gem @spec
+ @gem = @spec.cache_file
+
+ @cmd.handle_options %w[]
+
+ refute @cmd.options[:user_install]
+
+ FileUtils.chmod 0755, @userhome
+ FileUtils.chmod 0000, @gemhome
+
+ Gem.use_paths @gemhome, @userhome
+
+ @cmd.install_update_options.include?(:user_install)
+ ensure
+ FileUtils.chmod 0755, @gemhome
+ end
+
def test_vendor
vendordir(File.join(@tempdir, "vendor")) do
@cmd.handle_options %w[--vendor]