active-fedora 6.7.8 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +938 -0
- data/.travis.yml +5 -6
- data/Gemfile +3 -1
- data/Rakefile +7 -5
- data/active-fedora.gemspec +7 -8
- data/lib/active_fedora/om_datastream.rb +1 -0
- data/lib/active_fedora/rdf_xml_writer.rb +31 -62
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +232 -232
- data/spec/integration/attributes_spec.rb +11 -12
- data/spec/integration/auditable_spec.rb +10 -10
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delegating_spec.rb +14 -14
- data/spec/integration/delete_all_spec.rb +38 -42
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/full_featured_model_spec.rb +101 -101
- data/spec/integration/has_many_associations_spec.rb +24 -24
- data/spec/integration/model_spec.rb +30 -30
- data/spec/integration/nested_attribute_spec.rb +41 -41
- data/spec/integration/ntriples_datastream_spec.rb +107 -107
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +6 -6
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +24 -26
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +40 -41
- data/spec/integration/solr_instance_loader_spec.rb +4 -4
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/rails3_test_app/config/application.rb +1 -1
- data/spec/rails3_test_app/config/environments/development.rb +0 -1
- data/spec/rails3_test_app/config/environments/production.rb +1 -1
- data/spec/rails3_test_app/spec/spec_helper.rb +3 -3
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +4 -4
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +7 -11
- data/spec/support/an_active_model.rb +2 -2
- data/spec/support/mock_fedora.rb +16 -17
- data/spec/unit/active_fedora_spec.rb +58 -58
- data/spec/unit/association_proxy_spec.rb +5 -7
- data/spec/unit/base_active_model_spec.rb +25 -26
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_delegate_spec.rb +80 -82
- data/spec/unit/base_delegate_to_spec.rb +37 -39
- data/spec/unit/base_extra_spec.rb +48 -48
- data/spec/unit/base_spec.rb +300 -300
- data/spec/unit/callback_spec.rb +19 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +16 -8
- data/spec/unit/content_model_spec.rb +60 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +57 -54
- data/spec/unit/datastreams_spec.rb +77 -77
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +26 -26
- data/spec/unit/has_many_collection_spec.rb +9 -9
- data/spec/unit/inheritance_spec.rb +12 -13
- data/spec/unit/model_spec.rb +41 -51
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +112 -112
- data/spec/unit/om_datastream_spec.rb +233 -227
- data/spec/unit/persistence_spec.rb +6 -6
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +9 -17
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +188 -217
- data/spec/unit/rdf_datastream_spec.rb +28 -21
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +80 -104
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +75 -69
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +59 -59
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +27 -28
- data/spec/unit/solr_digital_object_spec.rb +21 -21
- data/spec/unit/solr_service_spec.rb +81 -81
- data/spec/unit/unsaved_digital_object_spec.rb +20 -20
- data/spec/unit/validations_spec.rb +21 -21
- metadata +70 -58
- data/gemfiles/gemfile.rails3 +0 -11
- data/gemfiles/gemfile.rails4 +0 -10
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'NestedAttribute behavior' do
|
4
4
|
before do
|
5
5
|
class Bar < ActiveFedora::Base
|
6
|
-
belongs_to :car, :property
|
7
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
8
|
-
m.field
|
9
|
-
m.field
|
6
|
+
belongs_to :car, :property => :has_member
|
7
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData' do |m|
|
8
|
+
m.field 'uno', :string
|
9
|
+
m.field 'dos', :string
|
10
10
|
end
|
11
11
|
delegate :uno, to: 'someData', multiple: false
|
12
12
|
delegate :dos, to: 'someData', multiple: false
|
@@ -14,23 +14,23 @@ describe "NestedAttribute behavior" do
|
|
14
14
|
|
15
15
|
# base Car class, used in test for association updates and :allow_destroy flag
|
16
16
|
class Car < ActiveFedora::Base
|
17
|
-
has_many :bars, :property
|
18
|
-
accepts_nested_attributes_for :bars, :allow_destroy=>true
|
17
|
+
has_many :bars, :property => :has_member
|
18
|
+
accepts_nested_attributes_for :bars, :allow_destroy => true
|
19
19
|
end
|
20
20
|
|
21
21
|
# class used in test for :reject_if=>:all_blank
|
22
22
|
class CarAllBlank < Car
|
23
|
-
accepts_nested_attributes_for :bars, :reject_if
|
23
|
+
accepts_nested_attributes_for :bars, :reject_if => :all_blank
|
24
24
|
end
|
25
25
|
|
26
26
|
# class used in test for :reject_if with proc object
|
27
27
|
class CarProc < Car
|
28
|
-
accepts_nested_attributes_for :bars, :reject_if=>proc { |attributes| attributes['uno'].blank? }
|
28
|
+
accepts_nested_attributes_for :bars, :reject_if => proc { |attributes| attributes['uno'].blank? }
|
29
29
|
end
|
30
30
|
|
31
31
|
# class used in test for :reject_if with method name as symbol
|
32
32
|
class CarSymbol < Car
|
33
|
-
accepts_nested_attributes_for :bars, :reject_if
|
33
|
+
accepts_nested_attributes_for :bars, :reject_if => :uno_blank
|
34
34
|
|
35
35
|
def uno_blank(attributes)
|
36
36
|
attributes['uno'].blank?
|
@@ -43,64 +43,64 @@ describe "NestedAttribute behavior" do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
it
|
47
|
-
Bar.new._destroy.
|
46
|
+
it 'should have _destroy' do
|
47
|
+
expect(Bar.new._destroy).to be_falsey
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
50
|
+
it 'should update the child objects' do
|
51
51
|
@car, @bar1, @bar2 = create_car_with_bars
|
52
52
|
|
53
|
-
@car.attributes = {:bars_attributes=>[{:id
|
54
|
-
Bar.find(@bar1.pid).uno.
|
55
|
-
Bar.where(:id => @bar2.pid).first.
|
56
|
-
Bar.where(:uno =>
|
53
|
+
@car.attributes = {:bars_attributes => [{:id => @bar1.pid, :uno => 'bar1 uno'}, {:uno => 'newbar uno'}, {:id => @bar2.pid, :_destroy => '1', :uno => 'bar2 uno'}]}
|
54
|
+
expect(Bar.find(@bar1.pid).uno).to eq('bar1 uno')
|
55
|
+
expect(Bar.where(:id => @bar2.pid).first).to be_nil
|
56
|
+
expect(Bar.where(:uno => 'newbar uno').first).not_to be_nil
|
57
57
|
|
58
58
|
bars = @car.bars(true)
|
59
|
-
bars.
|
60
|
-
bars.
|
59
|
+
expect(bars).to include(@bar1)
|
60
|
+
expect(bars).not_to include(@bar2)
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it 'should reject attributes when all blank' do
|
64
64
|
@car, @bar1, @bar2 = create_car_with_bars(CarAllBlank)
|
65
65
|
|
66
|
-
@car.bars.count.
|
67
|
-
@car.attributes = {:bars_attributes=>[{}, {:id
|
68
|
-
@car.bars(true).count.
|
66
|
+
expect(@car.bars.count).to eq(2)
|
67
|
+
@car.attributes = {:bars_attributes => [{}, {:id => @bar1.pid, :uno => 'bar1 uno'}]}
|
68
|
+
expect(@car.bars(true).count).to eq(2)
|
69
69
|
|
70
70
|
@bar1.reload
|
71
|
-
@bar1.uno.
|
71
|
+
expect(@bar1.uno).to eq('bar1 uno')
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'should reject attributes based on proc' do
|
75
75
|
@car, @bar1, @bar2 = create_car_with_bars(CarProc)
|
76
76
|
|
77
|
-
@car.attributes = {:bars_attributes=>[{}, {:id
|
77
|
+
@car.attributes = {:bars_attributes => [{}, {:id => @bar1.pid, :uno => 'bar1 uno'}, {:id => @bar2.pid, :dos => 'bar2 dos'}]}
|
78
78
|
@bar1.reload
|
79
79
|
@bar2.reload
|
80
|
-
@bar1.uno.
|
81
|
-
@bar2.dos.
|
80
|
+
expect(@bar1.uno).to eq('bar1 uno')
|
81
|
+
expect(@bar2.dos).to be_nil
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
84
|
+
it 'should reject attributes base on method name' do
|
85
85
|
@car, @bar1, @bar2 = create_car_with_bars(CarSymbol)
|
86
86
|
|
87
|
-
@car.attributes = {:bars_attributes=>[{}, {:id
|
87
|
+
@car.attributes = {:bars_attributes => [{}, {:id => @bar1.pid, :uno => 'bar1 uno'}, {:id => @bar2.pid, :dos => 'bar2 dos'}]}
|
88
88
|
@bar1.reload
|
89
89
|
@bar2.reload
|
90
|
-
@bar1.uno.
|
91
|
-
@bar2.dos.
|
90
|
+
expect(@bar1.uno).to eq('bar1 uno')
|
91
|
+
expect(@bar2.dos).to be_nil
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it 'should throw TooManyRecords' do
|
95
95
|
@car, @bar1, @bar2 = create_car_with_bars(CarWithLimit)
|
96
96
|
|
97
|
-
|
98
|
-
@car.attributes = {:bars_attributes=>[{}]}
|
99
|
-
}.
|
97
|
+
expect {
|
98
|
+
@car.attributes = {:bars_attributes => [{}]}
|
99
|
+
}.not_to raise_exception
|
100
100
|
|
101
|
-
|
102
|
-
@car.attributes = {:bars_attributes=>[{}, {}]}
|
103
|
-
}.
|
101
|
+
expect {
|
102
|
+
@car.attributes = {:bars_attributes => [{}, {}]}
|
103
|
+
}.to raise_exception(ActiveFedora::NestedAttributes::TooManyRecords)
|
104
104
|
end
|
105
105
|
|
106
106
|
private
|
@@ -114,8 +114,8 @@ describe "NestedAttribute behavior" do
|
|
114
114
|
def create_car_with_bars(car_class = Car, bar_class = Bar)
|
115
115
|
car = car_class.new; car.save
|
116
116
|
|
117
|
-
bar1 = bar_class.new(:car=>car); bar1.save
|
118
|
-
bar2 = bar_class.new(:car=>car); bar2.save
|
117
|
+
bar1 = bar_class.new(:car => car); bar1.save
|
118
|
+
bar2 = bar_class.new(:car => car); bar2.save
|
119
119
|
[car, bar1, bar2]
|
120
120
|
end
|
121
121
|
|
@@ -7,17 +7,17 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
7
7
|
map.title(:in => RDF::DC) do |index|
|
8
8
|
index.as :stored_searchable, :facetable
|
9
9
|
end
|
10
|
-
map.date_uploaded(:to =>
|
10
|
+
map.date_uploaded(:to => 'dateSubmitted', :in => RDF::DC) do |index|
|
11
11
|
index.type :date
|
12
12
|
index.as :stored_searchable, :sortable
|
13
13
|
end
|
14
|
-
map.part(:to =>
|
14
|
+
map.part(:to => 'hasPart', :in => RDF::DC)
|
15
15
|
map.based_near(:in => RDF::FOAF)
|
16
|
-
map.related_url(:to =>
|
16
|
+
map.related_url(:to => 'seeAlso', :in => RDF::RDFS)
|
17
17
|
end
|
18
18
|
end
|
19
|
-
class RdfTest < ActiveFedora::Base
|
20
|
-
has_metadata :name=>'rdf', :type=>MyDatastream
|
19
|
+
class RdfTest < ActiveFedora::Base
|
20
|
+
has_metadata :name => 'rdf', :type => MyDatastream
|
21
21
|
delegate_to 'rdf', [:based_near, :related_url, :part, :date_uploaded], multiple: true
|
22
22
|
delegate :title, to: 'rdf', multiple: false
|
23
23
|
end
|
@@ -33,105 +33,105 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
33
33
|
Object.send(:remove_const, :MyDatastream)
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'should not try to send an empty datastream' do
|
37
37
|
@subject.save
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
foo = RdfTest.new(:pid=>'test:1') #Pid needs to match the subject in the loaded file
|
40
|
+
it 'should save content properly upon save' do
|
41
|
+
foo = RdfTest.new(:pid => 'test:1') #Pid needs to match the subject in the loaded file
|
42
42
|
foo.title = 'Hamlet'
|
43
43
|
foo.save
|
44
|
-
foo.title.
|
44
|
+
expect(foo.title).to eq('Hamlet')
|
45
45
|
foo.rdf.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
|
46
46
|
foo.save
|
47
|
-
foo.title.
|
47
|
+
expect(foo.title).to eq('Title of work')
|
48
48
|
end
|
49
49
|
|
50
|
-
it
|
51
|
-
@subject = RdfTest.new(title:
|
52
|
-
@subject.rdf.title.as_json.
|
53
|
-
@subject.rdf.title.to_json.
|
50
|
+
it 'should delegate as_json to the fields' do
|
51
|
+
@subject = RdfTest.new(title: 'Title of work')
|
52
|
+
expect(@subject.rdf.title.as_json).to eq(['Title of work'])
|
53
|
+
expect(@subject.rdf.title.to_json).to eq("\[\"Title of work\"\]")
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should solrize even when the object is not new' do
|
57
57
|
foo = RdfTest.new
|
58
|
-
foo.
|
59
|
-
foo.title =
|
58
|
+
expect(foo).to receive(:update_index).once
|
59
|
+
foo.title = 'title1'
|
60
60
|
foo.save
|
61
61
|
foo = RdfTest.find(foo.pid)
|
62
|
-
foo.
|
63
|
-
foo.title =
|
64
|
-
foo.save
|
62
|
+
expect(foo).to receive(:update_index).once
|
63
|
+
foo.title = 'The Work2'
|
64
|
+
foo.save
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it 'should serialize dates' do
|
68
68
|
subject.date_uploaded = Date.parse('2012-11-02')
|
69
|
-
subject.date_uploaded.first.
|
69
|
+
expect(subject.date_uploaded.first).to be_kind_of Date
|
70
70
|
solr_document = subject.to_solr
|
71
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)].
|
71
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)]).to eq(['2012-11-02T00:00:00Z'])
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
@subject = RdfTest.new(title:
|
74
|
+
it 'should produce a solr document' do
|
75
|
+
@subject = RdfTest.new(title: 'War and Peace')
|
76
76
|
solr_document = @subject.to_solr
|
77
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)].
|
78
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)].
|
77
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)]).to eq(['War and Peace'])
|
78
|
+
expect(solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)]).to eq(['War and Peace'])
|
79
79
|
end
|
80
80
|
|
81
|
-
it
|
81
|
+
it 'should set and recall values' do
|
82
82
|
@subject.title = 'War and Peace'
|
83
|
-
@subject.rdf.
|
84
|
-
@subject.based_near =
|
85
|
-
@subject.related_url =
|
86
|
-
@subject.part =
|
83
|
+
expect(@subject.rdf).to be_changed
|
84
|
+
@subject.based_near = 'Moscow, Russia'
|
85
|
+
@subject.related_url = 'http://en.wikipedia.org/wiki/War_and_Peace'
|
86
|
+
@subject.part = 'this is a part'
|
87
87
|
@subject.save
|
88
|
-
@subject.title.
|
89
|
-
@subject.based_near.
|
90
|
-
@subject.related_url.
|
91
|
-
@subject.part.
|
88
|
+
expect(@subject.title).to eq('War and Peace')
|
89
|
+
expect(@subject.based_near).to eq(['Moscow, Russia'])
|
90
|
+
expect(@subject.related_url).to eq(['http://en.wikipedia.org/wiki/War_and_Peace'])
|
91
|
+
expect(@subject.part).to eq(['this is a part'])
|
92
92
|
end
|
93
|
-
it
|
93
|
+
it 'should set, persist, and recall values' do
|
94
94
|
@subject.title = 'War and Peace'
|
95
|
-
@subject.based_near =
|
96
|
-
@subject.related_url =
|
97
|
-
@subject.part =
|
95
|
+
@subject.based_near = 'Moscow, Russia'
|
96
|
+
@subject.related_url = 'http://en.wikipedia.org/wiki/War_and_Peace'
|
97
|
+
@subject.part = 'this is a part'
|
98
98
|
@subject.save
|
99
99
|
|
100
100
|
loaded = RdfTest.find(@subject.pid)
|
101
|
-
loaded.title.
|
102
|
-
loaded.based_near.
|
103
|
-
loaded.related_url.
|
104
|
-
loaded.part.
|
101
|
+
expect(loaded.title).to eq('War and Peace')
|
102
|
+
expect(loaded.based_near).to eq(['Moscow, Russia'])
|
103
|
+
expect(loaded.related_url).to eq(['http://en.wikipedia.org/wiki/War_and_Peace'])
|
104
|
+
expect(loaded.part).to eq(['this is a part'])
|
105
105
|
end
|
106
|
-
it
|
107
|
-
@subject.part = [
|
106
|
+
it 'should set multiple values' do
|
107
|
+
@subject.part = ['part 1', 'part 2']
|
108
108
|
@subject.save
|
109
109
|
|
110
110
|
loaded = RdfTest.find(@subject.pid)
|
111
|
-
loaded.part.
|
111
|
+
expect(loaded.part).to eq(['part 1', 'part 2'])
|
112
112
|
end
|
113
|
-
it
|
114
|
-
@subject.part =
|
113
|
+
it 'should append values' do
|
114
|
+
@subject.part = 'thing 1'
|
115
115
|
@subject.save
|
116
116
|
|
117
|
-
@subject.part <<
|
118
|
-
@subject.part.
|
117
|
+
@subject.part << 'thing 2'
|
118
|
+
expect(@subject.part).to eq(['thing 1', 'thing 2'])
|
119
119
|
end
|
120
120
|
|
121
|
-
it
|
122
|
-
@subject.title =
|
121
|
+
it 'should be able to save a blank document' do
|
122
|
+
@subject.title = ''
|
123
123
|
@subject.save
|
124
124
|
end
|
125
125
|
|
126
|
-
it
|
126
|
+
it 'should load n-triples into the graph' do
|
127
127
|
ntrip = '<http://oregondigital.org/ns/62> <http://purl.org/dc/terms/type> "Image" .
|
128
128
|
<http://oregondigital.org/ns/62> <http://purl.org/dc/terms/spatial> "Benton County (Ore.)" .
|
129
129
|
'
|
130
130
|
@subject.rdf.content = ntrip
|
131
|
-
@subject.rdf.graph.dump(:ntriples).
|
131
|
+
expect(@subject.rdf.graph.dump(:ntriples)).to eq(ntrip)
|
132
132
|
end
|
133
133
|
|
134
|
-
describe
|
134
|
+
describe 'using rdf_subject' do
|
135
135
|
before do
|
136
136
|
# reopening existing class
|
137
137
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
@@ -146,12 +146,12 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
146
146
|
@subject.destroy
|
147
147
|
end
|
148
148
|
|
149
|
-
it
|
149
|
+
it 'should write rdf with proper subjects' do
|
150
150
|
@subject.inner_object.pid = 'test:99'
|
151
|
-
@subject.rdf.type =
|
151
|
+
@subject.rdf.type = 'Frog'
|
152
152
|
@subject.save!
|
153
153
|
@subject.reload
|
154
|
-
@subject.rdf.graph.dump(:ntriples).
|
154
|
+
expect(@subject.rdf.graph.dump(:ntriples)).to eq("<http://oregondigital.org/ns/99> <http://purl.org/dc/terms/type> \"Frog\" .\n")
|
155
155
|
@subject.rdf.type == ['Frog']
|
156
156
|
|
157
157
|
end
|
@@ -159,49 +159,49 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
|
162
|
-
it
|
163
|
-
@subject.title =
|
164
|
-
@subject.related_url =
|
165
|
-
@subject.related_url <<
|
162
|
+
it 'should delete values' do
|
163
|
+
@subject.title = 'Hamlet'
|
164
|
+
@subject.related_url = 'http://psu.edu/'
|
165
|
+
@subject.related_url << 'http://projecthydra.org/'
|
166
166
|
|
167
|
-
@subject.title.
|
168
|
-
@subject.related_url.
|
169
|
-
@subject.related_url.
|
167
|
+
expect(@subject.title).to eq('Hamlet')
|
168
|
+
expect(@subject.related_url).to include('http://psu.edu/')
|
169
|
+
expect(@subject.related_url).to include('http://projecthydra.org/')
|
170
170
|
|
171
|
-
@subject.title =
|
172
|
-
@subject.title.
|
171
|
+
@subject.title = '' #empty string can be meaningful, don't assume delete.
|
172
|
+
expect(@subject.title).to eq('')
|
173
173
|
|
174
174
|
@subject.title = nil
|
175
|
-
@subject.related_url.delete(
|
176
|
-
|
177
|
-
@subject.title.
|
178
|
-
@subject.related_url.
|
179
|
-
end
|
180
|
-
it
|
181
|
-
@subject.part =
|
182
|
-
@subject.part <<
|
183
|
-
@subject.part <<
|
184
|
-
@subject.part.first.
|
185
|
-
@subject.part.delete(
|
186
|
-
@subject.part.
|
187
|
-
@subject.part.first.
|
188
|
-
end
|
189
|
-
it
|
190
|
-
@subject.part = [
|
191
|
-
@subject.part.delete(
|
192
|
-
@subject.part.
|
193
|
-
end
|
194
|
-
describe
|
175
|
+
@subject.related_url.delete('http://projecthydra.org/')
|
176
|
+
|
177
|
+
expect(@subject.title).to be_nil
|
178
|
+
expect(@subject.related_url).to eq(['http://psu.edu/'])
|
179
|
+
end
|
180
|
+
it 'should delete multiple values at once' do
|
181
|
+
@subject.part = 'MacBeth'
|
182
|
+
@subject.part << 'Hamlet'
|
183
|
+
@subject.part << 'Romeo & Juliet'
|
184
|
+
expect(@subject.part.first).to eq('MacBeth')
|
185
|
+
@subject.part.delete('MacBeth', 'Romeo & Juliet')
|
186
|
+
expect(@subject.part).to eq(['Hamlet'])
|
187
|
+
expect(@subject.part.first).to eq('Hamlet')
|
188
|
+
end
|
189
|
+
it 'should ignore values to be deleted that do not exist' do
|
190
|
+
@subject.part = ['title1', 'title2', 'title3']
|
191
|
+
@subject.part.delete('title2', 'title4', 'title6')
|
192
|
+
expect(@subject.part).to eq(['title1', 'title3'])
|
193
|
+
end
|
194
|
+
describe 'term proxy methods' do
|
195
195
|
before(:each) do
|
196
196
|
class TitleDatastream < ActiveFedora::NtriplesRDFDatastream
|
197
197
|
map_predicates { |map| map.title(:in => RDF::DC) }
|
198
198
|
end
|
199
|
-
class Foobar < ActiveFedora::Base
|
200
|
-
has_metadata :name=>'rdf', :type=>TitleDatastream
|
201
|
-
delegate :title, :to=>'rdf', multiple: true
|
199
|
+
class Foobar < ActiveFedora::Base
|
200
|
+
has_metadata :name => 'rdf', :type => TitleDatastream
|
201
|
+
delegate :title, :to => 'rdf', multiple: true
|
202
202
|
end
|
203
203
|
@subject = Foobar.new
|
204
|
-
@subject.title = [
|
204
|
+
@subject.title = ['title1', 'title2', 'title3']
|
205
205
|
end
|
206
206
|
|
207
207
|
after(:each) do
|
@@ -209,26 +209,26 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
209
209
|
Object.send(:remove_const, :TitleDatastream)
|
210
210
|
end
|
211
211
|
|
212
|
-
it
|
213
|
-
@subject.title.count.
|
212
|
+
it 'should support the count method to determine # of values' do
|
213
|
+
expect(@subject.title.count).to eq(3)
|
214
214
|
end
|
215
|
-
it
|
216
|
-
@subject.title.
|
215
|
+
it 'should iterate over multiple values' do
|
216
|
+
expect(@subject.title).to respond_to(:each)
|
217
217
|
end
|
218
|
-
it
|
219
|
-
@subject.title.first.
|
218
|
+
it 'should get the first value' do
|
219
|
+
expect(@subject.title.first).to eq('title1')
|
220
220
|
end
|
221
|
-
it
|
222
|
-
@subject.title.
|
221
|
+
it 'should evaluate equality predictably' do
|
222
|
+
expect(@subject.title).to eq(['title1', 'title2', 'title3'])
|
223
223
|
end
|
224
|
-
it
|
225
|
-
@subject.title.
|
226
|
-
@subject.title.empty
|
227
|
-
@subject.title.delete(
|
228
|
-
@subject.title.empty
|
224
|
+
it 'should support the empty? method' do
|
225
|
+
expect(@subject.title).to respond_to(:empty?)
|
226
|
+
expect(@subject.title.empty?).to be_falsey
|
227
|
+
@subject.title.delete('title1', 'title2', 'title3')
|
228
|
+
expect(@subject.title.empty?).to be_truthy
|
229
229
|
end
|
230
|
-
it
|
231
|
-
@subject.title.is_a?(Array).
|
230
|
+
it 'should support the is_a? method' do
|
231
|
+
expect(@subject.title.is_a?(Array)).to eq(true)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|