active-fedora 6.7.8 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
|
3
|
-
require
|
|
3
|
+
require 'active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher'
|
|
4
4
|
|
|
5
|
-
describe RSpec::Matchers,
|
|
5
|
+
describe RSpec::Matchers, 'belong_to_associated_active_fedora_object_matcher' do
|
|
6
6
|
subject { OpenStruct.new(:pid => pid )}
|
|
7
7
|
let(:pid) { 123 }
|
|
8
8
|
let(:object1) { Object.new }
|
|
@@ -10,17 +10,17 @@ describe RSpec::Matchers, "belong_to_associated_active_fedora_object_matcher" do
|
|
|
10
10
|
let(:association) { :association }
|
|
11
11
|
|
|
12
12
|
it 'should match when association is properly stored in fedora' do
|
|
13
|
-
subject.class.
|
|
14
|
-
subject.
|
|
15
|
-
subject.
|
|
13
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
14
|
+
expect(subject).to receive(association).and_return(object1)
|
|
15
|
+
expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object1)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it 'should not match when association is different' do
|
|
19
|
-
subject.class.
|
|
20
|
-
subject.
|
|
21
|
-
|
|
22
|
-
subject.
|
|
23
|
-
}.
|
|
19
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
20
|
+
expect(subject).to receive(association).and_return(object1)
|
|
21
|
+
expect {
|
|
22
|
+
expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object2)
|
|
23
|
+
}.to (
|
|
24
24
|
raise_error(
|
|
25
25
|
RSpec::Expectations::ExpectationNotMetError,
|
|
26
26
|
/expected #{subject.class} PID=#{pid} association: #{association.inspect}/
|
|
@@ -29,12 +29,12 @@ describe RSpec::Matchers, "belong_to_associated_active_fedora_object_matcher" do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'should require :with_object option' do
|
|
32
|
-
|
|
33
|
-
subject.
|
|
34
|
-
}.
|
|
32
|
+
expect {
|
|
33
|
+
expect(subject).to belong_to_associated_active_fedora_object(association)
|
|
34
|
+
}.to(
|
|
35
35
|
raise_error(
|
|
36
36
|
ArgumentError,
|
|
37
|
-
|
|
37
|
+
'subject.should belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)'
|
|
38
38
|
)
|
|
39
39
|
)
|
|
40
40
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
|
3
|
-
require
|
|
3
|
+
require 'active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher'
|
|
4
4
|
|
|
5
|
-
describe RSpec::Matchers,
|
|
5
|
+
describe RSpec::Matchers, 'have_many_associated_active_fedora_objects_matcher' do
|
|
6
6
|
subject { OpenStruct.new(:pid => pid )}
|
|
7
7
|
let(:pid) { 123 }
|
|
8
8
|
let(:object1) { Object.new }
|
|
@@ -11,17 +11,17 @@ describe RSpec::Matchers, "have_many_associated_active_fedora_objects_matcher" d
|
|
|
11
11
|
let(:association) { :association }
|
|
12
12
|
|
|
13
13
|
it 'should match when association is properly stored in fedora' do
|
|
14
|
-
subject.class.
|
|
15
|
-
subject.
|
|
16
|
-
subject.
|
|
14
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
15
|
+
expect(subject).to receive(association).and_return([object1, object2])
|
|
16
|
+
expect(subject).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'should not match when association is different' do
|
|
20
|
-
subject.class.
|
|
21
|
-
subject.
|
|
22
|
-
|
|
23
|
-
subject.
|
|
24
|
-
}.
|
|
20
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
21
|
+
expect(subject).to receive(association).and_return([object1, object3])
|
|
22
|
+
expect {
|
|
23
|
+
expect(subject).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
|
|
24
|
+
}.to (
|
|
25
25
|
raise_error(
|
|
26
26
|
RSpec::Expectations::ExpectationNotMetError,
|
|
27
27
|
/expected #{subject.class} PID=#{pid} association: #{association.inspect}/
|
|
@@ -30,12 +30,12 @@ describe RSpec::Matchers, "have_many_associated_active_fedora_objects_matcher" d
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it 'should require :with_objects option' do
|
|
33
|
-
|
|
34
|
-
subject.
|
|
35
|
-
}.
|
|
33
|
+
expect {
|
|
34
|
+
expect(subject).to have_many_associated_active_fedora_objects(association)
|
|
35
|
+
}.to(
|
|
36
36
|
raise_error(
|
|
37
37
|
ArgumentError,
|
|
38
|
-
|
|
38
|
+
'subject.should have_many_associated_active_fedora_objects(<association_name>).with_objects(<objects[]>)'
|
|
39
39
|
)
|
|
40
40
|
)
|
|
41
41
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
|
3
|
-
require
|
|
3
|
+
require 'active_fedora/rspec_matchers/have_predicate_matcher'
|
|
4
4
|
|
|
5
|
-
describe RSpec::Matchers,
|
|
5
|
+
describe RSpec::Matchers, 'have_predicate_matcher' do
|
|
6
6
|
subject { OpenStruct.new(:pid => pid )}
|
|
7
7
|
let(:pid) { 123 }
|
|
8
8
|
let(:object1) { Object.new }
|
|
@@ -11,17 +11,17 @@ describe RSpec::Matchers, "have_predicate_matcher" do
|
|
|
11
11
|
let(:predicate) { :predicate }
|
|
12
12
|
|
|
13
13
|
it 'should match when relationship is "what we have in Fedora"' do
|
|
14
|
-
subject.class.
|
|
15
|
-
subject.
|
|
16
|
-
subject.
|
|
14
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
15
|
+
expect(subject).to receive(:relationships).with(predicate).and_return([object1, object2])
|
|
16
|
+
expect(subject).to have_predicate(predicate).with_objects([object1, object2])
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'should not match when relationship is different' do
|
|
20
|
-
subject.class.
|
|
21
|
-
subject.
|
|
22
|
-
|
|
23
|
-
subject.
|
|
24
|
-
}.
|
|
20
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
|
21
|
+
expect(subject).to receive(:relationships).with(predicate).and_return([object1, object3])
|
|
22
|
+
expect {
|
|
23
|
+
expect(subject).to have_predicate(predicate).with_objects([object1, object2])
|
|
24
|
+
}.to (
|
|
25
25
|
raise_error(
|
|
26
26
|
RSpec::Expectations::ExpectationNotMetError,
|
|
27
27
|
/expected #{subject.class} PID=#{pid} relationship: #{predicate.inspect}/
|
|
@@ -30,12 +30,12 @@ describe RSpec::Matchers, "have_predicate_matcher" do
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it 'should require :with_objects option' do
|
|
33
|
-
|
|
34
|
-
subject.
|
|
35
|
-
}.
|
|
33
|
+
expect {
|
|
34
|
+
expect(subject).to have_predicate(predicate)
|
|
35
|
+
}.to(
|
|
36
36
|
raise_error(
|
|
37
37
|
ArgumentError,
|
|
38
|
-
|
|
38
|
+
'subject.should have_predicate(<predicate>).with_objects(<objects[]>)'
|
|
39
39
|
)
|
|
40
40
|
)
|
|
41
41
|
end
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
require 'ostruct'
|
|
3
3
|
require 'webmock/rspec'
|
|
4
4
|
WebMock.allow_net_connect!
|
|
5
|
-
require
|
|
5
|
+
require 'active_fedora/rspec_matchers/match_fedora_datastream_matcher'
|
|
6
6
|
|
|
7
|
-
describe RSpec::Matchers,
|
|
7
|
+
describe RSpec::Matchers, 'match_fedora_datastream' do
|
|
8
8
|
let(:pid) { 123 }
|
|
9
9
|
let(:expected_xml) { '<xml><node>Value</node></xml>' }
|
|
10
10
|
let(:datastream_name) { 'metadata' }
|
|
11
11
|
let(:datastream_url) {
|
|
12
|
-
File.join(ActiveFedora.config.credentials[:url], 'objects', pid.to_s,'datastreams', datastream_name, 'content')
|
|
12
|
+
File.join(ActiveFedora.config.credentials[:url], 'objects', pid.to_s, 'datastreams', datastream_name, 'content')
|
|
13
13
|
}
|
|
14
14
|
subject { OpenStruct.new(:pid => pid )}
|
|
15
15
|
|
|
16
16
|
it 'should match based on request' do
|
|
17
17
|
stub_request(:get, datastream_url).to_return(:body => expected_xml, :status => 200)
|
|
18
|
-
subject.
|
|
18
|
+
expect(subject).to match_fedora_datastream(datastream_name).with(expected_xml)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it 'should handle non-matching requests' do
|
|
22
22
|
stub_request(:get, datastream_url).to_return(:body => "<parent>#{expected_xml}</parent>", :status => 200)
|
|
23
|
-
|
|
24
|
-
subject.
|
|
25
|
-
}.
|
|
23
|
+
expect {
|
|
24
|
+
expect(subject).to match_fedora_datastream(datastream_name).with(expected_xml)
|
|
25
|
+
}.to(
|
|
26
26
|
raise_error(
|
|
27
27
|
RSpec::Expectations::ExpectationNotMetError,
|
|
28
28
|
/expected #{subject.class} PID=#{pid} datastream: #{datastream_name.inspect} to match Fedora/
|
|
@@ -32,12 +32,12 @@ describe RSpec::Matchers, "match_fedora_datastream" do
|
|
|
32
32
|
|
|
33
33
|
it 'should require :with option' do
|
|
34
34
|
stub_request(:get, datastream_url).to_return(:body => "<parent>#{expected_xml}</parent>", :status => 200)
|
|
35
|
-
|
|
36
|
-
subject.
|
|
37
|
-
}.
|
|
35
|
+
expect {
|
|
36
|
+
expect(subject).to match_fedora_datastream(datastream_name)
|
|
37
|
+
}.to(
|
|
38
38
|
raise_error(
|
|
39
39
|
ArgumentError,
|
|
40
|
-
|
|
40
|
+
'match_fedora_datastream(<datastream_name>).with(<expected_xml>)'
|
|
41
41
|
)
|
|
42
42
|
)
|
|
43
43
|
end
|
|
@@ -3,11 +3,11 @@ require 'active_fedora/rubydora_connection'
|
|
|
3
3
|
|
|
4
4
|
describe ActiveFedora::RubydoraConnection do
|
|
5
5
|
describe 'initialize' do
|
|
6
|
-
it
|
|
7
|
-
@instance = ActiveFedora::RubydoraConnection.new :timeout => 3600, :fake_option => :missing, :force => true, :validateChecksum=>true
|
|
8
|
-
@instance.connection.client.options[:timeout].
|
|
9
|
-
@instance.connection.config[:validateChecksum].
|
|
10
|
-
@instance.connection.client.options.has_key?(:fake_option).
|
|
6
|
+
it 'should pass through valid options' do
|
|
7
|
+
@instance = ActiveFedora::RubydoraConnection.new :timeout => 3600, :fake_option => :missing, :force => true, :validateChecksum => true
|
|
8
|
+
expect(@instance.connection.client.options[:timeout]).to eq(3600)
|
|
9
|
+
expect(@instance.connection.config[:validateChecksum]).to eq(true)
|
|
10
|
+
expect(@instance.connection.client.options.has_key?(:fake_option)).to be_falsey
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -6,7 +6,7 @@ require 'xmlsimple'
|
|
|
6
6
|
|
|
7
7
|
class SpecNode2
|
|
8
8
|
include ActiveFedora::SemanticNode
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
attr_accessor :pid
|
|
11
11
|
def internal_uri
|
|
12
12
|
'info:fedora/' + pid.to_s
|
|
@@ -15,43 +15,43 @@ end
|
|
|
15
15
|
|
|
16
16
|
describe ActiveFedora::SemanticNode do
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
describe
|
|
18
|
+
|
|
19
|
+
describe 'with a bunch of objects' do
|
|
20
20
|
def increment_pid
|
|
21
|
-
@@last_pid += 1
|
|
21
|
+
@@last_pid += 1
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
before(:each) do
|
|
25
25
|
class SpecNode
|
|
26
26
|
include ActiveFedora::SemanticNode
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
attr_accessor :pid
|
|
29
|
-
def initialize
|
|
29
|
+
def initialize(params = {})
|
|
30
30
|
self.pid = params[:pid]
|
|
31
31
|
end
|
|
32
32
|
def internal_uri
|
|
33
33
|
'info:fedora/' + pid.to_s
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
class AudioRecord
|
|
38
38
|
attr_accessor :pid
|
|
39
|
-
def initialize
|
|
39
|
+
def initialize(params = {})
|
|
40
40
|
self.pid = params[:pid]
|
|
41
41
|
end
|
|
42
42
|
def internal_uri
|
|
43
43
|
'info:fedora/' + pid.to_s
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
@node = SpecNode.new
|
|
48
|
-
@node.
|
|
48
|
+
allow(@node).to receive(:rels_ext).and_return(double('rels_ext', :content_will_change! => true, :content => ''))
|
|
49
49
|
@node.pid = increment_pid
|
|
50
50
|
@test_object = SpecNode2.new
|
|
51
|
-
@test_object.pid = increment_pid
|
|
52
|
-
@test_object.
|
|
51
|
+
@test_object.pid = increment_pid
|
|
52
|
+
allow(@test_object).to receive(:rels_ext).and_return(double('rels_ext', :content_will_change! => true, :content => ''))
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
after(:each) do
|
|
56
56
|
Object.send(:remove_const, :SpecNode)
|
|
57
57
|
begin
|
|
@@ -75,82 +75,82 @@ describe ActiveFedora::SemanticNode do
|
|
|
75
75
|
rescue
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
|
|
80
80
|
it 'should provide .internal_uri' do
|
|
81
|
-
@node.
|
|
81
|
+
expect(@node).to respond_to(:internal_uri)
|
|
82
82
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
describe
|
|
86
|
-
it
|
|
87
|
-
@node.add_relationship(
|
|
88
|
-
@node.ids_for_outbound(
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
describe '.add_relationship' do
|
|
86
|
+
it 'should add relationship to the relationships graph' do
|
|
87
|
+
@node.add_relationship('isMemberOf', 'demo:9')
|
|
88
|
+
expect(@node.ids_for_outbound('isMemberOf')).to eq(['demo:9'])
|
|
89
89
|
end
|
|
90
|
-
it
|
|
90
|
+
it 'should not be written into the graph until it is saved' do
|
|
91
91
|
@n1 = ActiveFedora::Base.new
|
|
92
92
|
@node.add_relationship(:has_part, @n1)
|
|
93
|
-
@node.relationships.statements.to_a.first.object.to_s.
|
|
93
|
+
expect(@node.relationships.statements.to_a.first.object.to_s).to eq('info:fedora/')
|
|
94
94
|
@n1.save
|
|
95
|
-
@node.relationships.statements.to_a.first.object.to_s.
|
|
95
|
+
expect(@node.relationships.statements.to_a.first.object.to_s).to eq(@n1.internal_uri)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
it
|
|
99
|
-
@node.add_relationship(
|
|
100
|
-
@node.relationships(
|
|
98
|
+
it 'should add a literal relationship to the relationships graph' do
|
|
99
|
+
@node.add_relationship('isMemberOf', 'demo:9', true)
|
|
100
|
+
expect(@node.relationships('isMemberOf')).to eq(['demo:9'])
|
|
101
101
|
end
|
|
102
|
-
|
|
103
|
-
it
|
|
102
|
+
|
|
103
|
+
it 'adding relationship to an instance should not affect class-level relationships hash' do
|
|
104
104
|
local_test_node1 = SpecNode.new
|
|
105
105
|
local_test_node2 = SpecNode.new
|
|
106
|
-
local_test_node1.
|
|
106
|
+
allow(local_test_node1).to receive(:rels_ext).and_return(double('rels_ext', :content_will_change! => true, :content => ''))
|
|
107
107
|
local_test_node1.add_relationship(:is_member_of, 'demo:10')
|
|
108
|
-
local_test_node2.
|
|
109
|
-
|
|
110
|
-
local_test_node1.relationships(:is_member_of).
|
|
111
|
-
local_test_node2.relationships(:is_member_of).
|
|
108
|
+
allow(local_test_node2).to receive(:rels_ext).and_return(double('rels-ext', :content => ''))
|
|
109
|
+
|
|
110
|
+
expect(local_test_node1.relationships(:is_member_of)).to eq(['demo:10'])
|
|
111
|
+
expect(local_test_node2.relationships(:is_member_of)).to eq([])
|
|
112
112
|
end
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
describe
|
|
116
|
+
describe '.clear_relationship' do
|
|
117
117
|
before do
|
|
118
118
|
@node.add_relationship(:is_member_of, 'demo:9')
|
|
119
119
|
@node.add_relationship(:is_member_of, 'demo:7')
|
|
120
120
|
@node.add_relationship(:has_description, 'demo:9')
|
|
121
121
|
end
|
|
122
|
-
it
|
|
122
|
+
it 'should clear the specified relationship' do
|
|
123
123
|
@node.clear_relationship(:is_member_of)
|
|
124
|
-
@node.relationships(:is_member_of).
|
|
125
|
-
@node.relationships(:has_description).
|
|
124
|
+
expect(@node.relationships(:is_member_of)).to eq([])
|
|
125
|
+
expect(@node.relationships(:has_description)).to eq(['demo:9'])
|
|
126
126
|
end
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
end
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
it
|
|
132
|
-
@node.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
it 'should provide .outbound_relationships' do
|
|
132
|
+
expect(@node).to respond_to(:outbound_relationships)
|
|
133
133
|
end
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
|
|
135
|
+
|
|
136
136
|
describe '#remove_relationship' do
|
|
137
137
|
it 'should remove a relationship from the relationships hash' do
|
|
138
|
-
@test_object.
|
|
139
|
-
@test_object.add_relationship(:has_part,
|
|
140
|
-
@test_object.add_relationship(:has_part,
|
|
138
|
+
allow(@test_object).to receive(:rels_ext).and_return(double('rels_ext', :content_will_change! => true, :content => ''))
|
|
139
|
+
@test_object.add_relationship(:has_part, 'info:fedora/3')
|
|
140
|
+
@test_object.add_relationship(:has_part, 'info:fedora/4')
|
|
141
141
|
#check both are there
|
|
142
|
-
@test_object.ids_for_outbound(:has_part).
|
|
143
|
-
@test_object.remove_relationship(:has_part,
|
|
142
|
+
expect(@test_object.ids_for_outbound(:has_part)).to include '3', '4'
|
|
143
|
+
@test_object.remove_relationship(:has_part, 'info:fedora/3')
|
|
144
144
|
#check returns false if relationship does not exist and does nothing with different predicate
|
|
145
|
-
@test_object.remove_relationship(:has_member,
|
|
145
|
+
@test_object.remove_relationship(:has_member, 'info:fedora/4')
|
|
146
146
|
#check only one item removed
|
|
147
|
-
@test_object.ids_for_outbound(:has_part).
|
|
148
|
-
@test_object.remove_relationship(:has_part,
|
|
147
|
+
expect(@test_object.ids_for_outbound(:has_part)).to eq(['4'])
|
|
148
|
+
@test_object.remove_relationship(:has_part, 'info:fedora/4')
|
|
149
149
|
#check last item removed and predicate removed since now emtpy
|
|
150
|
-
@test_object.ids_for_outbound(:has_part).
|
|
150
|
+
expect(@test_object.ids_for_outbound(:has_part)).to eq([])
|
|
151
|
+
|
|
152
|
+
expect(@test_object.relationships_are_dirty).to eq(true)
|
|
151
153
|
|
|
152
|
-
@test_object.relationships_are_dirty.should == true
|
|
153
|
-
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
156
|
|
|
@@ -162,7 +162,7 @@ describe ActiveFedora::SemanticNode do
|
|
|
162
162
|
rescue
|
|
163
163
|
had_exception = true
|
|
164
164
|
end
|
|
165
|
-
raise
|
|
165
|
+
raise 'Failed to throw exception with kind of mismatch' unless had_exception
|
|
166
166
|
#now should not throw any exception
|
|
167
167
|
@test_object.assert_kind_of 'SpecNode2', @test_object, SpecNode2
|
|
168
168
|
end
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Attributes::Serializers do
|
|
4
4
|
subject { ActiveFedora::Base }
|
|
5
|
-
describe
|
|
5
|
+
describe 'deserialize_dates_from_form' do
|
|
6
6
|
before do
|
|
7
7
|
class Foo < ActiveFedora::Base
|
|
8
8
|
attr_accessor :birthday
|
|
@@ -12,9 +12,9 @@ describe ActiveFedora::Attributes::Serializers do
|
|
|
12
12
|
Object.send(:remove_const, :Foo)
|
|
13
13
|
end
|
|
14
14
|
subject { Foo.new }
|
|
15
|
-
it
|
|
16
|
-
subject.attributes = {'birthday(1i)' =>'2012', 'birthday(2i)' =>'10', 'birthday(3i)' => '31'}
|
|
17
|
-
subject.birthday.
|
|
15
|
+
it 'should deserialize dates' do
|
|
16
|
+
subject.attributes = {'birthday(1i)' => '2012', 'birthday(2i)' => '10', 'birthday(3i)' => '31'}
|
|
17
|
+
expect(subject.birthday).to eq('2012-10-31')
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|