summaryrefslogtreecommitdiff
path: root/spec/models/project_services/chat_message/issue_message_spec.rb
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2016-11-25 17:36:37 -0200
committerFelipe Artur <felipefac@gmail.com>2016-12-15 11:09:31 -0200
commit141faaacf9119ce5d765efe73c6509030ba078cd (patch)
tree1f5cf350087ad524273e0ba80c7ddcc3ce640ad8 /spec/models/project_services/chat_message/issue_message_spec.rb
parent2d1dfae9b63d35232e4bf537a0aca9b95e2d5e72 (diff)
downloadgitlab-ce-141faaacf9119ce5d765efe73c6509030ba078cd.tar.gz
Mattermost Notifications Service
Diffstat (limited to 'spec/models/project_services/chat_message/issue_message_spec.rb')
-rw-r--r--spec/models/project_services/chat_message/issue_message_spec.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/models/project_services/chat_message/issue_message_spec.rb b/spec/models/project_services/chat_message/issue_message_spec.rb
new file mode 100644
index 00000000000..ebe0ead4408
--- /dev/null
+++ b/spec/models/project_services/chat_message/issue_message_spec.rb
@@ -0,0 +1,67 @@
+require 'spec_helper'
+
+describe ChatMessage::IssueMessage, models: true do
+ subject { described_class.new(args) }
+
+ let(:args) do
+ {
+ user: {
+ name: 'Test User',
+ username: 'test.user'
+ },
+ project_name: 'project_name',
+ project_url: 'somewhere.com',
+
+ object_attributes: {
+ title: 'Issue title',
+ id: 10,
+ iid: 100,
+ assignee_id: 1,
+ url: 'url',
+ action: 'open',
+ state: 'opened',
+ description: 'issue description'
+ }
+ }
+ end
+
+ let(:color) { '#C95823' }
+
+ context '#initialize' do
+ before do
+ args[:object_attributes][:description] = nil
+ end
+
+ it 'returns a non-null description' do
+ expect(subject.description).to eq('')
+ end
+ end
+
+ context 'open' do
+ it 'returns a message regarding opening of issues' do
+ expect(subject.pretext).to eq(
+ '<somewhere.com|[project_name>] Issue opened by test.user')
+ expect(subject.attachments).to eq([
+ {
+ title: "#100 Issue title",
+ title_link: "url",
+ text: "issue description",
+ color: color,
+ }
+ ])
+ end
+ end
+
+ context 'close' do
+ before do
+ args[:object_attributes][:action] = 'close'
+ args[:object_attributes][:state] = 'closed'
+ end
+
+ it 'returns a message regarding closing of issues' do
+ expect(subject.pretext). to eq(
+ '<somewhere.com|[project_name>] Issue <url|#100 Issue title> closed by test.user')
+ expect(subject.attachments).to be_empty
+ end
+ end
+end