Skip to content

Commit

Permalink
🧹 [i1010] combine embargo and lease test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaLMoore committed Apr 17, 2024
1 parent 04e599e commit 5148436
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/bulkrax/has_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def multiple?(field)
end

def fields_that_are_always_multiple
@fields_that_are_always_multiple = %W[
@fields_that_are_always_multiple = %w[
id
delete
model
visibility
visibility
visibility_during_embargo
embargo_release_date
visibility_after_embargo
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/csv/embargo-lease.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
model,title,creator,source_identifier,visibility,visibility_during_embargo,embargo_release_date,visibility_after_embargo,visibility_during_lease,lease_expiration_date,visibility_after_lease
Work,An Image,user,123456789,embargo,restricted,2024-04-19,open,,,,
Work,An Image,user,1987654321,lease,,,,restricted,2024-04-19,open
2 changes: 0 additions & 2 deletions spec/fixtures/csv/embargo.csv

This file was deleted.

2 changes: 0 additions & 2 deletions spec/fixtures/csv/lease.csv

This file was deleted.

66 changes: 35 additions & 31 deletions spec/models/bulkrax/csv_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1257,23 +1257,25 @@ class ::Avacado < Work
end
end

describe 'exposing lease attributes for parser' do
let(:data) {
describe 'exposing embargo attributes for parser' do
let(:data) do
{
'model': 'Work',
'title': 'Image',
'creator': 'user A',
'source_identifier': '123456789',
'visibility': 'embargo',
'visibility_during_embargo': 'restricted',
'embargo_release_date': '2054-04-19',
'visibility_after_embargo': 'open'
'model': 'Work',
'title': 'Image',
'creator': 'user A',
'source_identifier': '123456789',
'visibility': 'embargo',
'visibility_during_embargo': 'restricted',
'embargo_release_date': '2054-04-19',
'visibility_after_embargo': 'open'
}
}
let(:entry) { Bulkrax::EntrySpecHelper.entry_for(identifier: '123456789',
data: data,
parser_class_name: 'Bulkrax::CsvParser',
parser_fields: { 'import_file_path': 'spec/fixtures/csv/embargo.csv'} ) }
end
let(:entry) do
Bulkrax::EntrySpecHelper.entry_for(identifier: '123456789',
data: data,
parser_class_name: 'Bulkrax::CsvParser',
parser_fields: { 'import_file_path': 'spec/fixtures/csv/embargo-lease.csv' })
end

it 'embargo attributes are included in the parsed metadata' do
entry.build_metadata
Expand All @@ -1285,25 +1287,27 @@ class ::Avacado < Work
end
end

describe 'exposing lease attributes for parser' do
let(:data) {
describe 'exposing lease attributes for parser' do
let(:data) do
{
'model': 'Work',
'title': 'Image',
'creator': 'user A',
'source_identifier': '123456789',
'visibility': 'lease',
'visibility_during_lease': 'restricted',
'lease_expiration_date': '2054-04-19',
'visibility_after_lease': 'open'
'model': 'Work',
'title': 'Image',
'creator': 'user A',
'source_identifier': '987654321',
'visibility': 'lease',
'visibility_during_lease': 'restricted',
'lease_expiration_date': '2054-04-19',
'visibility_after_lease': 'open'
}
}
let(:entry) { Bulkrax::EntrySpecHelper.entry_for(identifier: '123456789',
data: data,
parser_class_name: 'Bulkrax::CsvParser',
parser_fields: { 'import_file_path': 'spec/fixtures/csv/lease.csv'} ) }
end
let(:entry) do
Bulkrax::EntrySpecHelper.entry_for(identifier: '123456789',
data: data,
parser_class_name: 'Bulkrax::CsvParser',
parser_fields: { 'import_file_path': 'spec/fixtures/csv/embargo-lease.csv' })
end

it 'embargo attributes are included in the parsed metadata' do
it 'lease attributes are included in the parsed metadata' do
entry.build_metadata

expect(entry.parsed_metadata['visibility']).to eq('lease')
Expand Down

0 comments on commit 5148436

Please sign in to comment.