diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2017-11-29 16:27:26 -0600 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2017-12-07 08:34:42 -0600 |
commit | ac8bbb9503165c9483cbd02a36c46310eb02af90 (patch) | |
tree | f13ee1fa966f2c1dbd2f434a29eacc5a22672a0e | |
parent | 76e75549b9bec9dee1e856969ef169a4450b3f30 (diff) | |
download | gitlab-shell-35385-allow-git-pull-push-on-project-redirects.tar.gz |
Prints a message if project was redirected35385-allow-git-pull-push-on-project-redirects
-rw-r--r-- | lib/gitlab_post_receive.rb | 2 | ||||
-rw-r--r-- | spec/gitlab_post_receive_spec.rb | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb index aca1ee2..4404244 100644 --- a/lib/gitlab_post_receive.rb +++ b/lib/gitlab_post_receive.rb @@ -25,9 +25,9 @@ class GitlabPostReceive end return false unless response - print_broadcast_message(response['broadcast_message']) if response['broadcast_message'] print_merge_request_links(response['merge_request_urls']) if response['merge_request_urls'] + puts response['redirected_message'] if response['redirected_message'] response['reference_counter_decreased'] rescue GitlabNet::ApiUnreachableError diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb index 82a0f8c..599dd1d 100644 --- a/spec/gitlab_post_receive_spec.rb +++ b/spec/gitlab_post_receive_spec.rb @@ -206,6 +206,30 @@ describe GitlabPostReceive do expect(gitlab_post_receive.exec).to eq(true) end end + + context 'when redirected message available' do + let(:message) do + <<-MSG + Project 'foo/bar' was moved to 'foo/baz'. + + Please update your Git remote: + + git remote set-url origin http://localhost:3000/foo/baz.git + MSG + end + let(:response) do + { + 'reference_counter_decreased' => true, + 'redirected_message' => message + } + end + + it 'prints redirected message' do + expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response) + assert_redirected_message_printed(gitlab_post_receive) + expect(gitlab_post_receive.exec).to eq(true) + end + end end end @@ -252,4 +276,15 @@ describe GitlabPostReceive do "========================================================================" ).ordered end + + def assert_redirected_message_printed(gitlab_post_receive) + message = <<-MSG + Project 'foo/bar' was moved to 'foo/baz'. + + Please update your Git remote: + + git remote set-url origin http://localhost:3000/foo/baz.git + MSG + expect(gitlab_post_receive).to receive(:puts).with(message).ordered + end end |