Skip to content

Commit

Permalink
Add bugfix and test for LCSH from TCO-90
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-bernhardt committed Oct 4, 2024
1 parent f6ea1f5 commit 77626cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/detector/lcsh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def self.record(term)
results.identifiers.each_key do
Detection.find_or_create_by(
term:,
detector: Detector.where(name: 'LCSH').first
detector: Detector.where(name: 'LCSH').first,
detector_version: ENV.fetch('DETECTOR_VERSION', 'unset')
)
end

Expand Down
19 changes: 19 additions & 0 deletions test/models/detector/lcsh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,24 @@ class LcshTest < ActiveSupport::TestCase

assert_equal(detection_count, Detection.count)
end

test 'record respects changes to the DETECTOR_VERSION value' do
# Create a relevant detection
Detector::Lcsh.record(terms('lcsh'))

detection_count = Detection.count

# Calling the record method again doesn't do anything, but does not error.
Detector::Lcsh.record(terms('lcsh'))

assert_equal(detection_count, Detection.count)

# Calling the record method after DETECTOR_VERSION is incremented results in a new Detection
ClimateControl.modify DETECTOR_VERSION: 'updated' do
Detector::Lcsh.record(terms('lcsh'))

assert_equal detection_count + 1, Detection.count
end
end
end
end

0 comments on commit 77626cb

Please sign in to comment.