Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log validation errors in sentry #404

Merged
merged 5 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -7,7 +7,12 @@ def create
education_benefits_claim = EducationBenefitsClaim.new(education_benefits_claim_params)

unless education_benefits_claim.save
logger.error(education_benefits_claim.errors.full_messages.join(', '))
validation_error = education_benefits_claim.errors.full_messages.join(', ')

Raven.tags_context(validation: 'education_benefits_claim')
Raven.capture_exception(validation_error)

logger.error(validation_error)
raise Common::Exceptions::ValidationErrors, education_benefits_claim
end

Expand Down
7 changes: 6 additions & 1 deletion spec/request/education_benefits_claims_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@
it 'should log the validation errors' do
education_benefits_claim = EducationBenefitsClaim.new(params[:educationBenefitsClaim])
education_benefits_claim.valid?
validation_error = education_benefits_claim.errors.full_messages.join(', ')

allow(Rails.logger).to receive(:error)
expect(Rails.logger).to receive(:error).with(education_benefits_claim.errors.full_messages.join(', ')).once
expect(Rails.logger).to receive(:error).with(validation_error).once

expect(Raven).to receive(:tags_context).once.with(validation: 'education_benefits_claim')
expect(Raven).to receive(:capture_exception).once.with(validation_error)

subject
end
Expand Down