@@ -301,4 +301,32 @@ class RecordHelperTest < ActionView::TestCase
301301 locations = [ ]
302302 assert_not geospatial_coordinates? ( locations )
303303 end
304+
305+ test 'deduplicate_subjects returns only unique subjects' do
306+ # within the same subject
307+ duplicative_subject = [ { 'kind' => 'foo' , 'value' => [ 'bar' , 'bar' , 'baz' ] } ]
308+ assert_equal [ [ 'bar' , 'baz' ] ] , deduplicate_subjects ( duplicative_subject )
309+
310+ # across multiple subjects
311+ multiple_duplicative_subjects = [ { 'kind' => 'foo' , 'value' => [ 'bar' ] } ,
312+ { 'kind' => 'baz' , 'value' => [ 'bar' ] } ]
313+ assert_equal [ [ 'bar' ] ] , deduplicate_subjects ( multiple_duplicative_subjects )
314+ end
315+
316+ test 'deduplicate_subjects ignores case' do
317+ # within the same subject
318+ duplicative_subject = [ { 'kind' => 'foo' , 'value' => [ 'Bar' , 'BAR' , 'bar' ] } ]
319+ assert_equal [ [ 'Bar' ] ] , deduplicate_subjects ( duplicative_subject )
320+
321+ # across multiple subjects
322+ multiple_duplicative_subjects = [ { 'kind' => 'foo' , 'value' => [ 'Bar' ] } ,
323+ { 'kind' => 'foo' , 'value' => [ 'BAR' ] } ,
324+ { 'kind' => 'foo' , 'value' => [ 'bar' ] } ]
325+ assert_equal [ [ 'Bar' ] ] , deduplicate_subjects ( multiple_duplicative_subjects )
326+ end
327+
328+ test 'deduplicate_subjects returns nothing if subjects are not present' do
329+ subjects = [ ]
330+ assert_nil deduplicate_subjects ( subjects )
331+ end
304332end
0 commit comments