Skip to content

Commit

Permalink
Merge pull request #890 from pulibrary/887-keywords-case
Browse files Browse the repository at this point in the history
Downcase keywords at save time
  • Loading branch information
tpendragon committed Apr 13, 2021
2 parents 1da47cb + aac5a52 commit 42892c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.8.2)
mimemagic (0.3.5)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
Expand Down Expand Up @@ -666,4 +668,4 @@ DEPENDENCIES
webpacker (>= 4.0.x)

BUNDLED WITH
2.1.4
2.2.6
1 change: 1 addition & 0 deletions app/values/manifest_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def transform_value(value)
return value["@id"] if value["@id"]
return link_to_catalog(value) if key == "Link to catalog" || key == "Link to finding aid"
return actors(value) if key == "Actor"
return value.downcase if key.casecmp("keywords").zero?

value
end
Expand Down
12 changes: 12 additions & 0 deletions spec/values/manifest_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
}
] }
end
let(:keywords_value) do
{
"keywords" => [
"Christianity",
"people's movement",
"liberation theology"
]
}
end

describe "#process_values" do
it "doesn't modify a plain value" do
Expand All @@ -46,5 +55,8 @@
it "uses @id as a last resort" do
expect(metadata.process_values(id_value)).to eq("Title" => ["1234"])
end
it "downcases keywords for consistent storage" do
expect(metadata.process_values(keywords_value)).to eq("keywords" => ["christianity", "people's movement", "liberation theology"])
end
end
end

0 comments on commit 42892c6

Please sign in to comment.