summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_push_command.rb
diff options
context:
space:
mode:
authorJenny Shen <jenny.shen@shopify.com>2022-09-16 08:48:38 -0400
committergit <svn-admin@ruby-lang.org>2022-09-29 17:56:34 +0900
commit1cbf0fd86356ccbac5556ab0f63ea8a4b08fd24d (patch)
tree594fd118edf2ddb0af882955521a1f048805515d /test/rubygems/test_gem_commands_push_command.rb
parent9948b8bfec08d18c2803dd1fced82a6c28967441 (diff)
[rubygems/rubygems] Add error message when api response is a permanent redirect
https://github.com/rubygems/rubygems/commit/ccca30c77a Co-authored-by: Nick Schwaderer <nick.schwaderer@shopify.com>
Diffstat (limited to 'test/rubygems/test_gem_commands_push_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index f38a2ae7a1..c58d3f3692 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -325,6 +325,24 @@ class TestGemCommandsPushCommand < Gem::TestCase
assert_match @response, @ui.output
end
+ def test_sending_gem_to_permanent_redirect_host
+ @host = "http://rubygems.example"
+ @fetcher.data["#{@host}/api/v1/gems"] = ["", 308, "Permanent Redirect"]
+
+ assert_raise Gem::MockGemUi::TermError do
+ use_ui @ui do
+ @cmd.instance_variable_set :@host, @host
+
+ Gem::Uri.stub("parse", URI.parse("https://rubygems.example/")) do
+ @cmd.send_gem(@path)
+ end
+ end
+ end
+
+ response = "The request has redirected permanently to https://rubygems.example. Please check your defined push host."
+ assert_match response, @ui.output
+ end
+
def test_raises_error_with_no_arguments
def @cmd.sign_in(*); end
assert_raise Gem::CommandLineError do