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

I1010 embargo lease support #950

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
6 changes: 6 additions & 0 deletions app/factories/bulkrax/object_factory_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def self.update_index_for_file_sets_of(resource:)
id
read_groups
visibility
visibility_during_embargo
embargo_release_date
visibility_after_embargo
visibility_during_lease
lease_expiration_date
visibility_after_lease
work_members_attributes
]

Expand Down
13 changes: 12 additions & 1 deletion app/models/concerns/bulkrax/has_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,18 @@ def multiple?(field)
end

def fields_that_are_always_multiple
%w[id delete model visibility]
@fields_that_are_always_multiple = %w[
id
delete
model
visibility
visibility_during_embargo
embargo_release_date
visibility_after_embargo
visibility_during_lease
lease_expiration_date
visibility_after_lease
]
end

def fields_that_are_always_singular
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
60 changes: 60 additions & 0 deletions spec/models/bulkrax/csv_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,66 @@ class ::Avacado < Work
end
end
end

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'
}
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

expect(entry.parsed_metadata['visibility']).to eq('embargo')
expect(entry.parsed_metadata['visibility_during_embargo']).to eq('restricted')
expect(entry.parsed_metadata['embargo_release_date']).to eq('2054-04-19')
expect(entry.parsed_metadata['visibility_after_embargo']).to eq('open')
end
end

describe 'exposing lease attributes for parser' do
let(:data) do
{
'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'
}
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 'lease attributes are included in the parsed metadata' do
entry.build_metadata

expect(entry.parsed_metadata['visibility']).to eq('lease')
expect(entry.parsed_metadata['visibility_during_lease']).to eq('restricted')
expect(entry.parsed_metadata['lease_expiration_date']).to eq('2054-04-19')
expect(entry.parsed_metadata['visibility_after_lease']).to eq('open')
end
end
end
end
# rubocop: enable Metrics/BlockLength
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
require 'bulkrax/entry_spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require 'simplecov'
SimpleCov.start
Expand Down
Loading