summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-03-28 04:15:41 -0700
committerStan Hu <stanhu@gmail.com>2016-03-28 04:15:41 -0700
commit2fa20f2d4f9dd6b5fd4c55018da243d9a8d0548f (patch)
treeb1941640e2316234e5d353b2bdcae9cdc4574a0f
parent30e4d3ce9a18340c689557cd0c7b5f69e48795d4 (diff)
downloadgitlab-ce-2fa20f2d4f9dd6b5fd4c55018da243d9a8d0548f.tar.gz
Handle nil descriptions in Slack issue messages
Closes #14676
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/project_services/slack_service/issue_message.rb2
-rw-r--r--spec/models/project_services/slack_service/issue_message_spec.rb10
3 files changed, 12 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7e9a447a8f6..63d5adedcb6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ v 8.7.0 (unreleased)
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Fix avatar stretching by providing a cropping feature
- Add links to CI setup documentation from project settings and builds pages
+ - Handle nil descriptions in Slack issue messages (Stan Hu)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
diff --git a/app/models/project_services/slack_service/issue_message.rb b/app/models/project_services/slack_service/issue_message.rb
index 5af24a80609..438ff33fdff 100644
--- a/app/models/project_services/slack_service/issue_message.rb
+++ b/app/models/project_services/slack_service/issue_message.rb
@@ -22,7 +22,7 @@ class SlackService
@issue_url = obj_attr[:url]
@action = obj_attr[:action]
@state = obj_attr[:state]
- @description = obj_attr[:description]
+ @description = obj_attr[:description] || ''
end
def attachments
diff --git a/spec/models/project_services/slack_service/issue_message_spec.rb b/spec/models/project_services/slack_service/issue_message_spec.rb
index 97e6f03e308..f648cbe2dee 100644
--- a/spec/models/project_services/slack_service/issue_message_spec.rb
+++ b/spec/models/project_services/slack_service/issue_message_spec.rb
@@ -27,6 +27,16 @@ describe SlackService::IssueMessage, models: true do
let(:color) { '#345' }
+ 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(