diff options
| author | Nick Thomas <nick@gitlab.com> | 2019-04-01 10:49:56 +0000 |
|---|---|---|
| committer | Nick Thomas <nick@gitlab.com> | 2019-04-01 10:49:56 +0000 |
| commit | 433cc96551a6d1f1621f9e105b1e7eb1ccc41b7a (patch) | |
| tree | a355cd32ff76ec9ed07acf968af5fc1a0db7f540 /spec | |
| parent | 0a0388cc81bac3ebc54cf47715cb90566b207a7f (diff) | |
| parent | 84d96bed60f6ffd7a1bc81f0c99ad7ff3296ef95 (diff) | |
| download | gitlab-shell-433cc96551a6d1f1621f9e105b1e7eb1ccc41b7a.tar.gz | |
Merge branch 'display-post-receive-warnings' into 'master'
Display post receive warnings from Rails
See merge request gitlab-org/gitlab-shell!288
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gitlab_post_receive_spec.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb index 3cae631..d061830 100644 --- a/spec/gitlab_post_receive_spec.rb +++ b/spec/gitlab_post_receive_spec.rb @@ -64,7 +64,7 @@ describe GitlabPostReceive do context 'when contains long url string at end' do let(:broadcast_message) { "test " * 10 + "message " * 10 + "https://localhost:5000/test/a/really/long/url/that/is/in/the/broadcast/message/do-not-truncate-when-url" } - it 'doesnt truncate url' do + it 'doesnt truncate url' do expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response) assert_broadcast_message_printed_keep_long_url_end(gitlab_post_receive) assert_new_mr_printed(gitlab_post_receive) @@ -76,7 +76,7 @@ describe GitlabPostReceive do context 'when contains long url string at start' do let(:broadcast_message) { "https://localhost:5000/test/a/really/long/url/that/is/in/the/broadcast/message/do-not-truncate-when-url " + "test " * 10 + "message " * 11} - it 'doesnt truncate url' do + it 'doesnt truncate url' do expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response) assert_broadcast_message_printed_keep_long_url_start(gitlab_post_receive) assert_new_mr_printed(gitlab_post_receive) @@ -88,7 +88,7 @@ describe GitlabPostReceive do context 'when contains long url string in middle' do let(:broadcast_message) { "test " * 11 + "https://localhost:5000/test/a/really/long/url/that/is/in/the/broadcast/message/do-not-truncate-when-url " + "message " * 11} - it 'doesnt truncate url' do + it 'doesnt truncate url' do expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response) assert_broadcast_message_printed_keep_long_url_middle(gitlab_post_receive) assert_new_mr_printed(gitlab_post_receive) @@ -96,7 +96,21 @@ describe GitlabPostReceive do expect(gitlab_post_receive.exec).to eq(true) end end + end + + context 'when warnings are present' do + let(:response) do + { + 'reference_counter_decreased' => true, + 'warnings' => 'My warning message' + } + end + it 'treats the warning as a broadcast message' do + expect_any_instance_of(GitlabNet).to receive(:post_receive).and_return(response) + expect(gitlab_post_receive).to receive(:print_formatted_alert_message).with("WARNINGS:\nMy warning message") + expect(gitlab_post_receive.exec).to eq(true) + end end context 'when redirected message available' do @@ -199,7 +213,7 @@ describe GitlabPostReceive do expect(gitlab_post_receive).to receive(:puts).with( " message message message message message message message message" ).ordered - + expect(gitlab_post_receive).to receive(:puts).with( "https://localhost:5000/test/a/really/long/url/that/is/in/the/broadcast/message/do-not-truncate-when-url" ).ordered @@ -216,7 +230,7 @@ describe GitlabPostReceive do "========================================================================" ).ordered expect(gitlab_post_receive).to receive(:puts).ordered - + expect(gitlab_post_receive).to receive(:puts).with( "https://localhost:5000/test/a/really/long/url/that/is/in/the/broadcast/message/do-not-truncate-when-url" ).ordered @@ -245,7 +259,7 @@ describe GitlabPostReceive do "========================================================================" ).ordered expect(gitlab_post_receive).to receive(:puts).ordered - + expect(gitlab_post_receive).to receive(:puts).with( " test test test test test test test test test test test" ).ordered |
