active-fedora 9.0.0.beta4 → 9.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 868c4057e2767f632105de888a5b5ca519ddf483
4
- data.tar.gz: a40dfbdc7a7e9047413c4cec194cbfa66969677d
3
+ metadata.gz: 17554700da06c7fc155b4336f11cc269e1114d42
4
+ data.tar.gz: 85dc2454b14e8a65334524debae01d56c690c712
5
5
  SHA512:
6
- metadata.gz: 9736c5cd63546aa1cf1d82119ab84d0376e6d06a8507026bce1c474ef340fb193149e352107ebbf6c215b74a110d095e2e126f0e95fa9186a3ba3b8143ac15f9
7
- data.tar.gz: 05a30a175532f659499d94d3362b18b89a025f2610aa462b0de0860b21b87690d9ba7c74a2fc153a0da574d0607b9aecba3074623a92438ed91e6b953fe98339
6
+ metadata.gz: 94d352731c92f119bc6b7ec521dcead14a68099588c840874dece0f38c27e47b29e45ee063bd010df1bf7624161b302b57d958ee29c7c66ec241eef8a8b4b7ce
7
+ data.tar.gz: 3cdf222ffa305dc0f452ddbfb8008a8a628ec7a222f969c52f043fd3ffc4506042a4c84f1908065b74c30d190ef1c18f2dae1bf9e0ba8c71197d023e4d68acb3
@@ -15,10 +15,13 @@ module ActiveFedora
15
15
  fields.each do |field_key, field_info|
16
16
  values = resource.get_values(field_key)
17
17
  Array(values).each do |val|
18
- if val.kind_of? ::RDF::URI
19
- val = val.to_s
20
- elsif val.kind_of? ActiveTriples::Resource
21
- val = val.solrize
18
+ val = case val
19
+ when ::RDF::URI, ActiveTriples::Term
20
+ val.to_s
21
+ when ActiveTriples::Resource
22
+ val.solrize
23
+ else
24
+ val
22
25
  end
23
26
  self.class.create_and_insert_terms(apply_prefix(field_key, opts[:name]), val, field_info[:behaviors], solr_doc)
24
27
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "9.0.0.beta4"
2
+ VERSION = "9.0.0.beta5"
3
3
  end
@@ -254,39 +254,6 @@ describe ActiveFedora::Base do
254
254
  end
255
255
  end
256
256
 
257
- describe ".to_solr" do
258
- it "should provide .to_solr" do
259
- expect(@test_object).to respond_to(:to_solr)
260
- end
261
-
262
- it "should add id, system_create_date, system_modified_date from object attributes" do
263
- expect(@test_object).to receive(:create_date).and_return(DateTime.parse("2012-03-04T03:12:02Z")).twice
264
- expect(@test_object).to receive(:modified_date).and_return(DateTime.parse("2012-03-07T03:12:02Z")).twice
265
- allow(@test_object).to receive(:id).and_return('changeme:123')
266
- solr_doc = @test_object.to_solr
267
- expect(solr_doc[ActiveFedora::SolrQueryBuilder.solr_name("system_create", :stored_sortable, type: :date)]).to eql("2012-03-04T03:12:02Z")
268
- expect(solr_doc[ActiveFedora::SolrQueryBuilder.solr_name("system_modified", :stored_sortable, type: :date)]).to eql("2012-03-07T03:12:02Z")
269
- expect(solr_doc[:id]).to eql("changeme:123")
270
- end
271
-
272
- it "should add self.class as the :active_fedora_model" do
273
- @test_history = FooHistory.new()
274
- solr_doc = @test_history.to_solr
275
- expect(solr_doc[ActiveFedora::SolrQueryBuilder.solr_name("active_fedora_model", :stored_sortable)]).to eql("FooHistory")
276
- end
277
-
278
- it "should call .to_solr on all datastreams, passing the resulting document to solr" do
279
- mock1 = double("ds1")
280
- expect(mock1).to receive(:to_solr).and_return({})
281
- mock2 = double("ds2")
282
- expect(mock2).to receive(:to_solr).and_return({})
283
-
284
- allow(@test_object).to receive(:attached_files).and_return(ds1: mock1, ds2: mock2)
285
- expect(@test_object.indexing_service).to receive(:solrize_relationships)
286
- @test_object.to_solr
287
- end
288
- end
289
-
290
257
  describe "update_attributes" do
291
258
  it "should set the attributes and save" do
292
259
  m = FooHistory.new
@@ -23,4 +23,56 @@ describe ActiveFedora::Indexing do
23
23
  it { should be true }
24
24
  end
25
25
  end
26
+
27
+ describe "#to_solr" do
28
+ before :all do
29
+ class SpecNode < ActiveFedora::Base
30
+ property :title, predicate: ::RDF::DC.title do |index|
31
+ index.as :stored_searchable
32
+ end
33
+ property :abstract, predicate: ::RDF::DC.abstract, multiple: false do |index|
34
+ index.as :stored_sortable
35
+ end
36
+ end
37
+ end
38
+ after :all do
39
+ Object.send(:remove_const, :SpecNode)
40
+ end
41
+
42
+ let(:test_object) { SpecNode.new(title: ['first title'], abstract: 'The abstract') }
43
+
44
+ subject { test_object.to_solr }
45
+
46
+ it "should index the rdf properties" do
47
+ expect(subject).to include('title_tesim' => ['first title'], 'abstract_ssi' => 'The abstract')
48
+ end
49
+
50
+ it "should add id, system_create_date, system_modified_date from object attributes" do
51
+ expect(test_object).to receive(:create_date).and_return(DateTime.parse("2012-03-04T03:12:02Z")).twice
52
+ expect(test_object).to receive(:modified_date).and_return(DateTime.parse("2012-03-07T03:12:02Z")).twice
53
+ allow(test_object).to receive(:id).and_return('changeme:123')
54
+ solr_doc = test_object.to_solr
55
+ expect(solr_doc[ActiveFedora::SolrQueryBuilder.solr_name("system_create", :stored_sortable, type: :date)]).to eql("2012-03-04T03:12:02Z")
56
+ expect(solr_doc[ActiveFedora::SolrQueryBuilder.solr_name("system_modified", :stored_sortable, type: :date)]).to eql("2012-03-07T03:12:02Z")
57
+ expect(solr_doc[:id]).to eql("changeme:123")
58
+ end
59
+
60
+ it "should add self.class as the :active_fedora_model" do
61
+ expect(subject[ActiveFedora::SolrQueryBuilder.solr_name("active_fedora_model", :stored_sortable)]).to eql "SpecNode"
62
+ end
63
+
64
+ context "with attached files" do
65
+ let(:mock1) { double("ds1") }
66
+ let(:mock2) { double("ds2") }
67
+
68
+ it "should call .to_solr on all datastreams, passing the resulting document to solr" do
69
+ expect(mock1).to receive(:to_solr).and_return("one" => "title one")
70
+ expect(mock2).to receive(:to_solr).and_return("two" => "title two")
71
+
72
+ allow(test_object).to receive(:attached_files).and_return(ds1: mock1, ds2: mock2)
73
+ expect(subject).to include('one' => 'title one', 'two' => 'title two')
74
+ end
75
+ end
76
+ end
77
+
26
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0.beta4
4
+ version: 9.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-05 00:00:00.000000000 Z
13
+ date: 2014-12-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr