Skip to content

Commit

Permalink
Merge pull request #5859 from avalonmediasystem/more_json
Browse files Browse the repository at this point in the history
Don't titlize for matching since resource type isn't titlized in the index anymore
  • Loading branch information
cjcolvar authored Jun 11, 2024
2 parents aaef4ce + f6f095d commit c50c120
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ def lti_share_url_for(obj, _opts = {})
user_omniauth_callback_lti_url(target_id: target)
end

# TODO: Fix me with latest changes from 5.1.4
def image_for(document)
master_file_id = document["section_id_ssim"].try :first

video_count = document["avalon_resource_type_ssim"].count{|m| m.start_with?('moving image'.titleize) } rescue 0
audio_count = document["avalon_resource_type_ssim"].count{|m| m.start_with?('sound recording'.titleize) } rescue 0
video_count = document["avalon_resource_type_ssim"].count{|m| m.start_with?('moving image') } rescue 0
audio_count = document["avalon_resource_type_ssim"].count{|m| m.start_with?('sound recording') } rescue 0

if master_file_id
if video_count > 0
Expand Down
8 changes: 4 additions & 4 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,23 @@
expect(helper.image_for(doc)).to eq(nil)
end
it "should return audio icon" do
doc = {"avalon_resource_type_ssim" => ['Sound Recording', 'Sound Recording'] }
doc = {"avalon_resource_type_ssim" => ['sound recording', 'sound recording'] }
expect(helper.image_for(doc).start_with?("#{root_url}assets/audio_icon")).to be_truthy
end
it "should return video icon" do
doc = {"avalon_resource_type_ssim" => ['Moving Image'] }
doc = {"avalon_resource_type_ssim" => ['moving image'] }
expect(helper.image_for(doc).start_with?("#{root_url}assets/video_icon")).to be_truthy
end
it "should return hybrid icon" do
doc = {"avalon_resource_type_ssim" => ['Moving Image', 'Sound Recording'] }
doc = {"avalon_resource_type_ssim" => ['moving image', 'sound recording'] }
expect(helper.image_for(doc).start_with?("#{root_url}assets/hybrid_icon")).to be_truthy
end
it "should return nil when only unprocessed video" do
doc = {"section_id_ssim" => ['1'], "avalon_resource_type_ssim" => [] }
expect(helper.image_for(doc)).to eq(nil)
end
it "should return thumbnail" do
doc = {"section_id_ssim" => ['1'], "avalon_resource_type_ssim" => ['Moving Image'] }
doc = {"section_id_ssim" => ['1'], "avalon_resource_type_ssim" => ['moving image'] }
expect(helper.image_for(doc)).to eq('/master_files/1/thumbnail')
end
end
Expand Down

0 comments on commit c50c120

Please sign in to comment.