Update article published Slack notifications (#12579)
* Move Slack article published channel to SiteConfig * Add identifying comment
This commit is contained in:
parent
bac0fa1fbb
commit
d45d9be7c6
3 changed files with 11 additions and 2 deletions
|
|
@ -14,6 +14,10 @@ class SiteConfig < RailsSettings::Base
|
|||
VALID_URL = %r{\A(http|https)://([/|.\w\s-])*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?\z}.freeze
|
||||
URL_MESSAGE = "must be a valid URL".freeze
|
||||
|
||||
# Forem Team
|
||||
# [forem-fix] Remove channel name from SiteConfig
|
||||
field :article_published_slack_channel, type: :string, default: "activity"
|
||||
|
||||
# Meta
|
||||
field :admin_action_taken_at, type: :datetime, default: Time.current
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ module Slack
|
|||
url: URL.article(article),
|
||||
)
|
||||
|
||||
# [forem-fix] Remove channel name from SiteConfig
|
||||
Slack::Messengers::Worker.perform_async(
|
||||
message: message,
|
||||
channel: "activity",
|
||||
channel: SiteConfig.article_published_slack_channel,
|
||||
username: "article_bot",
|
||||
icon_emoji: ":writing_hand:",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ RSpec.describe Slack::Messengers::ArticlePublished, type: :service do
|
|||
end
|
||||
|
||||
it "messages the proper channel with the proper username and emoji", :aggregate_failures do
|
||||
channel = "test-channel"
|
||||
# [forem-fix] Remove channel name from SiteConfig
|
||||
allow(SiteConfig).to receive(:article_published_slack_channel).and_return(channel)
|
||||
|
||||
sidekiq_assert_enqueued_jobs(1, only: Slack::Messengers::Worker) do
|
||||
described_class.call(default_params)
|
||||
end
|
||||
|
|
@ -48,7 +52,7 @@ RSpec.describe Slack::Messengers::ArticlePublished, type: :service do
|
|||
job = sidekiq_enqueued_jobs(worker: Slack::Messengers::Worker).last
|
||||
job_args = job["args"].first
|
||||
|
||||
expect(job_args["channel"]).to eq("activity")
|
||||
expect(job_args["channel"]).to eq(channel)
|
||||
expect(job_args["username"]).to eq("article_bot")
|
||||
expect(job_args["icon_emoji"]).to eq(":writing_hand:")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue