-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Any error associated with an individual row is now attached to an individual background job
- Loading branch information
1 parent
0df9930
commit ef8f1d7
Showing
10 changed files
with
92 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
|
||
RSpec.describe CsvRowImportJob do | ||
let(:csv_row) { FactoryBot.create(:csv_row, status: nil) } | ||
RSpec.describe CsvRowImportJob, :clean do | ||
let(:csv_import) { FactoryBot.create(:csv_import) } | ||
|
||
it 'can set a status' do | ||
described_class.perform_now(row_id: csv_row.id) | ||
csv_row.reload | ||
expect(csv_row.status).to eq('complete') | ||
context 'happy path' do | ||
let(:csv_row) { FactoryBot.create(:csv_row, status: nil, csv_import_id: csv_import.id) } | ||
|
||
it 'can set a status' do | ||
described_class.perform_now(row_id: csv_row.id) | ||
csv_row.reload | ||
expect(csv_row.status).to eq('complete') | ||
end | ||
end | ||
|
||
context 'error cases' do | ||
let(:metadata) do | ||
{ | ||
"Project Name" => "Ethiopic Manuscripts", | ||
"Item ARK" => "", | ||
"Parent ARK" => "21198/zz001pz6h6", | ||
"Object Type" => "Page" | ||
}.to_json | ||
end | ||
let(:csv_row) { FactoryBot.create(:csv_row, status: nil, metadata: metadata, error_messages: nil, csv_import_id: csv_import.id) } | ||
|
||
it 'records an error state and error messages' do | ||
described_class.perform_now(row_id: csv_row.id) | ||
csv_row.reload | ||
expect(csv_row.status).to eq('error') | ||
expect(csv_row.error_messages).to eq 'Cannot set id without a valid ark' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters