active-fedora 7.0.1 → 7.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module ActiveFedora
19
19
  # belongs_to :publisher, :property=>:has_member
20
20
  results = SolrService.query(ActiveFedora::SolrService.construct_query_for_pids(ids))
21
21
  results.each do |result|
22
- return result['id'] if SolrService.class_from_solr_document(result) == klass
22
+ return result['id'] if SolrService.classes_from_solr_document(result).include? klass
23
23
  end
24
24
  return nil
25
25
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  module ActiveFedora
2
3
  module Associations
3
4
  # Association proxies in Active Fedora are middlemen between the object that
@@ -49,6 +50,10 @@ module ActiveFedora
49
50
  @association.load_target
50
51
  end
51
52
 
53
+ def load_from_solr(opts = Hash.new)
54
+ @association.load_from_solr(opts)
55
+ end
56
+
52
57
  def loaded?
53
58
  @association.loaded?
54
59
  end
@@ -23,7 +23,7 @@ module ActiveFedora
23
23
  # If there's nothing in the database and @target has no new records
24
24
  # we are certain the current target is an empty array. This is a
25
25
  # documented side-effect of the method that may avoid an extra SELECT.
26
- @target ||= [] and loaded if count == 0
26
+ @target ||= [] and loaded! if count == 0
27
27
 
28
28
  return count
29
29
  end
@@ -56,9 +56,12 @@ module ActiveFedora
56
56
 
57
57
  args.merge!({:mimeType=>args[:mime_type]}) if args.has_key?(:mime_type)
58
58
 
59
- unless class_named_datastreams_desc[args[:name]].has_key?(:type)
59
+ unless args.has_key?(:type)
60
60
  #default to type ActiveFedora::Datastream
61
- args.merge!({:type => "ActiveFedora::Datastream"})
61
+ args[:type] = "ActiveFedora::Datastream"
62
+ else
63
+ # stringify class/model names
64
+ args[:type] = args[:type].name if args[:type].is_a? Class
62
65
  end
63
66
  class_named_datastreams_desc[args[:name]]= args
64
67
  create_named_datastream_finders(args[:name],args[:prefix])
@@ -44,7 +44,11 @@ module ActiveFedora::Rdf::Identifiable
44
44
  # @see ActiveFedora::Rdf::Resource.from_uri
45
45
  # @param [RDF::URI] uri URI that is being looked up.
46
46
  def from_uri(uri,_)
47
- self.find(pid_from_subject(uri))
47
+ begin
48
+ self.find(pid_from_subject(uri))
49
+ rescue ActiveFedora::ObjectNotFoundError
50
+ self.ds_specs[resource_datastream.to_s][:type].resource_class.new(uri)
51
+ end
48
52
  end
49
53
 
50
54
  ##
@@ -103,6 +103,7 @@ module ActiveFedora::Rdf
103
103
  klass = properties[key[0..-12]]['class_name']
104
104
  klass = ActiveFedora.class_from_string(klass, final_parent.class) if klass.is_a? String
105
105
  value.is_a?(Hash) ? attributes_hash_to_list(values[key], klass) : attributes_to_list(value, klass)
106
+ values.delete key
106
107
  end
107
108
  end
108
109
  persist!
@@ -11,6 +11,21 @@ module ActiveFedora
11
11
  raise ArgumentError, "Invalid arguments for Rdf Node configuration: #{args} on #{predicate}" unless args.empty?
12
12
  end
13
13
 
14
+ def [](value)
15
+ value = value.to_sym
16
+ self.respond_to?(value) ? self.send(value) : nil
17
+ end
18
+
19
+ def class_name
20
+ if @class_name.kind_of?(String)
21
+ begin
22
+ new_class = @class_name.constantize
23
+ @class_name = new_class
24
+ rescue NameError
25
+ end
26
+ end
27
+ @class_name
28
+ end
14
29
 
15
30
  def with_index (&block)
16
31
  # needed for solrizer integration
@@ -17,7 +17,7 @@ module ActiveFedora::Rdf
17
17
  # You can pass a block to either to set index behavior.
18
18
  module Properties
19
19
  extend Deprecation
20
- attr_accessor :properties
20
+ attr_accessor :config
21
21
 
22
22
  ##
23
23
  # Registers properties for Resource-like classes
@@ -25,38 +25,24 @@ module ActiveFedora::Rdf
25
25
  # @param [Hash] opts for this property, must include a :predicate
26
26
  # @yield [index] index sets solr behaviors for the property
27
27
  def property(name, opts={}, &block)
28
- config[name] = ActiveFedora::Rdf::NodeConfig.new(name, opts[:predicate], opts.except(:predicate)).tap do |config|
28
+ self.config[name] = ActiveFedora::Rdf::NodeConfig.new(name, opts[:predicate], opts.except(:predicate)).tap do |config|
29
29
  config.with_index(&block) if block_given?
30
30
  end
31
31
  behaviors = config[name].behaviors.flatten if config[name].behaviors and not config[name].behaviors.empty?
32
-
33
- self.properties[name] = {
34
- behaviors: behaviors,
35
- type: config[name].type,
36
- class_name: config[name].class_name,
37
- predicate: config[name].predicate,
38
- term: config[name].term,
39
- multivalue: config[name].multivalue
40
- }
41
32
  register_property(name)
42
33
  end
43
34
 
44
- def properties
45
- @properties ||= if superclass.respond_to? :properties
46
- superclass.properties.dup
47
- else
48
- {}.with_indifferent_access
49
- end
50
- end
51
-
52
35
  def config
53
36
  @config ||= if superclass.respond_to? :config
54
- superclass.properties.dup
37
+ superclass.config.dup
55
38
  else
56
39
  {}.with_indifferent_access
57
40
  end
58
41
  end
59
42
 
43
+ alias_method :properties, :config
44
+ alias_method :properties=, :config=
45
+
60
46
  def config_for_term_or_uri(term)
61
47
  return config[term.to_sym] unless term.kind_of? RDF::Resource
62
48
  config.each { |k, v| return v if v.predicate == term.to_uri }
@@ -33,14 +33,14 @@ module ActiveFedora
33
33
  def metadata?
34
34
  true
35
35
  end
36
-
36
+
37
37
  def content
38
38
  serialize
39
39
  end
40
40
 
41
41
  def content=(content)
42
42
  resource.clear!
43
- resource << RDF::Reader.for(serialization_format).new(content)
43
+ resource << deserialize(content)
44
44
  content
45
45
  end
46
46
 
@@ -62,14 +62,14 @@ module ActiveFedora
62
62
  # set_value, get_value, and property accessors are delegated to this object.
63
63
  def resource
64
64
  @resource ||= begin
65
- r = self.class.resource_class.new(digital_object ? self.class.rdf_subject.call(self) : nil)
65
+ r = self.singleton_class.resource_class.new(digital_object ? self.class.rdf_subject.call(self) : nil)
66
66
  r.singleton_class.properties = self.class.properties
67
67
  r.singleton_class.properties.keys.each do |property|
68
68
  r.singleton_class.send(:register_property, property)
69
69
  end
70
70
  r.datastream = self
71
71
  r.singleton_class.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?
72
- r << RDF::Reader.for(serialization_format).new(datastream_content) if datastream_content
72
+ r << deserialize
73
73
  r
74
74
  end
75
75
  end
@@ -101,6 +101,10 @@ module ActiveFedora
101
101
  def deserialize(data=nil)
102
102
  return RDF::Graph.new if new? && data.nil?
103
103
  data ||= datastream_content
104
+
105
+ # Because datastream_content can return nil, we should check that here.
106
+ return repository if data.nil?
107
+
104
108
  data.force_encoding('utf-8')
105
109
  RDF::Graph.new << RDF::Reader.for(serialization_format).new(data)
106
110
  end
@@ -77,11 +77,15 @@ module ActiveFedora::Rdf
77
77
 
78
78
  def attributes=(values)
79
79
  raise ArgumentError, "values must be a Hash, you provided #{values.class}" unless values.kind_of? Hash
80
- values.with_indifferent_access.each do |key, value|
81
- if self.singleton_class.properties.keys.include?(key)
80
+ values = values.with_indifferent_access
81
+ set_subject!(values.delete(:id)) if values.has_key?(:id) and node?
82
+ values.each do |key, value|
83
+ if properties.keys.include?(key)
82
84
  set_value(rdf_subject, key, value)
83
85
  elsif self.singleton_class.nested_attributes_options.keys.map{ |k| "#{k}_attributes"}.include?(key)
84
86
  send("#{key}=".to_sym, value)
87
+ else
88
+ raise ArgumentError, "No association found for name `#{key}'. Has it been defined yet?"
85
89
  end
86
90
  end
87
91
  end
@@ -318,7 +322,7 @@ module ActiveFedora::Rdf
318
322
  return RDF::Node(uri_or_str[2..-1]) if uri_or_str.start_with? '_:'
319
323
  return RDF::URI(uri_or_str) if RDF::URI(uri_or_str).valid? and (URI.scheme_list.include?(RDF::URI.new(uri_or_str).scheme.upcase) or RDF::URI.new(uri_or_str).scheme == 'info')
320
324
  return RDF::URI(self.base_uri.to_s + (self.base_uri.to_s[-1,1] =~ /(\/|#)/ ? '' : '/') + uri_or_str) if base_uri && !uri_or_str.start_with?(base_uri.to_s)
321
- raise RuntimeError "could not make a valid RDF::URI from #{uri_or_str}"
325
+ raise RuntimeError, "could not make a valid RDF::URI from #{uri_or_str}"
322
326
  end
323
327
  end
324
328
  end
@@ -55,7 +55,18 @@ module ActiveFedora
55
55
  klass.find(hit[SOLR_DOCUMENT_ID], cast: true)
56
56
  end
57
57
  end
58
-
58
+
59
+ #Returns all possible classes for the solr object
60
+ def classes_from_solr_document(hit, opts = {})
61
+ #Add ActiveFedora::Base as never stored in Solr explicitely.
62
+ classes = [ActiveFedora::Base]
63
+
64
+ hit[HAS_MODEL_SOLR_FIELD].each { |value| classes << Model.from_class_uri(value) }
65
+
66
+ classes
67
+ end
68
+
69
+ #Returns the best singular class for the solr object
59
70
  def class_from_solr_document(hit, opts = {})
60
71
  #Set the default starting point to the class specified, if available.
61
72
  best_model_match = Model.from_class_uri(opts[:class]) unless opts[:class].nil?
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "7.0.1"
3
- end
2
+ VERSION = "7.0.2"
3
+ end
@@ -105,9 +105,9 @@ describe ActiveFedora::Base do
105
105
 
106
106
  it "should let you shift onto the association" do
107
107
  @library.new_record?.should be_true
108
- @library.books.size == 0
108
+ @library.books.size.should == 0
109
109
  @library.books.should == []
110
- @library.book_ids.should ==[]
110
+ @library.book_ids.should == []
111
111
  @library.books << @book
112
112
  @library.books.should == [@book]
113
113
  @library.book_ids.should ==[@book.pid]
@@ -76,7 +76,7 @@ describe ActiveFedora::Base do
76
76
  end
77
77
  end
78
78
 
79
- describe "casting inheritance additional test cases" do
79
+ describe "casting inheritance detailed test cases" do
80
80
  before :all do
81
81
  class SimpleObject < ActiveFedora::Base
82
82
  belongs_to :simple_collection, property: :is_part_of, class_name: 'SimpleCollection'
@@ -109,15 +109,18 @@ describe ActiveFedora::Base do
109
109
 
110
110
  @simple_object = SimpleObject.create
111
111
  @simple_object_second = SimpleObject.create
112
+ @simple_object_third = SimpleObject.create
112
113
  @complex_object = ComplexObject.create
114
+ @complex_object_second = ComplexObject.create
113
115
 
114
116
  #Need to add the simpler cmodel here as currently inheritance support is read-only.
115
117
  #See ActiveFedora pull request 207 on how to do this programmatically.
116
118
  @complex_object.add_relationship(:has_model, @complex_object.class.superclass.to_class_uri)
119
+ @complex_collection.add_relationship(:has_model, @complex_collection.class.superclass.to_class_uri)
117
120
 
118
121
  @simple_collection.objects = [@simple_object, @simple_object_second, @complex_object]
119
122
  @simple_collection.save!
120
- @complex_collection.objects = [@simple_object, @complex_object]
123
+ @complex_collection.objects = [@simple_object_third, @complex_object_second]
121
124
  @complex_collection.save!
122
125
  @complex_object.save!
123
126
  @simple_object.save!
@@ -126,32 +129,41 @@ describe ActiveFedora::Base do
126
129
 
127
130
 
128
131
  it "casted association methods should work and return the most complex class" do
132
+
129
133
  @complex_object.simple_collection.should be_instance_of SimpleCollection
130
- @complex_object.complex_collection.should be_instance_of ComplexCollection
134
+ @complex_object.complex_collection.should be_nil
135
+
136
+ @complex_object_second.simple_collection.should be_instance_of ComplexCollection
137
+ @complex_object_second.complex_collection.should be_instance_of ComplexCollection
131
138
 
132
139
  @simple_object.simple_collection.should be_instance_of SimpleCollection
133
- @simple_object.complex_collection.should be_instance_of ComplexCollection
140
+ @simple_object.complex_collection.should be_nil
141
+
134
142
  @simple_object_second.simple_collection.should be_instance_of SimpleCollection
135
143
  @simple_object_second.complex_collection.should be_nil
136
144
 
137
- @complex_collection.objects[0].should be_instance_of SimpleObject
138
- @complex_collection.objects[1].should be_instance_of ComplexObject
145
+ @simple_object_third.simple_collection.should be_instance_of ComplexCollection
146
+ @simple_object_third.complex_collection.should be_instance_of ComplexCollection
139
147
 
148
+ @simple_collection.objects.size.should == 3
140
149
  @simple_collection.objects[0].should be_instance_of SimpleObject
141
150
  @simple_collection.objects[1].should be_instance_of SimpleObject
142
151
  @simple_collection.objects[2].should be_instance_of ComplexObject
143
152
 
153
+ @complex_collection.objects.size.should == 2
154
+ @complex_collection.objects[0].should be_instance_of SimpleObject
155
+ @complex_collection.objects[1].should be_instance_of ComplexObject
156
+
144
157
  end
145
158
 
146
159
  it "specified ending relationships should ignore classes not specified" do
147
- @complex_collection.complex_objects.count.should == 1
148
- @complex_collection.complex_objects[0].should be_instance_of ComplexObject
149
- @complex_collection.complex_objects[1].should be_nil
150
-
151
- @simple_collection.complex_objects.count.should == 1
160
+ @simple_collection.complex_objects.size.should == 1
152
161
  @simple_collection.complex_objects[0].should be_instance_of ComplexObject
153
162
  @simple_collection.complex_objects[1].should be_nil
154
163
 
164
+ @complex_collection.complex_objects.size.should == 1
165
+ @complex_collection.complex_objects[0].should be_instance_of ComplexObject
166
+ @complex_collection.complex_objects[1].should be_nil
155
167
  end
156
168
 
157
169
  after do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Looking up collection members" do
3
+ describe "Collection members" do
4
4
  before :all do
5
5
  class Library < ActiveFedora::Base
6
6
  has_many :books
@@ -14,7 +14,17 @@ describe "Looking up collection members" do
14
14
  Object.send(:remove_const, :Book)
15
15
  Object.send(:remove_const, :Library)
16
16
  end
17
- describe "of has_many" do
17
+ describe "size of has_many" do
18
+ let(:library) { Library.create }
19
+ context "when no members" do
20
+ it "should cache the count" do
21
+ expect(library.books).not_to be_loaded
22
+ expect(library.books.size).to eq(0)
23
+ expect(library.books).to be_loaded
24
+ end
25
+ end
26
+ end
27
+ describe "looking up has_many" do
18
28
  let(:book) { Book.create }
19
29
  let(:library) { Library.create() }
20
30
  before do
@@ -34,6 +44,12 @@ describe "Looking up collection members" do
34
44
  expect(library.books).to eq [book]
35
45
  expect(library.books.loaded?).to be_true
36
46
  end
47
+ it "should load from solr" do
48
+ expect(library.books.load_from_solr.map {|r| r["id"]}).to eq([book.pid])
49
+ end
50
+ it "should load from solr with options" do
51
+ expect(library.books.load_from_solr(rows: 0).size).to eq(0)
52
+ end
37
53
  end
38
54
  end
39
55
 
@@ -69,7 +69,10 @@ describe "Nesting attribute behavior of RDFDatastream" do
69
69
  '0' =>
70
70
  {
71
71
  elementList_attributes: [{
72
- topicElement_attributes: [{elementValue:"Cosmology"}]
72
+ topicElement_attributes: [{
73
+ id: 'http://library.ucsd.edu/ark:/20775/bb3333333x',
74
+ elementValue:"Cosmology"
75
+ }]
73
76
  }]
74
77
  },
75
78
  '1' =>
@@ -81,7 +84,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
81
84
  },
82
85
  personalName_attributes: [
83
86
  {
84
- elementList_attributes: [{
87
+ id: 'http://library.ucsd.edu/ark:20775/jefferson',
88
+ elementList_attributes: [{
85
89
  fullNameElement: "Jefferson, Thomas",
86
90
  dateNameElement: "1743-1826"
87
91
  }]
@@ -107,22 +111,33 @@ describe "Nesting attribute behavior of RDFDatastream" do
107
111
  end
108
112
  end
109
113
 
110
- it "should create nested objects" do
111
- # Replace the graph's contents with the Hash
112
- subject.attributes = params[:myResource]
113
-
114
- # Here's how this would happen if we didn't have attributes=
115
- # personal_name = subject.personalName.build
116
- # elem_list = personal_name.elementList.build
117
- # elem_list.fullNameElement = "Jefferson, Thomas"
118
- # elem_list.dateNameElement = "1743-1826"
119
- # topic = subject.topic.build
120
- # elem_list = topic.elementList.build
121
- # elem_list.fullNameElement = 'Cosmology'
122
- subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
123
- subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
124
- subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
125
- subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
114
+ context "from nested objects" do
115
+ before do
116
+ # Replace the graph's contents with the Hash
117
+ subject.attributes = params[:myResource]
118
+ end
119
+
120
+ it 'should have attributes' do
121
+ subject.topic[0].elementList.first[0].elementValue.should == ["Cosmology"]
122
+ subject.topic[1].elementList.first[0].elementValue.should == ["Quantum Behavior"]
123
+ subject.personalName.first.elementList.first.fullNameElement.should == ["Jefferson, Thomas"]
124
+ subject.personalName.first.elementList.first.dateNameElement.should == ["1743-1826"]
125
+ end
126
+
127
+ it 'should build nodes with ids' do
128
+ expect(subject.topic[0].elementList.first[0].rdf_subject).to eq 'http://library.ucsd.edu/ark:/20775/bb3333333x'
129
+ expect(subject.personalName.first.rdf_subject).to eq 'http://library.ucsd.edu/ark:20775/jefferson'
130
+ end
131
+
132
+ it 'should fail when writing to a non-predicate' do
133
+ attributes = { topic_attributes: { '0' => { elementList_attributes: [{ topicElement_attributes: [{ fake_predicate:"Cosmology" }] }]}}}
134
+ expect{ subject.attributes = attributes }.to raise_error ArgumentError
135
+ end
136
+
137
+ it 'should fail when writing to a non-predicate with a setter method' do
138
+ attributes = { topic_attributes: { '0' => { elementList_attributes: [{ topicElement_attributes: [{ name:"Cosmology" }] }]}}}
139
+ expect{ subject.attributes = attributes }.to raise_error ArgumentError
140
+ end
126
141
  end
127
142
  end
128
143
 
@@ -149,9 +149,10 @@ describe ActiveFedora::DatastreamCollections do
149
149
 
150
150
  describe '#add_named_file_datastream' do
151
151
  before do
152
+ class MockDS < ActiveFedora::Datastream; end
152
153
  class MockAddNamedFileDatastream < ActiveFedora::Base
153
154
  include ActiveFedora::DatastreamCollections
154
- has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
155
+ has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>MockDS, :mimeType=>"image/jpeg", :controlGroup=>'M'
155
156
  has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
156
157
  has_datastream :name=>"anymime", :type=>ActiveFedora::Datastream, :controlGroup=>'M'
157
158
  end
@@ -165,7 +166,7 @@ describe ActiveFedora::DatastreamCollections do
165
166
  f.stub(:content_type).and_return("image/jpeg")
166
167
  @test_object2.add_named_file_datastream("thumbnail",f)
167
168
  thumb = @test_object2.thumbnail.first
168
- thumb.class.should == ActiveFedora::Datastream
169
+ thumb.class.should == MockDS
169
170
  thumb.mimeType.should == "image/jpeg"
170
171
  thumb.dsid.should == "THUMB1"
171
172
  thumb.controlGroup.should == "M"
@@ -63,4 +63,26 @@ describe ActiveFedora::RDFDatastream do
63
63
  result.dump(:ntriples).should == "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
64
64
  end
65
65
  end
66
+
67
+ describe 'content=' do
68
+ let(:ds) {ActiveFedora::NtriplesRDFDatastream.new}
69
+ it "should be able to handle non-utf-8 characters" do
70
+ data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
71
+ ds.content = data
72
+ expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
73
+ end
74
+ end
75
+
76
+ describe 'legacy non-utf-8 characters' do
77
+ let(:ds) do
78
+ datastream = ActiveFedora::NtriplesRDFDatastream.new
79
+ datastream.stub(:new?).and_return(false)
80
+ datastream.stub(:datastream_content).and_return("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT'))
81
+ datastream
82
+ end
83
+ it "should not error on access" do
84
+ expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
85
+ end
86
+ end
87
+
66
88
  end
@@ -49,6 +49,17 @@ describe ActiveFedora::Rdf::Properties do
49
49
  DummyProperties.property :title, :predicate => RDF::DC.title, :class_name => RDF::Literal
50
50
  expect(DummyProperties.properties[:title][:class_name]).to eq RDF::Literal
51
51
  end
52
+
53
+ it "should constantize string class names" do
54
+ DummyProperties.property :title, :predicate => RDF::DC.title, :class_name => "RDF::Literal"
55
+ expect(DummyProperties.properties[:title][:class_name]).to eq RDF::Literal
56
+ end
57
+
58
+ it "should keep strings which it can't constantize as strings" do
59
+ DummyProperties.property :title, :predicate => RDF::DC.title, :class_name => "FakeClassName"
60
+ expect(DummyProperties.properties[:title][:class_name]).to eq "FakeClassName"
61
+ end
62
+
52
63
  end
53
64
 
54
65
  context "when using a subclass" do
@@ -211,6 +211,17 @@ describe ActiveFedora::RDFDatastream do
211
211
  subject.reload
212
212
  expect(subject.descMetadata.creator.first).to be_kind_of(ActiveFedora::Base)
213
213
  end
214
+ context "when the AF:Base object is deleted" do
215
+ before do
216
+ subject.save
217
+ @new_object.destroy
218
+ end
219
+ it "should give back an AF::Rdf::Resource" do
220
+ subject.reload
221
+ expect(subject.descMetadata.creator.first).to be_kind_of(ActiveFedora::Rdf::Resource)
222
+ expect(subject.descMetadata.creator.first.rdf_subject).to eq @new_object.resource.rdf_subject
223
+ end
224
+ end
214
225
 
215
226
  it "should allow for deep attributes to be set directly" do
216
227
  subject.descMetadata.creator.first.title = "Bla"
@@ -29,6 +29,10 @@ describe ActiveFedora::Rdf::Resource do
29
29
  expect(subject.rdf_subject).to eq RDF::URI('http://example.org/moomin')
30
30
  end
31
31
 
32
+ it "should raise an error when setting to an invalid uri" do
33
+ expect{ subject.set_subject!('not_a_uri') }.to raise_error "could not make a valid RDF::URI from not_a_uri"
34
+ end
35
+
32
36
  describe 'when changing subject' do
33
37
  before do
34
38
  subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, RDF::Literal('Comet in Moominland'))
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Matt Zumwalt
@@ -10,258 +11,294 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-04-01 00:00:00.000000000 Z
14
+ date: 2014-04-17 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rsolr
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - "~>"
21
+ - - ~>
20
22
  - !ruby/object:Gem::Version
21
23
  version: 1.0.10.pre1
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
- - - "~>"
29
+ - - ~>
27
30
  - !ruby/object:Gem::Version
28
31
  version: 1.0.10.pre1
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: om
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
- - - "~>"
37
+ - - ~>
34
38
  - !ruby/object:Gem::Version
35
39
  version: 3.0.0
36
40
  type: :runtime
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
- - - "~>"
45
+ - - ~>
41
46
  - !ruby/object:Gem::Version
42
47
  version: 3.0.0
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: nom-xml
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
- - - ">="
53
+ - - ! '>='
48
54
  - !ruby/object:Gem::Version
49
55
  version: 0.5.1
50
56
  type: :runtime
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
- - - ">="
61
+ - - ! '>='
55
62
  - !ruby/object:Gem::Version
56
63
  version: 0.5.1
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: activesupport
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
- - - ">="
69
+ - - ! '>='
62
70
  - !ruby/object:Gem::Version
63
71
  version: 3.0.0
64
72
  type: :runtime
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
- - - ">="
77
+ - - ! '>='
69
78
  - !ruby/object:Gem::Version
70
79
  version: 3.0.0
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: mediashelf-loggable
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
- - - ">="
85
+ - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  type: :runtime
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
- - - ">="
93
+ - - ! '>='
83
94
  - !ruby/object:Gem::Version
84
95
  version: '0'
85
96
  - !ruby/object:Gem::Dependency
86
97
  name: rubydora
87
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
88
100
  requirements:
89
- - - "~>"
101
+ - - ~>
90
102
  - !ruby/object:Gem::Version
91
103
  version: 1.7.4
92
104
  type: :runtime
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
95
108
  requirements:
96
- - - "~>"
109
+ - - ~>
97
110
  - !ruby/object:Gem::Version
98
111
  version: 1.7.4
99
112
  - !ruby/object:Gem::Dependency
100
113
  name: linkeddata
101
114
  requirement: !ruby/object:Gem::Requirement
115
+ none: false
102
116
  requirements:
103
- - - ">="
117
+ - - ! '>='
104
118
  - !ruby/object:Gem::Version
105
119
  version: '0'
106
120
  type: :runtime
107
121
  prerelease: false
108
122
  version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
109
124
  requirements:
110
- - - ">="
125
+ - - ! '>='
111
126
  - !ruby/object:Gem::Version
112
127
  version: '0'
113
128
  - !ruby/object:Gem::Dependency
114
129
  name: rdf-rdfxml
115
130
  requirement: !ruby/object:Gem::Requirement
131
+ none: false
116
132
  requirements:
117
- - - "~>"
133
+ - - ~>
118
134
  - !ruby/object:Gem::Version
119
135
  version: 1.1.0
120
136
  type: :runtime
121
137
  prerelease: false
122
138
  version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
123
140
  requirements:
124
- - - "~>"
141
+ - - ~>
125
142
  - !ruby/object:Gem::Version
126
143
  version: 1.1.0
127
144
  - !ruby/object:Gem::Dependency
128
145
  name: deprecation
129
146
  requirement: !ruby/object:Gem::Requirement
147
+ none: false
130
148
  requirements:
131
- - - ">="
149
+ - - ! '>='
132
150
  - !ruby/object:Gem::Version
133
151
  version: '0'
134
152
  type: :runtime
135
153
  prerelease: false
136
154
  version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
137
156
  requirements:
138
- - - ">="
157
+ - - ! '>='
139
158
  - !ruby/object:Gem::Version
140
159
  version: '0'
141
160
  - !ruby/object:Gem::Dependency
142
161
  name: rdoc
143
162
  requirement: !ruby/object:Gem::Requirement
163
+ none: false
144
164
  requirements:
145
- - - ">="
165
+ - - ! '>='
146
166
  - !ruby/object:Gem::Version
147
167
  version: '0'
148
168
  type: :development
149
169
  prerelease: false
150
170
  version_requirements: !ruby/object:Gem::Requirement
171
+ none: false
151
172
  requirements:
152
- - - ">="
173
+ - - ! '>='
153
174
  - !ruby/object:Gem::Version
154
175
  version: '0'
155
176
  - !ruby/object:Gem::Dependency
156
177
  name: yard
157
178
  requirement: !ruby/object:Gem::Requirement
179
+ none: false
158
180
  requirements:
159
- - - ">="
181
+ - - ! '>='
160
182
  - !ruby/object:Gem::Version
161
183
  version: '0'
162
184
  type: :development
163
185
  prerelease: false
164
186
  version_requirements: !ruby/object:Gem::Requirement
187
+ none: false
165
188
  requirements:
166
- - - ">="
189
+ - - ! '>='
167
190
  - !ruby/object:Gem::Version
168
191
  version: '0'
169
192
  - !ruby/object:Gem::Dependency
170
193
  name: rake
171
194
  requirement: !ruby/object:Gem::Requirement
195
+ none: false
172
196
  requirements:
173
- - - ">="
197
+ - - ! '>='
174
198
  - !ruby/object:Gem::Version
175
199
  version: '0'
176
200
  type: :development
177
201
  prerelease: false
178
202
  version_requirements: !ruby/object:Gem::Requirement
203
+ none: false
179
204
  requirements:
180
- - - ">="
205
+ - - ! '>='
181
206
  - !ruby/object:Gem::Version
182
207
  version: '0'
183
208
  - !ruby/object:Gem::Dependency
184
209
  name: jettywrapper
185
210
  requirement: !ruby/object:Gem::Requirement
211
+ none: false
186
212
  requirements:
187
- - - ">="
213
+ - - ! '>='
188
214
  - !ruby/object:Gem::Version
189
215
  version: 1.4.0
190
216
  type: :development
191
217
  prerelease: false
192
218
  version_requirements: !ruby/object:Gem::Requirement
219
+ none: false
193
220
  requirements:
194
- - - ">="
221
+ - - ! '>='
195
222
  - !ruby/object:Gem::Version
196
223
  version: 1.4.0
197
224
  - !ruby/object:Gem::Dependency
198
225
  name: rspec
199
226
  requirement: !ruby/object:Gem::Requirement
227
+ none: false
200
228
  requirements:
201
- - - ">="
229
+ - - ! '>='
202
230
  - !ruby/object:Gem::Version
203
231
  version: 2.9.0
204
232
  type: :development
205
233
  prerelease: false
206
234
  version_requirements: !ruby/object:Gem::Requirement
235
+ none: false
207
236
  requirements:
208
- - - ">="
237
+ - - ! '>='
209
238
  - !ruby/object:Gem::Version
210
239
  version: 2.9.0
211
240
  - !ruby/object:Gem::Dependency
212
241
  name: equivalent-xml
213
242
  requirement: !ruby/object:Gem::Requirement
243
+ none: false
214
244
  requirements:
215
- - - ">="
245
+ - - ! '>='
216
246
  - !ruby/object:Gem::Version
217
247
  version: '0'
218
248
  type: :development
219
249
  prerelease: false
220
250
  version_requirements: !ruby/object:Gem::Requirement
251
+ none: false
221
252
  requirements:
222
- - - ">="
253
+ - - ! '>='
223
254
  - !ruby/object:Gem::Version
224
255
  version: '0'
225
256
  - !ruby/object:Gem::Dependency
226
257
  name: rest-client
227
258
  requirement: !ruby/object:Gem::Requirement
259
+ none: false
228
260
  requirements:
229
- - - ">="
261
+ - - ! '>='
230
262
  - !ruby/object:Gem::Version
231
263
  version: '0'
232
264
  type: :development
233
265
  prerelease: false
234
266
  version_requirements: !ruby/object:Gem::Requirement
267
+ none: false
235
268
  requirements:
236
- - - ">="
269
+ - - ! '>='
237
270
  - !ruby/object:Gem::Version
238
271
  version: '0'
239
272
  - !ruby/object:Gem::Dependency
240
273
  name: webmock
241
274
  requirement: !ruby/object:Gem::Requirement
275
+ none: false
242
276
  requirements:
243
- - - ">="
277
+ - - ! '>='
244
278
  - !ruby/object:Gem::Version
245
279
  version: '0'
246
280
  type: :development
247
281
  prerelease: false
248
282
  version_requirements: !ruby/object:Gem::Requirement
283
+ none: false
249
284
  requirements:
250
- - - ">="
285
+ - - ! '>='
251
286
  - !ruby/object:Gem::Version
252
287
  version: '0'
253
288
  - !ruby/object:Gem::Dependency
254
289
  name: simplecov
255
290
  requirement: !ruby/object:Gem::Requirement
291
+ none: false
256
292
  requirements:
257
- - - "~>"
293
+ - - ~>
258
294
  - !ruby/object:Gem::Version
259
295
  version: 0.7.1
260
296
  type: :development
261
297
  prerelease: false
262
298
  version_requirements: !ruby/object:Gem::Requirement
299
+ none: false
263
300
  requirements:
264
- - - "~>"
301
+ - - ~>
265
302
  - !ruby/object:Gem::Version
266
303
  version: 0.7.1
267
304
  description: ActiveFedora provides for creating and managing objects in the Fedora
@@ -274,10 +311,10 @@ extra_rdoc_files:
274
311
  - LICENSE
275
312
  - README.md
276
313
  files:
277
- - ".gitignore"
278
- - ".gitmodules"
279
- - ".mailmap"
280
- - ".travis.yml"
314
+ - .gitignore
315
+ - .gitmodules
316
+ - .mailmap
317
+ - .travis.yml
281
318
  - CONTRIBUTING.md
282
319
  - CONTRIBUTORS.md
283
320
  - Gemfile
@@ -545,26 +582,27 @@ files:
545
582
  homepage: https://github.com/projecthydra/active_fedora
546
583
  licenses:
547
584
  - APACHE2
548
- metadata: {}
549
585
  post_install_message:
550
586
  rdoc_options: []
551
587
  require_paths:
552
588
  - lib
553
589
  required_ruby_version: !ruby/object:Gem::Requirement
590
+ none: false
554
591
  requirements:
555
- - - ">="
592
+ - - ! '>='
556
593
  - !ruby/object:Gem::Version
557
594
  version: 1.9.3
558
595
  required_rubygems_version: !ruby/object:Gem::Requirement
596
+ none: false
559
597
  requirements:
560
- - - ">="
598
+ - - ! '>='
561
599
  - !ruby/object:Gem::Version
562
600
  version: '0'
563
601
  requirements: []
564
602
  rubyforge_project:
565
- rubygems_version: 2.2.2
603
+ rubygems_version: 1.8.24
566
604
  signing_key:
567
- specification_version: 4
605
+ specification_version: 3
568
606
  summary: A convenience libary for manipulating documents in the Fedora Repository.
569
607
  test_files:
570
608
  - spec/config_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3c10a4702718ed6d75d2ae3a50d68f2f7df312ed
4
- data.tar.gz: 1f789a3692431f14efbda9e097f0e2edfdb87881
5
- SHA512:
6
- metadata.gz: 2a00cdb7d97f144159944cee46347cd092fc8251b54317c23aea390ba35861906077fac78890f28e7976c53f5ddcfae1320998c8532a4ecbcf752360035c97ce
7
- data.tar.gz: 8e73ac6816f0ca3bd51a3724c6654bdb1031d75ae938d6464b1e88423a590e5a5e725c0b986548dcbfb8c4ea85851fcf00365bf4ecc5d6ebb16dc63a109a771e