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,14 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::AssociationProxy do
|
4
|
-
it
|
5
|
-
|
6
|
-
@owner =
|
4
|
+
it 'should delegate to_param' do
|
5
|
+
skip
|
6
|
+
@owner = double(:new_record? => false)
|
7
7
|
@assoc = ActiveFedora::Associations::AssociationProxy.new(@owner, @reflection)
|
8
|
-
@assoc.
|
8
|
+
expect(@assoc).to receive(:find_target).and_return(double(:to_param => '1234'))
|
9
9
|
@assoc.send(:load_target)
|
10
|
-
@assoc.to_param.
|
11
|
-
|
10
|
+
expect(@assoc.to_param).to eq('1234')
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
@@ -1,54 +1,54 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
describe
|
5
|
-
class BarStream < ActiveFedora::OmDatastream
|
4
|
+
describe 'active model methods' do
|
5
|
+
class BarStream < ActiveFedora::OmDatastream
|
6
6
|
set_terminology do |t|
|
7
|
-
t.root(:path=>
|
7
|
+
t.root(:path => 'first', :xmlns => 'urn:foobar')
|
8
8
|
t.duck()
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.xml_template
|
12
|
-
Nokogiri::XML::Document.parse '<first xmlns="urn:foobar">
|
12
|
+
Nokogiri::XML::Document.parse '<first xmlns="urn:foobar">
|
13
13
|
<duck></duck>
|
14
14
|
</first>'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
class BarHistory < ActiveFedora::Base
|
19
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
20
|
-
m.field
|
21
|
-
m.field
|
19
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData' do |m|
|
20
|
+
m.field 'fubar', :string
|
21
|
+
m.field 'swank', :text
|
22
22
|
end
|
23
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
24
|
-
m.field
|
23
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText' do |m|
|
24
|
+
m.field 'fubar', :text
|
25
|
+
end
|
26
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText2', :label => 'withLabel' do |m|
|
27
|
+
m.field 'fubar', :text
|
25
28
|
end
|
26
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel" do |m|
|
27
|
-
m.field "fubar", :text
|
28
|
-
end
|
29
29
|
|
30
|
-
has_metadata :type=>BarStream, :name=>
|
30
|
+
has_metadata :type => BarStream, :name => 'xmlish'
|
31
31
|
delegate :fubar, to: 'withText', multiple: false
|
32
32
|
delegate :duck, to: 'xmlish', multiple: false
|
33
33
|
end
|
34
34
|
before :each do
|
35
35
|
@n = BarHistory.new()
|
36
36
|
end
|
37
|
-
describe
|
38
|
-
it
|
39
|
-
@n.attributes = {:fubar=>
|
40
|
-
@n.fubar.
|
41
|
-
@n.withText.get_values(:fubar).first.
|
42
|
-
@n.duck.
|
43
|
-
@n.xmlish.term_values(:duck).first.
|
37
|
+
describe 'attributes=' do
|
38
|
+
it 'should set attributes' do
|
39
|
+
@n.attributes = {:fubar => 'baz', :duck => 'Quack'}
|
40
|
+
expect(@n.fubar).to eq('baz')
|
41
|
+
expect(@n.withText.get_values(:fubar).first).to eq('baz')
|
42
|
+
expect(@n.duck).to eq('Quack')
|
43
|
+
expect(@n.xmlish.term_values(:duck).first).to eq('Quack')
|
44
44
|
end
|
45
45
|
end
|
46
|
-
describe
|
47
|
-
it
|
48
|
-
@n.update_attributes(:fubar=>
|
46
|
+
describe 'update_attributes' do
|
47
|
+
it 'should set attributes and save ' do
|
48
|
+
@n.update_attributes(:fubar => 'baz', :duck => 'Quack')
|
49
49
|
@q = BarHistory.find(@n.pid)
|
50
|
-
@q.fubar.
|
51
|
-
@q.duck.
|
50
|
+
expect(@q.fubar).to eq('baz')
|
51
|
+
expect(@q.duck).to eq('Quack')
|
52
52
|
end
|
53
53
|
after do
|
54
54
|
@n.delete
|
@@ -57,4 +57,3 @@ describe ActiveFedora::Base do
|
|
57
57
|
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
data/spec/unit/base_cma_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@test_object = ActiveFedora::Base.new
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
describe '.save' do
|
10
10
|
|
11
|
-
it
|
12
|
-
@test_object.
|
13
|
-
@test_object.
|
11
|
+
it 'should add hasModel relationship that points to the CModel if @new_object' do
|
12
|
+
allow(@test_object).to receive(:update_index)
|
13
|
+
expect(@test_object).to receive(:refresh)
|
14
14
|
@test_object.save
|
15
15
|
end
|
16
16
|
end
|
@@ -1,57 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@test_object = ActiveFedora::Base.new
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
describe '.generate_dsid' do
|
10
|
-
it
|
11
|
-
dsids = Hash[
|
12
|
-
@test_object.
|
10
|
+
it 'should return a dsid that is not currently in use' do
|
11
|
+
dsids = Hash['DS1' => 1, 'DS2' => 1]
|
12
|
+
expect(@test_object).to receive(:datastreams).and_return(dsids)
|
13
13
|
generated_id = @test_object.generate_dsid
|
14
|
-
generated_id.
|
15
|
-
generated_id.
|
14
|
+
expect(generated_id).not_to be_nil
|
15
|
+
expect(generated_id).to eq('DS3')
|
16
16
|
end
|
17
|
-
it
|
18
|
-
@test_object.generate_dsid(
|
17
|
+
it 'should accept a prefix argument, default to using DS as prefix' do
|
18
|
+
expect(@test_object.generate_dsid('FOO')).to eq('FOO1')
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
22
|
-
dsids = Hash[
|
23
|
-
@test_object.
|
21
|
+
it 'if delete a datastream it should still use next index for a prefix' do
|
22
|
+
dsids = Hash['DS2' => 1]
|
23
|
+
expect(@test_object).to receive(:datastreams).and_return(dsids)
|
24
24
|
generated_id = @test_object.generate_dsid
|
25
|
-
generated_id.
|
26
|
-
generated_id.
|
25
|
+
expect(generated_id).not_to be_nil
|
26
|
+
expect(generated_id).to eq('DS3')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
describe '.add_datastream' do
|
30
|
-
it
|
30
|
+
it 'should not call Datastream.save' do
|
31
31
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
|
32
|
-
ds.
|
32
|
+
expect(ds).to receive(:save).never
|
33
33
|
@test_object.add_datastream(ds)
|
34
34
|
end
|
35
|
-
it
|
35
|
+
it 'should add the datastream to the datastreams_in_memory array' do
|
36
36
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
|
37
|
-
@test_object.datastreams.
|
37
|
+
expect(@test_object.datastreams).not_to have_key(ds.dsid)
|
38
38
|
@test_object.add_datastream(ds)
|
39
|
-
@test_object.datastreams.
|
39
|
+
expect(@test_object.datastreams).to have_key(ds.dsid)
|
40
40
|
end
|
41
|
-
it
|
41
|
+
it 'should auto-assign dsids using auto-incremented integers if dsid is nil or an empty string' do
|
42
42
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
|
43
|
-
ds.dsid.
|
43
|
+
expect(ds.dsid).to be_nil
|
44
44
|
ds_emptystringid = ActiveFedora::Datastream.new(@test_object.inner_object, '')
|
45
45
|
@test_object.stub(:generate_dsid => 'foo')
|
46
46
|
# ds.should_receive(:dsid=).with("foo")
|
47
|
-
@test_object.add_datastream(ds).
|
48
|
-
@test_object.add_datastream(ds_emptystringid).
|
47
|
+
expect(@test_object.add_datastream(ds)).to eq('foo')
|
48
|
+
expect(@test_object.add_datastream(ds_emptystringid)).to eq('foo')
|
49
49
|
end
|
50
|
-
it
|
50
|
+
it 'should accept a prefix option and apply it to automatically assigned dsids' do
|
51
51
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
|
52
|
-
ds.dsid.
|
53
|
-
@test_object.stub(:generate_dsid =>
|
54
|
-
@test_object.add_datastream(ds, :prefix =>
|
52
|
+
expect(ds.dsid).to be_nil
|
53
|
+
@test_object.stub(:generate_dsid => 'FOO')
|
54
|
+
expect(@test_object.add_datastream(ds, :prefix => 'FOO')).to eq('FOO')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
before :all do
|
5
|
-
class BarStream2 < ActiveFedora::OmDatastream
|
5
|
+
class BarStream2 < ActiveFedora::OmDatastream
|
6
6
|
set_terminology do |t|
|
7
|
-
t.root(:path=>
|
7
|
+
t.root(:path => 'animals', :xmlns => 'urn:zoobar')
|
8
8
|
t.waterfowl do
|
9
|
-
t.ducks do
|
9
|
+
t.ducks do
|
10
10
|
t.duck
|
11
11
|
end
|
12
12
|
end
|
@@ -17,7 +17,7 @@ describe ActiveFedora::Base do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.xml_template
|
20
|
-
Nokogiri::XML::Document.parse '<animals xmlns="urn:zoobar">
|
20
|
+
Nokogiri::XML::Document.parse '<animals xmlns="urn:zoobar">
|
21
21
|
<waterfowl>
|
22
22
|
<ducks>
|
23
23
|
<duck/>
|
@@ -33,28 +33,28 @@ describe ActiveFedora::Base do
|
|
33
33
|
Object.send(:remove_const, :BarStream2)
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
36
|
+
describe 'first level delegation' do
|
37
37
|
before :all do
|
38
38
|
class BarHistory2 < ActiveFedora::Base
|
39
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
40
|
-
m.field
|
41
|
-
m.field
|
42
|
-
m.field
|
39
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'someData' do |m|
|
40
|
+
m.field 'fubar', :string
|
41
|
+
m.field 'bandana', :string
|
42
|
+
m.field 'swank', :text
|
43
43
|
end
|
44
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
45
|
-
m.field
|
44
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText' do |m|
|
45
|
+
m.field 'fubar', :text
|
46
46
|
end
|
47
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>
|
48
|
-
m.field
|
49
|
-
end
|
50
|
-
|
51
|
-
has_metadata :type=>BarStream2, :name=>
|
52
|
-
delegate :fubar, :to=>'withText', :unique=>true
|
53
|
-
delegate :donkey, :to=>'xmlish', :unique=>true
|
54
|
-
delegate :cow, :to=>'xmlish' # for testing the default value of multiple
|
55
|
-
delegate :pig, :to=>'xmlish', multiple: false
|
56
|
-
delegate :horse, :to=>'xmlish', multiple: true
|
57
|
-
delegate :duck, :to=>'xmlish', :at=>[:waterfowl, :ducks], multiple: true
|
47
|
+
has_metadata :type => ActiveFedora::SimpleDatastream, :name => 'withText2', :label => 'withLabel' do |m|
|
48
|
+
m.field 'fubar', :text
|
49
|
+
end
|
50
|
+
|
51
|
+
has_metadata :type => BarStream2, :name => 'xmlish'
|
52
|
+
delegate :fubar, :to => 'withText', :unique => true
|
53
|
+
delegate :donkey, :to => 'xmlish', :unique => true
|
54
|
+
delegate :cow, :to => 'xmlish' # for testing the default value of multiple
|
55
|
+
delegate :pig, :to => 'xmlish', multiple: false
|
56
|
+
delegate :horse, :to => 'xmlish', multiple: true
|
57
|
+
delegate :duck, :to => 'xmlish', :at => [:waterfowl, :ducks], multiple: true
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -64,58 +64,58 @@ describe ActiveFedora::Base do
|
|
64
64
|
|
65
65
|
subject { BarHistory2.new() }
|
66
66
|
|
67
|
-
it
|
68
|
-
BarHistory2.unique?(:fubar).
|
69
|
-
BarHistory2.unique?(:cow).
|
67
|
+
it 'should reveal the unique properties' do
|
68
|
+
expect(BarHistory2.unique?(:fubar)).to be_truthy
|
69
|
+
expect(BarHistory2.unique?(:cow)).to be_falsey
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
73
|
-
subject.fubar=
|
74
|
-
subject.fubar.
|
75
|
-
subject.withText.get_values(:fubar).first.
|
76
|
-
subject.donkey=
|
77
|
-
subject.donkey.
|
78
|
-
subject.xmlish.term_values(:donkey).first.
|
72
|
+
it 'should save a delegated property uniquely' do
|
73
|
+
subject.fubar = 'Quack'
|
74
|
+
expect(subject.fubar).to eq('Quack')
|
75
|
+
expect(subject.withText.get_values(:fubar).first).to eq('Quack')
|
76
|
+
subject.donkey = 'Bray'
|
77
|
+
expect(subject.donkey).to eq('Bray')
|
78
|
+
expect(subject.xmlish.term_values(:donkey).first).to eq('Bray')
|
79
79
|
|
80
|
-
subject.pig=
|
81
|
-
subject.pig.
|
80
|
+
subject.pig = 'Oink'
|
81
|
+
expect(subject.pig).to eq('Oink')
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
85
|
-
subject.cow=[
|
86
|
-
subject.cow(1).
|
84
|
+
it 'should allow passing parameters to the delegate accessor' do
|
85
|
+
subject.cow = ['one', 'two']
|
86
|
+
expect(subject.cow(1)).to eq(['two'])
|
87
87
|
end
|
88
88
|
|
89
89
|
|
90
|
-
it
|
90
|
+
it 'should return an array if not marked as unique' do
|
91
91
|
### Metadata datastream does not appear to support multiple value setting
|
92
|
-
subject.cow=[
|
93
|
-
subject.cow.
|
92
|
+
subject.cow = ['one', 'two']
|
93
|
+
expect(subject.cow).to eq(['one', 'two'])
|
94
94
|
|
95
|
-
subject.horse=[
|
96
|
-
subject.horse.
|
95
|
+
subject.horse = ['neigh', 'whinny']
|
96
|
+
expect(subject.horse).to eq(['neigh', 'whinny'])
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
100
|
-
subject.duck=[
|
101
|
-
subject.duck.
|
99
|
+
it 'should be able to delegate deeply into the terminology' do
|
100
|
+
subject.duck = ['Quack', 'Peep']
|
101
|
+
expect(subject.duck).to eq(['Quack', 'Peep'])
|
102
102
|
end
|
103
103
|
|
104
|
-
it
|
105
|
-
subject.fubar_changed
|
106
|
-
subject.fubar =
|
107
|
-
subject.fubar_changed
|
104
|
+
it 'should be able to track change status' do
|
105
|
+
expect(subject.fubar_changed?).to be_falsey
|
106
|
+
subject.fubar = 'Meow'
|
107
|
+
expect(subject.fubar_changed?).to be_truthy
|
108
108
|
end
|
109
109
|
|
110
|
-
describe
|
111
|
-
it
|
112
|
-
subject[:duck]= [
|
113
|
-
subject[:duck].
|
110
|
+
describe 'array getters and setters' do
|
111
|
+
it 'should accept symbol keys' do
|
112
|
+
subject[:duck] = ['Cluck', 'Gobble']
|
113
|
+
expect(subject[:duck]).to eq(['Cluck', 'Gobble'])
|
114
114
|
end
|
115
115
|
|
116
|
-
it
|
117
|
-
subject['duck']= [
|
118
|
-
subject['duck'].
|
116
|
+
it 'should accept string keys' do
|
117
|
+
subject['duck'] = ['Cluck', 'Gobble']
|
118
|
+
expect(subject['duck']).to eq(['Cluck', 'Gobble'])
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should raise an error on the reader when the field isn't delegated" do
|
@@ -123,16 +123,16 @@ describe ActiveFedora::Base do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should raise an error on the setter when the field isn't delegated" do
|
126
|
-
expect {subject['goose']=
|
126
|
+
expect {subject['goose'] = 'honk' }.to raise_error ActiveFedora::UnknownAttributeError, "BarHistory2 does not have an attribute `goose'"
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
end
|
131
131
|
|
132
|
-
describe
|
132
|
+
describe 'with a superclass' do
|
133
133
|
before :all do
|
134
134
|
class BarHistory2 < ActiveFedora::Base
|
135
|
-
has_metadata 'xmlish', :type=>BarStream2
|
135
|
+
has_metadata 'xmlish', :type => BarStream2
|
136
136
|
delegate_to 'xmlish', [:donkey, :cow], multiple: true
|
137
137
|
end
|
138
138
|
class BarHistory3 < BarHistory2
|
@@ -146,19 +146,19 @@ describe ActiveFedora::Base do
|
|
146
146
|
|
147
147
|
subject { BarHistory3.new }
|
148
148
|
|
149
|
-
it
|
150
|
-
subject.donkey=[
|
151
|
-
subject.donkey.
|
149
|
+
it 'should be able to delegate deeply into the terminology' do
|
150
|
+
subject.donkey = ['Bray', 'Hee-haw']
|
151
|
+
expect(subject.donkey).to eq(['Bray', 'Hee-haw'])
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
155
|
-
subject.cow_changed
|
156
|
-
subject.cow = [
|
157
|
-
subject.cow_changed
|
158
|
-
end
|
154
|
+
it 'should be able to track change status' do
|
155
|
+
expect(subject.cow_changed?).to be_falsey
|
156
|
+
subject.cow = ['Moo']
|
157
|
+
expect(subject.cow_changed?).to be_truthy
|
158
|
+
end
|
159
159
|
end
|
160
160
|
|
161
|
-
describe
|
161
|
+
describe 'with a RDF datastream' do
|
162
162
|
before :all do
|
163
163
|
class BarRdfDatastream < ActiveFedora::NtriplesRDFDatastream
|
164
164
|
map_predicates do |map|
|
@@ -167,7 +167,7 @@ describe ActiveFedora::Base do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
class BarHistory4 < ActiveFedora::Base
|
170
|
-
has_metadata 'rdfish', :type=>BarRdfDatastream
|
170
|
+
has_metadata 'rdfish', :type => BarRdfDatastream
|
171
171
|
delegate_to 'rdfish', [:title, :description], multiple: true
|
172
172
|
end
|
173
173
|
end
|
@@ -179,21 +179,19 @@ describe ActiveFedora::Base do
|
|
179
179
|
|
180
180
|
subject { BarHistory4.new }
|
181
181
|
|
182
|
-
describe
|
183
|
-
it
|
184
|
-
subject.title_changed
|
185
|
-
subject.title = [
|
186
|
-
subject.title_changed
|
182
|
+
describe 'with a multivalued field' do
|
183
|
+
it 'should be able to track change status' do
|
184
|
+
expect(subject.title_changed?).to be_falsey
|
185
|
+
subject.title = ['Title1', 'Title2']
|
186
|
+
expect(subject.title_changed?).to be_truthy
|
187
187
|
end
|
188
188
|
end
|
189
|
-
describe
|
190
|
-
it
|
191
|
-
subject.description_changed
|
192
|
-
subject.description =
|
193
|
-
subject.description_changed
|
189
|
+
describe 'with a single-valued field' do
|
190
|
+
it 'should be able to track change status' do
|
191
|
+
expect(subject.description_changed?).to be_falsey
|
192
|
+
subject.description = 'A brief description'
|
193
|
+
expect(subject.description_changed?).to be_truthy
|
194
194
|
end
|
195
195
|
end
|
196
|
-
end
|
196
|
+
end
|
197
197
|
end
|
198
|
-
|
199
|
-
|