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

Fixes Wings migration of based_near attribute in to_resource #6922

Merged
merged 8 commits into from
Oct 16, 2024
Merged
6 changes: 5 additions & 1 deletion lib/wings/transformer_value_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ def self.handles?(value)
end

##
# @return [RDF::Term]
# Valkyrie objects contain a URI string for location objects so we need
# to return just the string for mapping from Fedora
#
# @return [RDF::Term || String]
def result
return value.id if value.is_a?(Hyrax::ControlledVocabularies::Location)
value.to_term
end
end
Expand Down
15 changes: 11 additions & 4 deletions spec/wings/attribute_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
require 'wings/attribute_transformer'

RSpec.describe Wings::AttributeTransformer, :active_fedora do
let(:id) { 'moomin123' }
let(:id) { 'moomin123' }
let(:based_near) { Hyrax::ControlledVocabularies::Location.new("https://sws.geonames.org/4920808/") }
let(:work) { GenericWork.new(id: id, **attributes) }

let(:attributes) do
{
title: ['fake title', 'fake title 2'],
contributor: ['user1'],
description: ['a description']
description: ['a description'],
based_near: [based_near]
}
end

it "transform the attributes" do
expect(described_class.run(work))
it "transforms the attributes" do
converted_work = described_class.run(work)
expect(converted_work)
.to include title: work.title,
contributor: work.contributor.first,
description: work.description.first
# ensure that based_near is converted from RDF::URI to URI string during valkyrization
converted_based_near = Array.wrap(converted_work[:based_near]).first
expect(converted_based_near).to be_a(String)
expect(converted_based_near).to eq(work.based_near.first.id)
end
end
Loading