diff --git a/app/models/qa/authorities/mesh.rb b/app/models/qa/authorities/mesh.rb new file mode 100644 index 0000000..d8f2d1b --- /dev/null +++ b/app/models/qa/authorities/mesh.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require Qa::Engine.root.join('lib', 'qa', 'authorities', 'mesh') + +module Qa + module Authorities + ## + # Monkeypatch the built in MESH authority to downcase terms. + # + # @see https://github.com/samvera/questioning_authority/issues/158 + class Mesh + def search(query) + Qa::SubjectMeshTerm + .where('term_lower LIKE ?', "#{query.to_s.downcase}%") + .limit(10) + .map { |t| { id: t.term_id, label: t.term } } + end + end + end +end diff --git a/spec/features/autocomplete_mesh_spec.rb b/spec/features/autocomplete_mesh_spec.rb index a70accc..8cfa317 100644 --- a/spec/features/autocomplete_mesh_spec.rb +++ b/spec/features/autocomplete_mesh_spec.rb @@ -25,7 +25,7 @@ click_on 'Additional fields' # Check that we get the correct autocompletion from QA - find('#etd_subject').send_keys 'sulfameraz' + find('#etd_subject').send_keys 'SuLFamerAZ' expect(page).to have_content('Sulfamerazine') # Fill out the rest of the form