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

Send email even if there was an exception in Preparsing #557

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions app/workers/preparsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def perform(genotype_id)
file_has_mails = true
end

ensure
# not proper file!
if not file_is_ok
if file_is_duplicate
Expand Down
Binary file added spec/fixtures/files/broken_genotype_file.gz
Binary file not shown.
23 changes: 23 additions & 0 deletions spec/workers/preparsing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

RSpec.describe Preparsing do
tsujigiri marked this conversation as resolved.
Show resolved Hide resolved
subject(:worker) { described_class.new }

let!(:genotype) do
create(
:genotype,
genotype: Rails.root.join('spec', 'fixtures', 'files', 'broken_genotype_file.gz').open
)
end

context 'when there is an exception' do
it 'still sends emails ' do
expect { worker.perform(genotype.id) }
.to raise_error(ArgumentError, 'invalid byte sequence in UTF-8')

expect(ActionMailer::Base.deliveries.count).to eq(1)
expect(ActionMailer::Base.deliveries.last.subject)
.to eq('openSNP.org: Something went wrong while parsing')
end
end
end