diff options
author | Tony Castrogiovanni <afarentino@gmail.com> | 2018-11-19 18:38:49 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-11-19 18:38:49 +0300 |
commit | 73a0ff413b39c2f9aaabdecc4e98ae39a17c0acf (patch) | |
tree | 279a2bebd857150f1de8b92bf5b491021d196985 /spec/models/project_services | |
parent | 3eb366722e32d878d56ed09a5fa596b777fccef5 (diff) |
Add support for surfacing a link to the branch or tag name in push messageā¦
Diffstat (limited to 'spec/models/project_services')
-rw-r--r-- | spec/models/project_services/chat_message/push_message_spec.rb | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/spec/models/project_services/chat_message/push_message_spec.rb b/spec/models/project_services/chat_message/push_message_spec.rb index 19c2862264f..973d6bdb2a0 100644 --- a/spec/models/project_services/chat_message/push_message_spec.rb +++ b/spec/models/project_services/chat_message/push_message_spec.rb @@ -48,12 +48,12 @@ describe ChatMessage::PushMessage do 'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))') expect(subject.attachments).to eq( "[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2 - author2") - expect(subject.activity).to eq({ - title: 'test.user pushed to branch', + expect(subject.activity).to eq( + title: 'test.user pushed to branch [master](http://url.com/commits/master)', subtitle: 'in [project_name](http://url.com)', text: '[Compare changes](http://url.com/compare/before...after)', image: 'http://someavatar.com' - }) + ) end end end @@ -89,12 +89,53 @@ describe ChatMessage::PushMessage do expect(subject.pretext).to eq( 'test.user pushed new tag [new_tag](http://url.com/commits/new_tag) to [project_name](http://url.com)') expect(subject.attachments).to be_empty - expect(subject.activity).to eq({ - title: 'test.user created tag', + expect(subject.activity).to eq( + title: 'test.user pushed new tag [new_tag](http://url.com/commits/new_tag)', subtitle: 'in [project_name](http://url.com)', text: '[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)', image: 'http://someavatar.com' - }) + ) + end + end + end + + context 'removed tag' do + let(:args) do + { + after: Gitlab::Git::BLANK_SHA, + before: 'before', + project_name: 'project_name', + ref: 'refs/tags/new_tag', + user_name: 'test.user', + user_avatar: 'http://someavatar.com', + project_url: 'http://url.com' + } + end + + context 'without markdown' do + it 'returns a message regarding removal of tags' do + expect(subject.pretext).to eq('test.user removed tag ' \ + 'new_tag from ' \ + '<http://url.com|project_name>') + expect(subject.attachments).to be_empty + end + end + + context 'with markdown' do + before do + args[:markdown] = true + end + + it 'returns a message regarding removal of tags' do + expect(subject.pretext).to eq( + 'test.user removed tag new_tag from [project_name](http://url.com)') + expect(subject.attachments).to be_empty + expect(subject.activity).to eq( + title: 'test.user removed tag new_tag', + subtitle: 'in [project_name](http://url.com)', + text: '[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)', + image: 'http://someavatar.com' + ) end end end @@ -122,12 +163,12 @@ describe ChatMessage::PushMessage do expect(subject.pretext).to eq( 'test.user pushed new branch [master](http://url.com/commits/master) to [project_name](http://url.com)') expect(subject.attachments).to be_empty - expect(subject.activity).to eq({ - title: 'test.user created branch', + expect(subject.activity).to eq( + title: 'test.user pushed new branch [master](http://url.com/commits/master)', subtitle: 'in [project_name](http://url.com)', text: '[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)', image: 'http://someavatar.com' - }) + ) end end end @@ -154,12 +195,12 @@ describe ChatMessage::PushMessage do expect(subject.pretext).to eq( 'test.user removed branch master from [project_name](http://url.com)') expect(subject.attachments).to be_empty - expect(subject.activity).to eq({ - title: 'test.user removed branch', + expect(subject.activity).to eq( + title: 'test.user removed branch master', subtitle: 'in [project_name](http://url.com)', text: '[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)', image: 'http://someavatar.com' - }) + ) end end end |