active-fedora 9.0.0.beta3 → 9.0.0.beta4

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: 380da0e904e671fecd1e7cc340a7ff9e7e43ca89
4
- data.tar.gz: 01155eab5f9d0480eefc945636a17c48707ddae7
3
+ metadata.gz: 868c4057e2767f632105de888a5b5ca519ddf483
4
+ data.tar.gz: a40dfbdc7a7e9047413c4cec194cbfa66969677d
5
5
  SHA512:
6
- metadata.gz: 33fe88b57b1e02b8173754cbbac2a722f364b33d119375f2a3c1b1a44229040c779938896ac3abd15a58ef0647b591346fe161ab10b1f7e89b076a1f12d52929
7
- data.tar.gz: a7b51616edde2428ac50bd8721f82d7db76e70d1532e02613b31e06e20a1b54d1d15826993d98763d3e592c78bc49953090b45805d9596b9dc6f618534f59f27
6
+ metadata.gz: 9736c5cd63546aa1cf1d82119ab84d0376e6d06a8507026bce1c474ef340fb193149e352107ebbf6c215b74a110d095e2e126f0e95fa9186a3ba3b8143ac15f9
7
+ data.tar.gz: 05a30a175532f659499d94d3362b18b89a025f2610aa462b0de0860b21b87690d9ba7c74a2fc153a0da574d0607b9aecba3074623a92438ed91e6b953fe98339
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency "rdf-rdfxml", '~> 1.1.0'
23
23
  s.add_dependency "linkeddata"
24
24
  s.add_dependency "deprecation"
25
- s.add_dependency "ldp", '~> 0.0.9'
25
+ s.add_dependency "ldp", '~> 0.1.0'
26
26
  s.add_dependency "rdf-ldp"
27
27
 
28
28
  s.add_development_dependency "rdoc"
@@ -102,6 +102,7 @@ module ActiveFedora #:nodoc:
102
102
  autoload :Predicates
103
103
  autoload :Validations
104
104
  autoload :Versionable
105
+ autoload :VersionsGraph
105
106
  autoload :WithMetadata
106
107
  end
107
108
 
@@ -121,6 +122,7 @@ module ActiveFedora #:nodoc:
121
122
  eager_autoload do
122
123
  autoload :Serializers
123
124
  autoload :PrimaryKey
125
+ autoload :PropertyBuilder
124
126
  end
125
127
  end
126
128
 
@@ -157,7 +159,6 @@ module ActiveFedora #:nodoc:
157
159
  SolrService.reset!
158
160
  Predicates.predicate_config = nil
159
161
  configurator.init(options)
160
- fedora.init_base_path
161
162
  end
162
163
 
163
164
  def config
@@ -168,10 +168,13 @@ module ActiveFedora
168
168
  delegated_attributes[field].multiple
169
169
  end
170
170
 
171
-
172
- def property name, properties
171
+ def property name, properties={}, &block
173
172
  find_or_create_defined_attribute(name, nil, {multiple: true}.merge(properties))
174
- super
173
+ raise ArgumentError, "#{name} is a keyword and not an acceptable property name." if protected_property_name? name
174
+ properties = properties.merge(multivalue: false) if properties[:multiple] == false
175
+ reflection = ActiveFedora::Attributes::PropertyBuilder.build(self, name, properties.except(:multiple), &block)
176
+ # reflection = ActiveTriple::PropertyBuilder.build(self, name, properties, &block)
177
+ ActiveTriples::Reflection.add_reflection self, name, reflection
175
178
  end
176
179
 
177
180
  private
@@ -0,0 +1,33 @@
1
+ module ActiveFedora::Attributes
2
+ class PropertyBuilder < ActiveTriples::PropertyBuilder #:nodoc:
3
+
4
+ def self.define_accessors(model, reflection)
5
+ mixin = model.generated_property_methods
6
+ name = reflection.term
7
+ define_readers(mixin, name)
8
+ reflection.multivalue ? define_writers(mixin, name) : define_singular_writers(mixin, name)
9
+ end
10
+
11
+ def self.define_writers(mixin, name)
12
+ mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
13
+ def #{name}=(value)
14
+ if value.present? && !value.respond_to?(:each)
15
+ raise ArgumentError, "You attempted to set the property `#{name}' to a scalar value. However, this property is declared as being multivalued."
16
+ end
17
+ set_value(:#{name}, value)
18
+ end
19
+ CODE
20
+ end
21
+
22
+ def self.define_singular_writers(mixin, name)
23
+ mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
24
+ def #{name}=(value)
25
+ if value.respond_to?(:each) # singular
26
+ raise ArgumentError, "You attempted to set the property `#{name}' to an enumerable value. However, this property is declared as singular."
27
+ end
28
+ set_value(:#{name}, value)
29
+ end
30
+ CODE
31
+ end
32
+ end
33
+ end
@@ -2,6 +2,7 @@ module ActiveFedora
2
2
  class Fedora
3
3
  def initialize(config)
4
4
  @config = config
5
+ init_base_path
5
6
  end
6
7
 
7
8
  def host
@@ -43,7 +43,7 @@ module ActiveFedora
43
43
  # It is expected that the singular filter gets applied after fetching the value from this
44
44
  # resource, so cast everything back to an array.
45
45
  def set_value(k, v)
46
- @hash[k] = Array(v)
46
+ @hash[k] = v
47
47
  end
48
48
 
49
49
  def get_values(k)
@@ -2,6 +2,8 @@ require 'rdf'
2
2
  module ActiveFedora::RDF
3
3
  class Fcrepo4 < RDF::StrictVocabulary("http://fedora.info/definitions/v4/repository#")
4
4
  property :created
5
+ property :hasVersion
6
+ property :hasVersionLabel
5
7
  property :lastModified
6
8
  end
7
9
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "9.0.0.beta3"
2
+ VERSION = "9.0.0.beta4"
3
3
  end
@@ -20,19 +20,15 @@ module ActiveFedora
20
20
  end
21
21
  end
22
22
 
23
- # Returns an array of uris matching our own version label, excluding auto-snapshot versions from Fedora.
23
+ # Returns an array of ActiveFedora::VersionsGraph::ResourceVersion objects.
24
+ # Excludes auto-snapshot versions from Fedora.
24
25
  def versions
25
- results = versions_graph.query([nil, ::RDF::URI.new('http://fedora.info/definitions/v4/repository#hasVersionLabel'), nil])
26
- numbered_versions(results).map { |v| version_uri(v.to_s) }
27
- end
28
-
29
- def versions_graph
30
- @versions_graph ||= ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(versions_request)
26
+ @versions ||= ActiveFedora::VersionsGraph.new << ::RDF::Reader.for(:ttl).new(versions_request)
31
27
  end
32
28
 
33
29
  def create_version
34
30
  resp = ActiveFedora.fedora.connection.post(versions_uri, nil, {slug: version_name})
35
- @versions_graph = nil
31
+ @versions = nil
36
32
  resp.success?
37
33
  end
38
34
 
@@ -46,8 +42,8 @@ module ActiveFedora
46
42
  end
47
43
 
48
44
  def restore_version label
49
- resp = ActiveFedora.fedora.connection.patch(version_uri(label), nil)
50
- @versions_graph = nil
45
+ resp = ActiveFedora.fedora.connection.patch(versions.with_label(label).uri, nil)
46
+ @versions = nil
51
47
  reload
52
48
  refresh_attributes if self.respond_to?("refresh_attributes")
53
49
  resp.success?
@@ -71,25 +67,14 @@ module ActiveFedora
71
67
 
72
68
  def versions_uri
73
69
  uri + '/fcr:versions'
74
- end
75
-
76
- def version_uri label
77
- versions_uri + '/' + label
78
- end
70
+ end
79
71
 
80
72
  def version_name
81
- if versions.empty?
73
+ if versions.all.empty?
82
74
  "version1"
83
75
  else
84
- "version" + (versions.count + 1).to_s
85
- end
86
- end
87
-
88
- def numbered_versions statements, literals = Array.new
89
- statements.each do |statement|
90
- literals << statement.object unless statement.object.to_s.match("auto-snapshot")
76
+ "version" + (versions.all.count + 1).to_s
91
77
  end
92
- return literals
93
78
  end
94
79
 
95
80
  end
@@ -0,0 +1,58 @@
1
+ module ActiveFedora
2
+ class VersionsGraph < ::RDF::Graph
3
+
4
+ def all opts={}
5
+ if opts[:include_auto_save]
6
+ fedora_versions
7
+ else
8
+ fedora_versions.reject { |v| v.label.match("auto") }
9
+ end
10
+ end
11
+
12
+ def first
13
+ all.first
14
+ end
15
+
16
+ def last
17
+ all.last
18
+ end
19
+
20
+ def with_label label
21
+ all.each do |version|
22
+ return version if version.label == label
23
+ end
24
+ end
25
+
26
+ def resources
27
+ query(predicate: ActiveFedora::RDF::Fcrepo4.hasVersion)
28
+ end
29
+
30
+ private
31
+
32
+ class ResourceVersion
33
+ attr_accessor :uri, :label, :created
34
+ end
35
+
36
+ def version_from_resource statement
37
+ version = ResourceVersion.new
38
+ version.uri = statement.object.to_s.gsub(/\/fcr:metadata$/,"")
39
+ version.label = label_query(statement)
40
+ version.created = created_query(statement)
41
+ return version
42
+ end
43
+
44
+ def label_query statement
45
+ query(subject: statement.object).query(predicate: ActiveFedora::RDF::Fcrepo4.hasVersionLabel).first.object.to_s
46
+ end
47
+
48
+ def created_query statement
49
+ query(subject: statement.object).query(predicate: ActiveFedora::RDF::Fcrepo4.created).first.object.to_s
50
+ end
51
+
52
+ def fedora_versions
53
+ resources.map { |statement| version_from_resource(statement) }
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -1,8 +1,7 @@
1
1
  APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
2
2
 
3
3
  require 'jettywrapper'
4
- JETTY_ZIP_BASENAME = 'fedora-4/master'
5
- Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
4
+ Jettywrapper.hydra_jetty_version = "v8.1.1"
6
5
 
7
6
  namespace :active_fedora do
8
7
  # Use yard to build docs
@@ -24,6 +24,7 @@ describe "delegating attributes" do
24
24
  end
25
25
  end
26
26
  end
27
+
27
28
  after :all do
28
29
  Object.send(:remove_const, :TitledObject)
29
30
  Object.send(:remove_const, :RdfObject)
@@ -57,7 +58,7 @@ describe "delegating attributes" do
57
58
 
58
59
  before do
59
60
  subject.depositor = "foo"
60
- subject.resource_type = "bar"
61
+ subject.resource_type = ["bar"]
61
62
  subject.save
62
63
  end
63
64
 
@@ -69,21 +70,20 @@ describe "delegating attributes" do
69
70
  expect(subject[:depositor]).to eql("foo")
70
71
  expect(subject[:resource_type]).to eql(["bar"])
71
72
  end
72
-
73
73
  end
74
74
 
75
75
  describe "setting attributes" do
76
-
77
76
  specify "using strings for keys" do
78
77
  subject["depositor"] = "foo"
79
- subject["resource_type"] = "bar"
78
+ subject["resource_type"] = ["bar"]
80
79
  subject.save
81
80
  expect(subject.depositor).to eql("foo")
82
81
  expect(subject.resource_type).to eql(["bar"])
83
82
  end
83
+
84
84
  specify "using symbols for keys" do
85
85
  subject[:depositor] = "foo"
86
- subject[:resource_type] = "bar"
86
+ subject[:resource_type] = ["bar"]
87
87
  subject.save
88
88
  expect(subject.depositor).to eql("foo")
89
89
  expect(subject.resource_type).to eql(["bar"])
@@ -102,9 +102,6 @@ describe "delegating attributes" do
102
102
  expect(subject.wrangler).to eql(["bar"])
103
103
  end
104
104
  end
105
-
106
105
  end
107
-
108
106
  end
109
107
  end
110
-
@@ -9,13 +9,9 @@ describe ActiveFedora::SolrInstanceLoader do
9
9
  end
10
10
  has_attributes :foo, datastream: 'descMetadata', multiple: true
11
11
  has_attributes :bar, datastream: 'descMetadata', multiple: false
12
- property :title, predicate: ::RDF::DC.title
12
+ property :title, predicate: ::RDF::DC.title, multiple: false
13
13
  property :description, predicate: ::RDF::DC.description
14
14
  belongs_to :another, predicate: ActiveFedora::RDF::RelsExt.isPartOf, class_name: 'Foo'
15
-
16
- def title
17
- super.first
18
- end
19
15
  end
20
16
  end
21
17
 
@@ -28,7 +24,6 @@ describe ActiveFedora::SolrInstanceLoader do
28
24
  Object.send(:remove_const, :Foo)
29
25
  end
30
26
 
31
-
32
27
  context "without a solr doc" do
33
28
  subject { loader.object }
34
29
 
@@ -59,7 +54,7 @@ describe ActiveFedora::SolrInstanceLoader do
59
54
  expect(object.foo).to eq ['baz'] # datastream assertion
60
55
 
61
56
  # and it's frozen
62
- expect { object.title = ['changed'] }.to raise_error ActiveFedora::ReadOnlyRecord
57
+ expect { object.title = 'changed' }.to raise_error ActiveFedora::ReadOnlyRecord
63
58
  expect(object.title).to eq 'My Title'
64
59
 
65
60
  expect { object.foo = ['changed'] }.to raise_error ActiveFedora::ReadOnlyRecord
@@ -77,7 +72,7 @@ describe ActiveFedora::SolrInstanceLoader do
77
72
  end
78
73
 
79
74
  context "with a solr doc" do
80
- let(:profile) { { "foo"=>["baz"], "bar"=>"quix", "title"=>["My Title"]}.to_json }
75
+ let(:profile) { { "foo"=>["baz"], "bar"=>"quix", "title"=>"My Title"}.to_json }
81
76
  let(:doc) { { 'id' => 'test-123', 'has_model_ssim'=>['Foo'], 'object_profile_ssm' => profile } }
82
77
  let(:loader) { ActiveFedora::SolrInstanceLoader.new(Foo, obj.id, doc) }
83
78
 
@@ -14,11 +14,13 @@ describe "a versionable class" do
14
14
 
15
15
  subject { WithVersions.new }
16
16
 
17
+ let(:current_year) { DateTime.now.year.to_s }
18
+
17
19
  it { is_expected.to be_versionable }
18
20
 
19
21
  context "after saving" do
20
22
  before do
21
- subject.title = "Greetings Earthlings"
23
+ subject.title = ["Greetings Earthlings"]
22
24
  subject.save
23
25
  subject.create_version
24
26
  end
@@ -28,22 +30,24 @@ describe "a versionable class" do
28
30
  end
29
31
 
30
32
  it "should have one version" do
31
- expect(subject.versions.size).to eq 1
32
- expect(subject.versions.first).to be_kind_of String
33
- expect(subject.versions.first).to end_with "version1"
33
+ expect(subject.versions).to be_kind_of ActiveFedora::VersionsGraph
34
+ expect(subject.versions.all.first).to be_kind_of ActiveFedora::VersionsGraph::ResourceVersion
35
+ expect(subject.versions.all.first.label).to eql "version1"
36
+ expect(subject.versions.all.first.created).to start_with current_year
34
37
  end
35
38
 
36
39
  context "two times" do
37
40
  before do
38
- subject.title = "Surrender and prepare to be boarded"
41
+ subject.title = ["Surrender and prepare to be boarded"]
39
42
  subject.save
40
43
  subject.create_version
41
44
  end
42
45
 
43
46
  it "should have two versions" do
44
- expect(subject.versions.size).to eq 2
45
- subject.versions.each_index do |index|
46
- expect(subject.versions[index]).to end_with "version"+(index+1).to_s
47
+ expect(subject.versions.all.size).to eq 2
48
+ subject.versions.all.each_index do |index|
49
+ expect(subject.versions.all[index].label).to end_with "version"+(index+1).to_s
50
+ expect(subject.versions.all[index].created).to start_with current_year
47
51
  end
48
52
  end
49
53
 
@@ -59,13 +63,13 @@ describe "a versionable class" do
59
63
 
60
64
  context "and creating additional versions" do
61
65
  before do
62
- subject.title = "Now, surrender and prepare to be boarded"
66
+ subject.title = ["Now, surrender and prepare to be boarded"]
63
67
  subject.save!
64
68
  subject.create_version
65
69
  end
66
70
 
67
71
  it "should have three versions" do
68
- expect(subject.versions.size).to eq 3
72
+ expect(subject.versions.all.size).to eq 3
69
73
  expect(subject.title).to eql(["Now, surrender and prepare to be boarded"])
70
74
  end
71
75
 
@@ -98,6 +102,8 @@ describe "a versionable rdf datastream" do
98
102
 
99
103
  subject { test_object.descMetadata }
100
104
 
105
+ let(:current_year) { DateTime.now.year.to_s }
106
+
101
107
  context "that exists in the repository" do
102
108
  let(:test_object) { MockAFBase.create }
103
109
 
@@ -127,7 +133,7 @@ describe "a versionable rdf datastream" do
127
133
  end
128
134
 
129
135
  it "should have one version" do
130
- expect(subject.versions.first).to end_with "version1"
136
+ expect(subject.versions.first.label).to eql "version1"
131
137
  end
132
138
 
133
139
  it "should have a title" do
@@ -146,9 +152,10 @@ describe "a versionable rdf datastream" do
146
152
  end
147
153
 
148
154
  it "should have two versions" do
149
- expect(subject.versions.size).to eq 2
150
- subject.versions.each_index do |index|
151
- expect(subject.versions[index]).to end_with "version"+(index+1).to_s
155
+ expect(subject.versions.all.size).to eq 2
156
+ subject.versions.all.each_index do |index|
157
+ expect(subject.versions.all[index].label).to end_with "version"+(index+1).to_s
158
+ expect(subject.versions.all[index].created).to start_with current_year
152
159
  end
153
160
  end
154
161
 
@@ -168,7 +175,7 @@ describe "a versionable rdf datastream" do
168
175
  end
169
176
 
170
177
  it "should have two unique versions" do
171
- expect(subject.versions.size).to eq 2
178
+ expect(subject.versions.all.size).to eq 2
172
179
  end
173
180
 
174
181
  it "should load the restored datastream's content" do
@@ -187,7 +194,7 @@ describe "a versionable rdf datastream" do
187
194
  end
188
195
 
189
196
  it "should have three unique versions" do
190
- expect(subject.versions.size).to eq 3
197
+ expect(subject.versions.all.size).to eq 3
191
198
  end
192
199
 
193
200
  it "should have a new title" do
@@ -227,6 +234,8 @@ describe "a versionable OM datastream" do
227
234
 
228
235
  subject { test_object.descMetadata }
229
236
 
237
+ let(:current_year) { DateTime.now.year.to_s }
238
+
230
239
  context "that exists in the repository" do
231
240
  let(:test_object) { MockAFBase.create }
232
241
 
@@ -256,7 +265,8 @@ describe "a versionable OM datastream" do
256
265
  end
257
266
 
258
267
  it "should have one version" do
259
- expect(subject.versions.first).to end_with "version1"
268
+ expect(subject.versions.first.label).to eql "version1"
269
+ expect(subject.versions.first.created).to start_with current_year
260
270
  end
261
271
 
262
272
  it "should have a title" do
@@ -276,9 +286,10 @@ describe "a versionable OM datastream" do
276
286
  end
277
287
 
278
288
  it "should have two unique versions" do
279
- expect(subject.versions.size).to eq 2
280
- subject.versions.each_index do |index|
281
- expect(subject.versions[index]).to end_with "version"+(index+1).to_s
289
+ expect(subject.versions.all.size).to eq 2
290
+ subject.versions.all.each_index do |index|
291
+ expect(subject.versions.all[index].label).to end_with "version"+(index+1).to_s
292
+ expect(subject.versions.all[index].created).to start_with current_year
282
293
  end
283
294
  end
284
295
 
@@ -298,7 +309,7 @@ describe "a versionable OM datastream" do
298
309
  end
299
310
 
300
311
  it "should still have two unique versions" do
301
- expect(subject.versions.size).to eq 2
312
+ expect(subject.versions.all.size).to eq 2
302
313
  end
303
314
 
304
315
  it "should load the restored datastream's content" do
@@ -317,7 +328,7 @@ describe "a versionable OM datastream" do
317
328
  end
318
329
 
319
330
  it "should have three unique versions" do
320
- expect(subject.versions.size).to eq 3
331
+ expect(subject.versions.all.size).to eq 3
321
332
  end
322
333
 
323
334
  it "should have a new title" do
@@ -353,6 +364,8 @@ describe "a versionable binary datastream" do
353
364
 
354
365
  subject { test_object.content }
355
366
 
367
+ let(:current_year) { DateTime.now.year.to_s }
368
+
356
369
  context "that exists in the repository" do
357
370
  let(:test_object) { MockAFBase.create }
358
371
 
@@ -381,10 +394,11 @@ describe "a versionable binary datastream" do
381
394
  end
382
395
 
383
396
  it "should have one version" do
384
- expect(subject.versions.size).to eq 1
397
+ expect(subject.versions.all.size).to eq 1
385
398
  expect(subject.original_name).to eql(first_name)
386
399
  expect(subject.content.size).to eq first_file.size
387
- expect(subject.versions.first).to end_with "version1"
400
+ expect(subject.versions.first.label).to eql "version1"
401
+ expect(subject.versions.first.created).to start_with current_year
388
402
  end
389
403
 
390
404
  context "two times" do
@@ -398,19 +412,20 @@ describe "a versionable binary datastream" do
398
412
  end
399
413
 
400
414
  it "should have two unique versions" do
401
- expect(subject.versions.size).to eq 2
415
+ expect(subject.versions.all.size).to eq 2
402
416
  expect(subject.original_name).to eql(second_name)
403
417
  expect(subject.content.size).to eq second_file.size
404
- subject.versions.each_index do |index|
405
- expect(subject.versions[index]).to end_with "version"+(index+1).to_s
418
+ subject.versions.all.each_index do |index|
419
+ expect(subject.versions.all[index].label).to end_with "version"+(index+1).to_s
420
+ expect(subject.versions.all[index].created).to start_with current_year
406
421
  end
407
422
  end
408
423
 
409
424
  context "with fixity checking" do
410
425
  let(:results) do
411
426
  results = Array.new
412
- subject.versions.each do |uri|
413
- results << ActiveFedora::FixityService.new(uri).check
427
+ subject.versions.all.each do |version|
428
+ results << ActiveFedora::FixityService.new(version.uri).check
414
429
  end
415
430
  return results
416
431
  end
@@ -429,7 +444,7 @@ describe "a versionable binary datastream" do
429
444
  end
430
445
 
431
446
  it "should still have two unique versions" do
432
- expect(subject.versions.size).to eq 2
447
+ expect(subject.versions.all.size).to eq 2
433
448
  end
434
449
 
435
450
  it "should load the restored datastream's content" do
@@ -449,11 +464,12 @@ describe "a versionable binary datastream" do
449
464
  end
450
465
 
451
466
  it "should have three unique versions" do
452
- expect(subject.versions.size).to eq 3
467
+ expect(subject.versions.all.size).to eq 3
453
468
  expect(subject.original_name).to eql(first_name)
454
469
  expect(subject.content.size).to eq first_file.size
455
- subject.versions.each_index do |index|
456
- expect(subject.versions[index]).to end_with "version"+(index+1).to_s
470
+ subject.versions.all.each_index do |index|
471
+ expect(subject.versions.all[index].label).to end_with "version"+(index+1).to_s
472
+ expect(subject.versions.all[index].created).to start_with current_year
457
473
  end
458
474
  end
459
475
 
@@ -464,10 +480,10 @@ describe "a versionable binary datastream" do
464
480
  end
465
481
  end
466
482
 
467
- describe "a non-versionable resource" do
483
+ describe "a non-versionable resource" do
468
484
  before(:all) do
469
485
  class NotVersionableWithVersions < ActiveFedora::Base
470
- # explicitly don't call has_many_versions
486
+ # explicitly don't call has_many_versions
471
487
  property :title, predicate: ::RDF::DC.title
472
488
  end
473
489
  end
@@ -480,16 +496,16 @@ describe "a non-versionable resource" do
480
496
 
481
497
  context "saved with no versions" do
482
498
  it "should not have versions" do
483
- subject.update(title: "Greetings Earthlings")
499
+ subject.update(title: ["Greetings Earthlings"])
484
500
  expect(subject).not_to have_versions
485
501
  end
486
502
  end
487
503
 
488
504
  context "saved with versions" do
489
505
  it "should have versions" do
490
- subject.update(title: "Greetings Earthlings")
506
+ subject.update(title: ["Greetings Earthlings"])
491
507
  subject.create_version
492
508
  expect(subject).to have_versions
493
509
  end
494
510
  end
495
- end
511
+ end
@@ -146,13 +146,14 @@ describe ActiveFedora::Base do
146
146
  expect(subject.fubar(1)).to eq ['two']
147
147
  end
148
148
 
149
- describe "asigning wrong cardinality" do
149
+ describe "assigning wrong cardinality" do
150
150
  it "should not allow passing a string to a multiple attribute writer" do
151
151
  expect { subject.fubar = "Quack" }.to raise_error ArgumentError
152
152
  expect { subject.fubar = ["Quack"] }.not_to raise_error
153
153
  expect { subject.fubar = nil }.not_to raise_error
154
154
  end
155
- it "should deprecate passing an enumerable to a unique attribute writer" do
155
+
156
+ it "should not allow passing an enumerable to a unique attribute writer" do
156
157
  expect { subject.cow = "Low" }.not_to raise_error
157
158
  expect { subject.cow = ["Low"]
158
159
  }.to raise_error ArgumentError, "You attempted to set the attribute `cow' on `BarHistory2' to an enumerable value. However, this attribute is declared as being singular."
@@ -160,7 +161,6 @@ describe ActiveFedora::Base do
160
161
  end
161
162
  end
162
163
 
163
-
164
164
  it "should return an array if marked as multiple" do
165
165
  subject.horse=["neigh", "whinny"]
166
166
  expect(subject.horse).to eq ["neigh", "whinny"]
@@ -185,7 +185,7 @@ describe ActiveFedora::Base do
185
185
  end
186
186
  end
187
187
 
188
- describe "array getters and setters" do
188
+ describe "hash getters and setters" do
189
189
  it "should accept symbol keys" do
190
190
  subject[:duck]= ["Cluck", "Gobble"]
191
191
  expect(subject[:duck]).to eq ["Cluck", "Gobble"]
@@ -394,6 +394,7 @@ describe ActiveFedora::Base do
394
394
  property :title, predicate: ::RDF::DC.title do |index|
395
395
  index.as :symbol
396
396
  end
397
+ property :abstract, predicate: ::RDF::DC.abstract, multiple: false
397
398
  end
398
399
  end
399
400
 
@@ -415,6 +416,21 @@ describe ActiveFedora::Base do
415
416
  expect(solr_doc['title_ssim']).to eq ['test1']
416
417
  end
417
418
  end
419
+
420
+ describe "when an object of the wrong cardinality is set" do
421
+ it "should not allow passing a string to a multiple property writer" do
422
+ expect { subject.title = "Quack" }.to raise_error ArgumentError
423
+ expect { subject.title = ["Quack"] }.not_to raise_error
424
+ expect { subject.title = nil }.not_to raise_error
425
+ end
426
+
427
+ it "should not allow an enumerable to a unique attribute writer" do
428
+ expect { subject.abstract = "Low" }.not_to raise_error
429
+ expect { subject.abstract = ["Low"]
430
+ }.to raise_error ArgumentError, "You attempted to set the property `abstract' to an enumerable value. However, this property is declared as singular."
431
+ expect { subject.abstract = nil }.not_to raise_error
432
+ end
433
+ end
418
434
  end
419
435
  end
420
436
 
@@ -213,7 +213,7 @@ describe ActiveFedora::Base do
213
213
  end
214
214
 
215
215
  context "and the object has properties" do
216
- let(:test_object) { WithProperty.new(title: 'foo') }
216
+ let(:test_object) { WithProperty.new(title: ['foo']) }
217
217
  before do
218
218
  class WithProperty < ActiveFedora::Base
219
219
  property :title, predicate: ::RDF::DC.title
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.beta3
4
+ version: 9.0.0.beta4
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-03 00:00:00.000000000 Z
13
+ date: 2014-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -130,14 +130,14 @@ dependencies:
130
130
  requirements:
131
131
  - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: 0.0.9
133
+ version: 0.1.0
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - "~>"
139
139
  - !ruby/object:Gem::Version
140
- version: 0.0.9
140
+ version: 0.1.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: rdf-ldp
143
143
  requirement: !ruby/object:Gem::Requirement
@@ -313,6 +313,7 @@ files:
313
313
  - lib/active_fedora/attribute_methods/write.rb
314
314
  - lib/active_fedora/attributes.rb
315
315
  - lib/active_fedora/attributes/primary_key.rb
316
+ - lib/active_fedora/attributes/property_builder.rb
316
317
  - lib/active_fedora/attributes/serializers.rb
317
318
  - lib/active_fedora/autosave_association.rb
318
319
  - lib/active_fedora/base.rb
@@ -387,6 +388,7 @@ files:
387
388
  - lib/active_fedora/validations.rb
388
389
  - lib/active_fedora/version.rb
389
390
  - lib/active_fedora/versionable.rb
391
+ - lib/active_fedora/versions_graph.rb
390
392
  - lib/active_fedora/with_metadata.rb
391
393
  - lib/active_fedora/with_metadata/metadata_node.rb
392
394
  - lib/generators/active_fedora/config/USAGE