Skip to content

Commit

Permalink
Merge pull request #1056 from projecthydra/1054-persisted-solrhit
Browse files Browse the repository at this point in the history
SolrHit#instantiate_with_json should create persisted objects
  • Loading branch information
jcoyne committed Apr 19, 2016
2 parents 6ab76f7 + 7259e12 commit 90fdf6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/active_fedora/solr_hit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __setobj__(obj)
attr_reader :document

def initialize(document)
document = document.with_indifferent_access
super
@document = document
end
Expand Down
5 changes: 3 additions & 2 deletions spec/integration/solr_hit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class Foo < ActiveFedora::Base
title: 'My Title'
) }

let(:profile) { { "foo" => ["baz"], "bar" => "quix", "title" => "My Title" }.to_json }
let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
let(:doc) { obj.to_solr }
let(:solr_hit) { described_class.new(doc) }

after do
Expand All @@ -44,6 +43,8 @@ class Foo < ActiveFedora::Base
describe "#instantiate_with_json" do
subject { solr_hit.instantiate_with_json }

it { is_expected.to be_persisted }

it "finds the document in solr" do
expect(subject).to be_instance_of Foo
expect(subject.title).to eq 'My Title'
Expand Down

0 comments on commit 90fdf6e

Please sign in to comment.