From 2fa20f2d4f9dd6b5fd4c55018da243d9a8d0548f Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 28 Mar 2016 04:15:41 -0700 Subject: Handle nil descriptions in Slack issue messages Closes #14676 --- CHANGELOG | 1 + app/models/project_services/slack_service/issue_message.rb | 2 +- .../project_services/slack_service/issue_message_spec.rb | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) 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( -- cgit v1.2.1