Skip to content

Commit

Permalink
API-25981 Make VAForms::FormBuilder less chatty in slack (#12730)
Browse files Browse the repository at this point in the history
  • Loading branch information
cilestin authored May 19, 2023
1 parent 89b22e4 commit dd499dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion modules/va_forms/app/workers/va_forms/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def update_sha256(form)
form_data = { form_name: form.form_name, form_url: form.url }.to_s

Rails.logger.error("#{message}: #{form_data}", e)
VAForms::Slack::Messenger.new({ class: self.class.name, message:, exception: e, form_data: }).notify!

# Only alert to slack when a formerly-valid PDF turns false
if form.valid_pdf?
VAForms::Slack::Messenger.new({ class: self.class.name, message:, exception: e, form_data: }).notify!
end

form.valid_pdf = false
form
Expand Down
13 changes: 12 additions & 1 deletion modules/va_forms/spec/workers/form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@

it 'fails to update the sha256 when forms are submitted' do
VCR.use_cassette('va_forms/fails') do
form = VAForms::Form.new(url: 'http://www.vba.va.gov/pubs/forms/26-85992.pdf')
form = VAForms::Form.new(url: 'http://www.vba.va.gov/pubs/forms/26-85992.pdf', valid_pdf: true)
form = form_builder.update_sha256(form)
expect(form.valid_pdf).to eq(false)
expect(form.sha256).to eq(nil)
expect(slack_messenger).to have_received(:notify!)
end
end

it 'only sends slack notification when valid_pdf turns invalid' do
VCR.use_cassette('va_forms/fails') do
form = VAForms::Form.new(url: 'http://www.vba.va.gov/pubs/forms/26-85992.pdf', valid_pdf: false)
form = form_builder.update_sha256(form)
expect(form.valid_pdf).to eq(false)
expect(form.sha256).to eq(nil)
expect(slack_messenger).not_to have_received(:notify!)
end
end

Expand Down

0 comments on commit dd499dc

Please sign in to comment.