active-fedora 11.0.0.rc2 → 11.0.0.rc3

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: 4b833ffd608a93150c266715fe4a7407b4123226
4
- data.tar.gz: 3eb0722fd8dd81dba86b8de505859e464a321145
3
+ metadata.gz: 91cff7660db1a97bf4fd92375d6f2b541e94ee17
4
+ data.tar.gz: 736b7165e630f80196850c4c0c8128bae538ada1
5
5
  SHA512:
6
- metadata.gz: 6956d0ea72523e17d0ae7b856565f8abab7a20f9247e3fe6a410ec56c0227468a1aa242148cf10f91d6ca47279b798b04b203fb161a5b38b2ff0dd5e4879e310
7
- data.tar.gz: c9202017657e945638899468958d79205fc7cbe44e41b5638347a3363a61cd24e23d4e0b81ad8781faa9f0a48e3da30804f5d8453c62d1d2cbaaca8dec762dab
6
+ metadata.gz: 17b5eaec5db6609a76cc0d0f0dfbcdf27c0a704556f210f6fe3b90f60b6b99037513ab96ef8beccb241c8afef10edafee26bf079dff920abf7a388f0ecafc0f7
7
+ data.tar.gz: 8a7956065d01ec69e5093a447661c2bee8d443eb9385a37bb8140b21288bf41e8812118bb86981ca319acf7a7505a9e50b564ed844447224f61d2881edd5f561
@@ -25,12 +25,12 @@ module ActiveFedora
25
25
 
26
26
  def find_or_initialize_target(&block)
27
27
  if reflection.klass < ActiveFedora::File
28
- reflection.build_association(target_uri, &block)
28
+ reflection.build_association(id: target_uri, &block)
29
29
  else
30
30
  reflection.klass.find(target_uri)
31
31
  end
32
32
  rescue ActiveFedora::ObjectNotFoundError
33
- reflection.build_association(target_uri, &block)
33
+ reflection.build_association(id: target_uri, &block)
34
34
  end
35
35
 
36
36
  def replace(record)
@@ -48,7 +48,6 @@ module ActiveFedora
48
48
 
49
49
  def _assign_attribute(k, v)
50
50
  raise UnknownAttributeError.new(self, k) unless respond_to?("#{k}=")
51
-
52
51
  public_send("#{k}=", v)
53
52
  end
54
53
  end
@@ -22,7 +22,7 @@ module ActiveFedora
22
22
  def self.find_or_initialize(id)
23
23
  find(id)
24
24
  rescue ActiveFedora::ObjectNotFoundError
25
- new(id)
25
+ new(id: id)
26
26
  end
27
27
 
28
28
  private
@@ -22,14 +22,14 @@ module ActiveFedora
22
22
  # Also, if +attrs+ does not contain +:id+ but does contain +:namespace+ it will pass the
23
23
  # +:namespace+ value to Fedora::Repository.nextid to generate the next id available within
24
24
  # the given namespace.
25
- def initialize(attributes_or_id = nil, &_block)
25
+ def initialize(attributes = nil, &_block)
26
26
  init_internals
27
- attributes = initialize_attributes(attributes_or_id)
28
- @ldp_source = build_ldp_resource(attributes.delete(:id))
27
+ id = attributes && (attributes.delete(:id) || attributes.delete('id'))
28
+ @ldp_source = build_ldp_resource(id)
29
29
  raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
30
+ assign_attributes(attributes) if attributes
30
31
  assert_content_model
31
32
  load_attached_files
32
- assign_attributes(attributes) if attributes
33
33
 
34
34
  yield self if block_given?
35
35
  _run_initialize_callbacks
@@ -144,19 +144,5 @@ module ActiveFedora
144
144
  raise ActiveFedora::ObjectNotFoundError, "Can't reload an object that hasn't been saved"
145
145
  end
146
146
  end
147
-
148
- def initialize_attributes(attributes_or_id)
149
- case attributes_or_id
150
- when String
151
- attributes = { id: attributes_or_id }.with_indifferent_access
152
- when Hash
153
- attributes = attributes_or_id.with_indifferent_access
154
- when NilClass
155
- attributes = {}.with_indifferent_access
156
- else
157
- raise ArgumentError, "#{attributes_or_id.class} is not acceptable"
158
- end
159
- attributes
160
- end
161
147
  end
162
148
  end
@@ -30,7 +30,7 @@ module ActiveFedora
30
30
  # @yield [self] Yields self
31
31
  # @yieldparam [File] self the newly created file
32
32
  def initialize(identifier = nil, &_block)
33
- identifier = nil if identifier.is_a? Hash
33
+ identifier = identifier.delete(:id) if identifier.is_a? Hash
34
34
  run_callbacks(:initialize) do
35
35
  case identifier
36
36
  when nil, ::RDF::URI
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "11.0.0.rc2".freeze
2
+ VERSION = "11.0.0.rc3".freeze
3
3
  end
@@ -19,7 +19,7 @@ describe ActiveFedora::Base do
19
19
  end
20
20
  context "in a typical sitation" do
21
21
  specify "it cannot be reused" do
22
- expect { described_class.create(ghost) }.to raise_error(Ldp::Gone)
22
+ expect { described_class.create(id: ghost) }.to raise_error(Ldp::Gone)
23
23
  end
24
24
  end
25
25
  specify "remove its tombstone" do
@@ -138,7 +138,7 @@ EOF
138
138
  rdf_test.destroy
139
139
  end
140
140
 
141
- subject(:rdf_test) { RdfTest.new('/test:99') }
141
+ subject(:rdf_test) { RdfTest.new(id: '/test:99') }
142
142
 
143
143
  it "writes rdf with proper subjects" do
144
144
  rdf_test.reload
@@ -2,35 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::QueryResultBuilder do
4
4
  describe "#reify_solr_results" do
5
- before(:each) do
5
+ before do
6
6
  class FooObject < ActiveFedora::Base
7
7
  def self.id_namespace
8
8
  "foo"
9
9
  end
10
-
11
- has_subresource :descMetadata, class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
12
10
  end
13
- @test_object = ActiveFedora::Base.new
14
- @foo_object = FooObject.new
15
- attributes = { "language" => { 0 => "Italian" },
16
- "creator" => { 0 => "Linguist, A." },
17
- "geography" => { 0 => "Italy" },
18
- "title" => { 0 => "Italian and Spanish: A Comparison of Common Phrases" } }
19
- @foo_object.descMetadata.update_indexed_attributes(attributes)
20
- @test_object.save
21
- @foo_object.save
22
- @profiles = {
23
- # 'test' => @test_object.profile,
24
- # 'foo' => @foo_object.profile,
25
- # 'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
26
- }
27
- @foo_content = @foo_object.attached_files['descMetadata'].content
28
11
  end
12
+
13
+ let(:test_object) { ActiveFedora::Base.create }
14
+ let(:foo_object) { FooObject.create }
15
+
29
16
  after(:each) do
30
17
  Object.send(:remove_const, :FooObject)
31
18
  end
19
+
32
20
  it "returns an array of objects that are of the class stored in active_fedora_model_s" do
33
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@test_object.id, @foo_object.id])
21
+ query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([test_object.id, foo_object.id])
34
22
  solr_result = ActiveFedora::SolrService.query(query)
35
23
  result = described_class.reify_solr_results(solr_result)
36
24
  expect(result.length).to eq 2
@@ -40,7 +28,7 @@ describe ActiveFedora::QueryResultBuilder do
40
28
  end
41
29
 
42
30
  it '#reifies a lightweight object as a new instance' do
43
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@foo_object.id])
31
+ query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([foo_object.id])
44
32
  solr_result = ActiveFedora::SolrService.query(query)
45
33
  result = described_class.reify_solr_results(solr_result, load_from_solr: true)
46
34
  expect(result.first).to be_instance_of FooObject
@@ -133,21 +133,13 @@ describe ActiveFedora::Base do
133
133
  before do
134
134
  allow_any_instance_of(FooHistory).to receive(:assign_id).and_return(@this_id)
135
135
  end
136
+
136
137
  context "with no arguments" do
137
138
  it "does not get an id on init" do
138
139
  expect(FooHistory.new.id).to be_nil
139
140
  end
140
141
  end
141
142
 
142
- context "with an id argument" do
143
- it "is able to create with a custom id" do
144
- expect(FooHistory).to receive(:id_to_uri).and_call_original
145
- f = FooHistory.new('baz_1')
146
- expect(f.id).to eq 'baz_1'
147
- expect(f.id).to eq 'baz_1'
148
- end
149
- end
150
-
151
143
  context "with a hash argument" do
152
144
  context "that has an id" do
153
145
  it "is able to create with a custom id" do
@@ -18,7 +18,8 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
18
18
  Object.send(:remove_const, :Book)
19
19
  Object.send(:remove_const, :Page)
20
20
  end
21
- subject(:book) { Book.new('subject-a') }
21
+
22
+ subject(:book) { Book.new(id: 'subject-a') }
22
23
 
23
24
  context "a one way relationship " do
24
25
  describe "adding memeber" do
@@ -12,8 +12,8 @@ describe ActiveFedora::Associations::HasManyAssociation do
12
12
  Object.send(:remove_const, :Book)
13
13
  Object.send(:remove_const, :Page)
14
14
  end
15
- let(:book) { Book.new('subject-a') }
16
- let(:page) { Page.new('object-b') }
15
+ let(:book) { Book.new(id: 'subject-a') }
16
+ let(:page) { Page.new(id: 'object-b') }
17
17
 
18
18
  describe "setting the foreign key" do
19
19
  before do
@@ -35,7 +35,7 @@ RSpec.describe ActiveFedora::Orders::ListNode do
35
35
  end
36
36
  context "and it doesn't exist" do
37
37
  it "returns an AT::Resource" do
38
- member = Member.new("testing")
38
+ member = Member.new(id: "testing")
39
39
  graph << [rdf_subject, RDF::Vocab::ORE.proxyFor, member.resource.rdf_subject]
40
40
  expect(list_node.target.rdf_subject).to eq member.uri
41
41
  end
@@ -128,9 +128,9 @@ describe ActiveFedora::Base do
128
128
  .and_return('response' => { 'docs' => mock_docs })
129
129
 
130
130
  allow(relation).to receive(:load_from_fedora).with("changeme-30", nil)
131
- .and_return(SpecModel::Basic.new('changeme-30'))
131
+ .and_return(SpecModel::Basic.new(id: 'changeme-30'))
132
132
  allow(relation).to receive(:load_from_fedora).with("changeme-22", nil)
133
- .and_return(SpecModel::Basic.new('changeme-22'))
133
+ .and_return(SpecModel::Basic.new(id: 'changeme-22'))
134
134
  SpecModel::Basic.find_each { |obj| obj.class == SpecModel::Basic }
135
135
  end
136
136
 
@@ -144,8 +144,8 @@ describe ActiveFedora::Base do
144
144
  let(:mock_docs) { [{ "id" => "changeme-30" }, { "id" => "changeme-22" }] }
145
145
 
146
146
  it "filters by the provided fields" do
147
- expect(relation).to receive(:load_from_fedora).with("changeme-30", nil).and_return(SpecModel::Basic.new('changeme-30'))
148
- expect(relation).to receive(:load_from_fedora).with("changeme-22", nil).and_return(SpecModel::Basic.new('changeme-22'))
147
+ expect(relation).to receive(:load_from_fedora).with("changeme-30", nil).and_return(SpecModel::Basic.new(id: 'changeme-30'))
148
+ expect(relation).to receive(:load_from_fedora).with("changeme-22", nil).and_return(SpecModel::Basic.new(id: 'changeme-22'))
149
149
 
150
150
  expect(mock_docs).to receive(:has_next?).and_return(false)
151
151
  expect(solr).to receive(:paginate).with(1, 1000, 'select', expected_params).and_return('response' => { 'docs' => mock_docs })
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: 11.0.0.rc2
4
+ version: 11.0.0.rc3
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: 2016-08-09 00:00:00.000000000 Z
13
+ date: 2016-08-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr