Skip to content

Commit

Permalink
Consolidate Blacklight::Solr::Document::MoreLikeThis into Blacklight:…
Browse files Browse the repository at this point in the history
…:Solr::Document
  • Loading branch information
cbeer committed Sep 15, 2016
1 parent 77dd08e commit 50449aa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
7 changes: 4 additions & 3 deletions app/models/concerns/blacklight/solr/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#

module Blacklight::Solr::Document
autoload :MoreLikeThis, 'blacklight/solr/document/more_like_this'

extend ActiveSupport::Concern
include Blacklight::Document
include Blacklight::Document::ActiveModelShim
include Blacklight::Solr::Document::MoreLikeThis

def more_like_this
response.more_like(self).map { |doc| self.class.new(doc, response) }
end

def has_highlight_field? k
return false if response['highlighting'].blank? or response['highlighting'][self.id].blank?
Expand Down

This file was deleted.

18 changes: 0 additions & 18 deletions spec/models/blacklight/solr/document/more_like_this_spec.rb

This file was deleted.

13 changes: 12 additions & 1 deletion spec/models/blacklight/solr/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,16 @@ class MockDocument

end
end

describe '#more_like_this' do
let(:response) { instance_double(Blacklight::Solr::Response, :more_like => [{'id' => 'abc'}]) }
let(:document) { MockDocument.new({:id => '123'}, response) }
subject(:result) { document.more_like_this }

it "should pluck the MoreLikeThis results from the Solr Response" do
expect(result).to have(1).item
expect(result.first).to be_a_kind_of(MockDocument)
expect(result.first.id).to eq 'abc'
expect(result.first.solr_response).to eq response
end
end
end

0 comments on commit 50449aa

Please sign in to comment.