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

Hyacinth 2.6.x error messages #452

Merged
merged 2 commits into from
Dec 5, 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
5 changes: 3 additions & 2 deletions app/jobs/process_digital_object_import_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def self.find_or_create_digital_object(digital_object_data, user, digital_object
# We're updating data for an existing object
existing_object_for_update(digital_object_data, user)
else
new_object(digital_object_data['digital_object_type']['string_key'], user, digital_object_import)
digital_object_type = digital_object_data['digital_object_type']['string_key'] if digital_object_data['digital_object_type']
new_object(digital_object_type, user, digital_object_import)
end
end

Expand Down Expand Up @@ -109,7 +110,7 @@ def self.existing_object_for_update(digital_object_data, user)
end

def self.new_object(digital_object_type, user, digital_object_import)
digital_object = DigitalObjectType.get_model_for_string_key(digital_object_type).new
digital_object = DigitalObjectType.get_model_for_string_key(digital_object_type || :missing).new
digital_object.created_by = user
digital_object.updated_by = user
digital_object
Expand Down
12 changes: 12 additions & 0 deletions spec/jobs/process_digital_object_import_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
expect(klass).to receive(:new_object)
klass.find_or_create_digital_object(digital_object_data, user, digital_object_import)
end
context "no digital_object_type given for a new object" do
let(:digital_object) { klass.find_or_create_digital_object(digital_object_data, user, digital_object_import) }
let(:expected_message) { "Invalid DigitalObjectType string key: missing" }
before do
digital_object_data.delete('digital_object_type')
end

it "fails with a legible error" do
expect(digital_object).to be_nil
expect(digital_object_import.digital_object_errors).to include(expected_message)
end
end
end

describe ".handle_unexpected_processing_error" do
Expand Down
15 changes: 14 additions & 1 deletion spec/models/concerns/digital_object/publishing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,18 @@
end
end

describe '#execute_publish_action_for_target'
describe '#execute_publish_action_for_target' do
let(:pubtarget_pid) { 'pubtarget:c' }
let(:pubtarget) { instance_double(DigitalObject::PublishTarget, pid: pubtarget_pid) }
let(:success) { digital_object.execute_publish_action_for_target(:publish, pubtarget, true) }
context 'raises RestClient::ExceptionWithResponse with no response attribute' do
before do
allow(pubtarget).to receive(:publish_target_field).with('publish_url').and_return("http://localhost/publish")
allow(pubtarget).to receive(:publish_digital_object).and_raise(RestClient::ExceptionWithResponse)
end
it 'returns false' do
expect(success).to be false
end
end
end
end
Loading