@work = Factory.create(:work, :title_primary => 'Work Title 1', :abstract => 'The abstract of my work.',
:volume => '1')
name_string = Factory.create(:name_string, :name => 'Name String Name')
Factory.create(:work_name_string, :work => @work, :name_string => name_string)
# Create a second work with the same values
@work2 = Factory.create(:work, :title_primary => @work[:title_primary], :abstract => @work[:abstract],
:volume => @work[:volume])
@work2.name_strings = @work.name_strings
# Set duplicate state manually
@work.work_state_id = Work::STATE_DUPLICATE
@work2.work_state_id = Work::STATE_DUPLICATE
@work.save
@work2.save
# Retrieve duplicate matches using a query similar to the methods in index.rb. This returns duplicates as expected.
Index.fetch("title:#{@work[:title_primary]} AND (#{Work.solr_duplicate_filter})",[],"year","descending",0,0,10).size.should be > 1
# possible_accepted_duplicates method in index.rb. This passes, i.e. no matches. I'd expect that... I think.
Index.possible_accepted_duplicates(@work).size.should eq 0
# possible_unaccepted_duplicates method in index.rb This fails, i.e. still no matches. I wouldn't expect that; I'd expect at least 2 works to be found here.
Index.possible_unaccepted_duplicate_works(@work).size.should be > 1