Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def workflow_run_markdown
.split(Regexp.union(delimiters))
.map(&:downcase)
.join(".")
.gsub("-.", "-")
.delete("'")

"<#{run_url}|#{@repo_name}/#{head_branch} ##{run_number}> for @#{slack_name}"
Expand Down
37 changes: 37 additions & 0 deletions test/notifier/deployment_status_message_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
let(:head_commit) do
{
"id" => sha,
"message" => "Commit message (#182)",

Check failure on line 104 in test/notifier/deployment_status_message_test.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Commit message (#182)" 3 times.

See more on https://sonarcloud.io/project/issues?id=fac_serverless-tools&issues=AZ8EOAqwVhkxC5OQ5ZsO&open=AZ8EOAqwVhkxC5OQ5ZsO&pullRequest=581
"author" => {
"name" => "Terry Pratchett"
}
Expand Down Expand Up @@ -170,6 +170,43 @@
assert_equal(subject.text_for_status("start"), expected)
end
end

describe "when author name includes a hyphen" do
let(:deploy_info) do
"<https://github.com/fac/repo-name/actions/runs/3534407323/attempts/1|fac/repo-name/branch-name #643> " \
"for @cherice.sackey-nelson\n" \
"⚙️ <https://github.com/fac/repo-name/commit/dab326e948974caba97eae82a1431d0bfcdeff36|dab326e9489> " \
"Commit message (<https://github.com/fac/repo-name/pull/182|#182>)"
end

before do
mock_git_client
.expects(:workflow_run).with(repo_name, run_id)
.returns({
"html_url" => "https://github.com/fac/repo-name/actions/runs/3534407323",
"run_attempt" => 1,
"run_number" => 643,
"head_branch" => "branch-name",
"pull_requests" => [],
"head_commit" => {
"id" => sha,
"message" => "Commit message (#182)",
"author" => {
"name" => "Cherice Sackey-Nelson"
}
},
"repository" => {
"html_url" => "https://github.com/fac/repo-name"
}
})
end

it "formats the name correctly for Slack" do
expected = "🏗️ *DEPLOYING* #{deploy_info}"

assert_equal(subject.text_for_status("start"), expected)
end
end
end
end
end