Skip to content

Commit

Permalink
Use case insensitive matching (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel authored Mar 14, 2024
1 parent fa0e961 commit 8ea7084
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/oclc/lc_call_slips/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def class_relevant_to_selector?(selector:)
def subject_relevant_to_selector?(selector:)
return false unless selector.subjects

subjects.any? { |subject| subject.downcase.match?(/#{selector.subjects.join('|')}/) }
subjects.any? { |subject| subject.match?(/#{selector.subjects.join('|')}/i) }
end

def author
Expand Down
22 changes: 22 additions & 0 deletions spec/models/oclc/lc_call_slips/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@
expect(oclc_record.relevant_to_selector?(selector:)).to eq(false)
end
end
context 'with capitalization in the config file subjects' do
let(:selector_config) do
{ hatfield: {
classes: [{ class: 'X', low_num: 0, high_num: 99_999 }],
subjects: ['Judaism']
} }
end
let(:fields) do
[
{ '650' => { "ind1" => "",
"ind2" => "0",
'subfields' => [
{ 'a' => 'Judaism' }
] } }
]
end

it 'uses case insensitive matching' do
expect(oclc_record.subject_relevant_to_selector?(selector:)).to eq(true)
expect(oclc_record.relevant_to_selector?(selector:)).to eq(true)
end
end
end

describe 'call number parsing' do
Expand Down

0 comments on commit 8ea7084

Please sign in to comment.