Commit 43aca15e authored by Anton Smith's avatar Anton Smith Committed by Luke Duncalfe

Remove Slack attachment in new issue presenter

https://gitlab.com/gitlab-org/gitlab/-/issues/324600
parent e3df0b6e
---
title: Remove Slack attachment from new issues created via Slash commands
merge_request: 57431
author:
type: changed
...@@ -12,16 +12,18 @@ module Gitlab ...@@ -12,16 +12,18 @@ module Gitlab
private private
def fallback_message def pretext
"New issue #{issue.to_reference}: #{issue.title}" "I created an issue on #{author_profile_link}'s behalf: *#{issue_link}* in #{project_link}"
end end
def fields_with_markdown def issue_link
%i(title pretext text fields) "[#{issue.to_reference}](#{project_issue_url(issue.project, issue)})"
end end
def pretext def response_message(custom_pretext: pretext)
"I created an issue on #{author_profile_link}'s behalf: *#{issue.to_reference}* in #{project_link}" {
text: pretext
}
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::SlashCommands::Presenters::IssueNew do RSpec.describe Gitlab::SlashCommands::Presenters::IssueNew do
include Gitlab::Routing
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:attachment) { subject[:attachments].first }
subject { described_class.new(issue).present } subject { described_class.new(issue).present }
it { is_expected.to be_a(Hash) } it { is_expected.to be_a(Hash) }
it 'shows the issue' do it 'shows the issue' do
expect(subject[:response_type]).to be(:in_channel) expected_text = "I created an issue on <#{url_for(issue.author)}|#{issue.author.to_reference}>'s behalf: *<#{project_issue_url(issue.project, issue)}|#{issue.to_reference}>* in <#{project.web_url}|#{project.full_name}>"
expect(subject).to have_key(:attachments)
expect(attachment[:title]).to start_with(issue.title) expect(subject).to eq(
response_type: :in_channel,
status: 200,
text: expected_text
)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment