active-fedora 13.1.2 → 13.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github_changelog_generator +2 -0
- data/CHANGELOG.md +3362 -0
- data/CONTRIBUTING.md +23 -1
- data/README.md +4 -0
- data/active-fedora.gemspec +14 -13
- data/lib/active_fedora/version.rb +1 -1
- metadata +104 -206
- data/spec/config_helper.rb +0 -17
- data/spec/fixtures/dino.jpg +0 -0
- data/spec/fixtures/dino_jpg_no_file_ext +0 -0
- data/spec/fixtures/minivan.jpg +0 -0
- data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
- data/spec/fixtures/rails_root/config/fedora.yml +0 -12
- data/spec/fixtures/rails_root/config/solr.yml +0 -15
- data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
- data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
- data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
- data/spec/integration/associations/rdf_spec.rb +0 -61
- data/spec/integration/associations_spec.rb +0 -680
- data/spec/integration/attached_files_spec.rb +0 -146
- data/spec/integration/attributes_spec.rb +0 -73
- data/spec/integration/autosave_association_spec.rb +0 -24
- data/spec/integration/base_spec.rb +0 -184
- data/spec/integration/basic_contains_association_spec.rb +0 -121
- data/spec/integration/belongs_to_association_spec.rb +0 -260
- data/spec/integration/caching_spec.rb +0 -59
- data/spec/integration/clean_connection_spec.rb +0 -21
- data/spec/integration/collection_association_spec.rb +0 -166
- data/spec/integration/date_time_properties_spec.rb +0 -41
- data/spec/integration/delete_all_spec.rb +0 -64
- data/spec/integration/direct_container_spec.rb +0 -250
- data/spec/integration/directly_contains_one_association_spec.rb +0 -96
- data/spec/integration/eradicate_spec.rb +0 -52
- data/spec/integration/fedora_solr_sync_spec.rb +0 -30
- data/spec/integration/file_fixity_spec.rb +0 -36
- data/spec/integration/file_spec.rb +0 -221
- data/spec/integration/generators/fedora_generator_spec.rb +0 -26
- data/spec/integration/generators/solr_generator_spec.rb +0 -23
- data/spec/integration/gone_spec.rb +0 -41
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
- data/spec/integration/has_many_associations_spec.rb +0 -436
- data/spec/integration/has_subresource_spec.rb +0 -34
- data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
- data/spec/integration/indexing_spec.rb +0 -110
- data/spec/integration/indirect_container_spec.rb +0 -290
- data/spec/integration/json_serialization_spec.rb +0 -32
- data/spec/integration/marshal_spec.rb +0 -39
- data/spec/integration/nested_attribute_spec.rb +0 -177
- data/spec/integration/nested_hash_resources_spec.rb +0 -43
- data/spec/integration/persistence_spec.rb +0 -37
- data/spec/integration/query_result_builder_spec.rb +0 -37
- data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
- data/spec/integration/relation_delegation_spec.rb +0 -52
- data/spec/integration/relation_spec.rb +0 -117
- data/spec/integration/scoped_query_spec.rb +0 -134
- data/spec/integration/scoping_spec.rb +0 -48
- data/spec/integration/solr_hit_spec.rb +0 -32
- data/spec/integration/versionable_spec.rb +0 -256
- data/spec/integration/with_metadata_spec.rb +0 -111
- data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -5
- data/spec/spec_helper.rb +0 -106
- data/spec/support/an_active_model.rb +0 -29
- data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
- data/spec/unit/active_fedora_spec.rb +0 -118
- data/spec/unit/aggregation/list_source_spec.rb +0 -134
- data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
- data/spec/unit/association_hash_spec.rb +0 -64
- data/spec/unit/attached_files_spec.rb +0 -218
- data/spec/unit/attributes_spec.rb +0 -146
- data/spec/unit/base_active_model_spec.rb +0 -28
- data/spec/unit/base_cma_spec.rb +0 -15
- data/spec/unit/base_extra_spec.rb +0 -33
- data/spec/unit/base_spec.rb +0 -328
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
- data/spec/unit/callback_spec.rb +0 -65
- data/spec/unit/change_set_spec.rb +0 -60
- data/spec/unit/checksum_spec.rb +0 -25
- data/spec/unit/code_configurator_spec.rb +0 -41
- data/spec/unit/collection_proxy_spec.rb +0 -25
- data/spec/unit/config_spec.rb +0 -18
- data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
- data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
- data/spec/unit/core/logger_spec.rb +0 -18
- data/spec/unit/core_spec.rb +0 -242
- data/spec/unit/default_model_mapper_spec.rb +0 -39
- data/spec/unit/fedora_spec.rb +0 -31
- data/spec/unit/file/streaming_spec.rb +0 -33
- data/spec/unit/file_configurator_spec.rb +0 -295
- data/spec/unit/file_io_spec.rb +0 -137
- data/spec/unit/file_path_builder_spec.rb +0 -18
- data/spec/unit/file_spec.rb +0 -489
- data/spec/unit/files_hash_spec.rb +0 -52
- data/spec/unit/filter_spec.rb +0 -133
- data/spec/unit/finder_methods_spec.rb +0 -154
- data/spec/unit/fixity_service_spec.rb +0 -128
- data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
- data/spec/unit/has_many_association_spec.rb +0 -131
- data/spec/unit/indexers/global_indexer_spec.rb +0 -41
- data/spec/unit/indexing/map/index_object_spec.rb +0 -25
- data/spec/unit/indexing/map_spec.rb +0 -27
- data/spec/unit/indexing_service_spec.rb +0 -28
- data/spec/unit/indexing_spec.rb +0 -86
- data/spec/unit/inheritance_spec.rb +0 -60
- data/spec/unit/ldp_resource_spec.rb +0 -15
- data/spec/unit/loadable_from_json_spec.rb +0 -40
- data/spec/unit/logger_spec.rb +0 -19
- data/spec/unit/model_classifier_spec.rb +0 -49
- data/spec/unit/ordered_spec.rb +0 -367
- data/spec/unit/orders/list_node_spec.rb +0 -151
- data/spec/unit/orders/ordered_list_spec.rb +0 -335
- data/spec/unit/orders/reflection_spec.rb +0 -22
- data/spec/unit/pathing_spec.rb +0 -35
- data/spec/unit/persistence_spec.rb +0 -115
- data/spec/unit/property_predicate_spec.rb +0 -35
- data/spec/unit/property_spec.rb +0 -25
- data/spec/unit/query_result_builder_spec.rb +0 -31
- data/spec/unit/query_spec.rb +0 -307
- data/spec/unit/querying_spec.rb +0 -24
- data/spec/unit/rdf/indexing_service_spec.rb +0 -114
- data/spec/unit/rdf_vocab_spec.rb +0 -30
- data/spec/unit/readonly_spec.rb +0 -24
- data/spec/unit/reflection_spec.rb +0 -42
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
- data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
- data/spec/unit/scoping_spec.rb +0 -67
- data/spec/unit/serializers_spec.rb +0 -19
- data/spec/unit/solr_config_options_spec.rb +0 -57
- data/spec/unit/solr_hit_spec.rb +0 -57
- data/spec/unit/solr_query_builder_spec.rb +0 -18
- data/spec/unit/solr_service_spec.rb +0 -165
- data/spec/unit/sparql_insert_spec.rb +0 -31
- data/spec/unit/validations_spec.rb +0 -92
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
- data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::ChangeSet do
|
4
|
-
subject(:change_set) { described_class.new(base, base.resource, base.changed_attributes.keys) }
|
5
|
-
|
6
|
-
context "with an unchanged object" do
|
7
|
-
let(:base) { ActiveFedora::Base.new }
|
8
|
-
|
9
|
-
it { is_expected.to be_empty }
|
10
|
-
end
|
11
|
-
|
12
|
-
context "with a changed object" do
|
13
|
-
before do
|
14
|
-
class Library < ActiveFedora::Base
|
15
|
-
end
|
16
|
-
|
17
|
-
class Book < ActiveFedora::Base
|
18
|
-
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
19
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
20
|
-
property :alt_id, predicate: ::RDF::Vocab::DC.identifier
|
21
|
-
end
|
22
|
-
|
23
|
-
base.library_id = 'foo'
|
24
|
-
base.title = ['bar']
|
25
|
-
base.alt_id = ['12345']
|
26
|
-
end
|
27
|
-
after do
|
28
|
-
Object.send(:remove_const, :Library)
|
29
|
-
Object.send(:remove_const, :Book)
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:base) { Book.create }
|
33
|
-
|
34
|
-
describe "#changes" do
|
35
|
-
subject(:changes) { change_set.changes }
|
36
|
-
|
37
|
-
it { is_expected.to be_kind_of Hash }
|
38
|
-
|
39
|
-
it "has three elements" do
|
40
|
-
expect(changes.size).to eq 3
|
41
|
-
end
|
42
|
-
it "does not include URIs from other objects" do
|
43
|
-
base.resource << RDF::Statement.new(RDF::URI("http://wrong.com"), RDF::Vocab::DC.title, "bad")
|
44
|
-
base.title = nil
|
45
|
-
expect(changes[RDF::Vocab::DC.title].to_a).to eq []
|
46
|
-
end
|
47
|
-
it "includes hash URIs" do
|
48
|
-
# This is useful as an alternative to blank nodes.
|
49
|
-
hash_uri = RDF::URI(base.uri.to_s + "#test")
|
50
|
-
base.resource << RDF::Statement.new(hash_uri, RDF::Vocab::DC.title, "good")
|
51
|
-
base.title = [RDF::URI(hash_uri)]
|
52
|
-
expect(changes[RDF::Vocab::DC.title].to_a).not_to eq []
|
53
|
-
# Include the title reference and the title for the hash URI
|
54
|
-
expect(changes[RDF::Vocab::DC.title].to_a.length).to eq 2
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it { is_expected.to_not be_empty }
|
59
|
-
end
|
60
|
-
end
|
data/spec/unit/checksum_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module ActiveFedora
|
4
|
-
describe Checksum do
|
5
|
-
subject { described_class.new(file) }
|
6
|
-
|
7
|
-
let(:uri) { ::RDF::URI("urn:sha1:bb3200c2ddaee4bd7b9a4dc1ad3e10ed886eaef1") }
|
8
|
-
|
9
|
-
describe "when initialized with a file having a digest" do
|
10
|
-
let(:file) { instance_double(ActiveFedora::File, digest: [uri]) }
|
11
|
-
|
12
|
-
its(:uri) { is_expected.to eq(uri) }
|
13
|
-
its(:value) { is_expected.to eq("bb3200c2ddaee4bd7b9a4dc1ad3e10ed886eaef1") }
|
14
|
-
its(:algorithm) { is_expected.to eq("SHA1") }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "when initialized with a file not having a digest" do
|
18
|
-
let(:file) { instance_double(ActiveFedora::File, digest: []) }
|
19
|
-
|
20
|
-
its(:uri) { is_expected.to be_nil }
|
21
|
-
its(:value) { is_expected.to be_nil }
|
22
|
-
its(:algorithm) { is_expected.to be_nil }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'config_helper'
|
3
|
-
|
4
|
-
describe ActiveFedora::FileConfigurator do
|
5
|
-
before :all do
|
6
|
-
class TestConfigurator
|
7
|
-
attr_reader :fedora_config, :solr_config
|
8
|
-
|
9
|
-
def init(options = {})
|
10
|
-
@fedora_config = options[:fedora_config]
|
11
|
-
@solr_config = options[:solr_config]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
@config_params = {
|
16
|
-
fedora_config: { url: 'http://codeconfig.example.edu/fedora/', user: 'fedoraAdmin', password: 'configurator', cert_file: '/path/to/cert/file' },
|
17
|
-
solr_config: { url: 'http://codeconfig.example.edu/solr/' }
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
before do
|
22
|
-
ActiveFedora.configurator = TestConfigurator.new
|
23
|
-
end
|
24
|
-
|
25
|
-
after :all do
|
26
|
-
unstub_rails
|
27
|
-
# Restore to default fedora configs
|
28
|
-
ActiveFedora.configurator = described_class.new
|
29
|
-
restore_spec_configuration
|
30
|
-
end
|
31
|
-
|
32
|
-
it "initializes from code" do
|
33
|
-
expect(Psych).to receive(:load).never
|
34
|
-
expect(File).to receive(:exists?).never
|
35
|
-
expect(File).to receive(:read).never
|
36
|
-
expect(File).to receive(:open).never
|
37
|
-
ActiveFedora.init(@config_params)
|
38
|
-
expect(ActiveFedora.fedora_config.credentials).to eq @config_params[:fedora_config]
|
39
|
-
expect(ActiveFedora.solr_config).to eq @config_params[:solr_config]
|
40
|
-
end
|
41
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Associations::CollectionProxy do
|
4
|
-
before do
|
5
|
-
class Book < ActiveFedora::Base
|
6
|
-
end
|
7
|
-
class Page < ActiveFedora::Base
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
Object.send(:remove_const, :Page)
|
13
|
-
Object.send(:remove_const, :Book)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#spawn" do
|
17
|
-
subject { proxy.spawn }
|
18
|
-
|
19
|
-
let(:reflection) { ActiveFedora::Reflection.create(:has_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book) }
|
20
|
-
let(:association) { ActiveFedora::Associations::HasManyAssociation.new(Book.new, reflection) }
|
21
|
-
let(:proxy) { described_class.new(association) }
|
22
|
-
|
23
|
-
it { is_expected.to be_instance_of ActiveFedora::Relation }
|
24
|
-
end
|
25
|
-
end
|
data/spec/unit/config_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Config do
|
4
|
-
context "with a single fedora instance" do
|
5
|
-
let(:yaml) { Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml')) }
|
6
|
-
let(:section) { 'test' }
|
7
|
-
let(:conf) { described_class.new(yaml[section]) }
|
8
|
-
|
9
|
-
describe "#credentials" do
|
10
|
-
subject { conf.credentials }
|
11
|
-
it { is_expected.to eq(url: 'http://testhost.com:8983/fedora', user: 'fedoraAdmin', password: 'fedoraAdmin') }
|
12
|
-
describe "with SSL options" do
|
13
|
-
let(:section) { 'test_ssl' }
|
14
|
-
its([:ssl]) { is_expected.to eq(verify: false, ca_path: '/path/to/certs') }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
4
|
-
describe ".call" do
|
5
|
-
let(:result) { described_class.call(id) }
|
6
|
-
context "when given an id" do
|
7
|
-
let(:good_uri) { ActiveFedora.fedora.base_uri + "/banana" }
|
8
|
-
let(:id) { "banana" }
|
9
|
-
it "returns a fedora URI" do
|
10
|
-
expect(result).to eq good_uri
|
11
|
-
end
|
12
|
-
|
13
|
-
context "with a leading slash" do
|
14
|
-
let(:id) { "/banana" }
|
15
|
-
it "returns a good fedora URI" do
|
16
|
-
expect(result).to eq good_uri
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "with characters that need escaping" do
|
21
|
-
let(:good_uri) { ActiveFedora.fedora.base_uri + "/%5Bfrob%5D" }
|
22
|
-
let(:id) { "[frob]" }
|
23
|
-
it "returns a good fedora URI" do
|
24
|
-
expect(result).to eq good_uri
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
|
4
|
-
describe ".call" do
|
5
|
-
let(:result) { described_class.call(uri) }
|
6
|
-
context "when given a Fedora URI" do
|
7
|
-
let(:uri) { ActiveFedora.fedora.base_uri + "/6" }
|
8
|
-
it "returns the id" do
|
9
|
-
expect(result).to eq '6'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
context "when given a URI missing a slash" do
|
13
|
-
let(:uri) { ActiveFedora.fedora.base_uri + "602-a" }
|
14
|
-
it "returns the id" do
|
15
|
-
expect(result).to eq "602-a"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::NullLogger do
|
4
|
-
before { ActiveFedora::Base.logger = described_class.new }
|
5
|
-
describe "::logger" do
|
6
|
-
let(:logger) { ActiveFedora::Base.logger }
|
7
|
-
it "when calling the logger" do
|
8
|
-
expect(logger.warn("warning!")).to be_nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#logger" do
|
13
|
-
let(:logger) { ActiveFedora::Base.new.logger }
|
14
|
-
it "when calling the logger" do
|
15
|
-
expect(logger.warn("warning!")).to be_nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/unit/core_spec.rb
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::Base do
|
4
|
-
before do
|
5
|
-
class Library < ActiveFedora::Base
|
6
|
-
end
|
7
|
-
class Book < ActiveFedora::Base
|
8
|
-
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
9
|
-
property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
|
10
|
-
property :publisher, predicate: ::RDF::Vocab::DC.publisher, multiple: false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject(:book) { Book.new(library: library, title: "War and Peace", publisher: "Random House") }
|
15
|
-
let(:library) { Library.create }
|
16
|
-
|
17
|
-
after do
|
18
|
-
Object.send(:remove_const, :Book)
|
19
|
-
Object.send(:remove_const, :Library)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "asserts a content model" do
|
23
|
-
expect(book.has_model).to eq ['Book']
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "initialize" do
|
27
|
-
context "with a block" do
|
28
|
-
subject(:book) { Book.new { |b| b.title = "The Sun also Rises" } }
|
29
|
-
|
30
|
-
it "has set the title" do
|
31
|
-
expect(book.title).to eq "The Sun also Rises"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with an identifier" do
|
36
|
-
subject(:book) { Book.new(attributes) }
|
37
|
-
let(:attributes) { { id: '1234' } }
|
38
|
-
|
39
|
-
it "sets the id and doesn't modify the passed hash" do
|
40
|
-
expect(book.id).to eq '1234'
|
41
|
-
expect(attributes[:id]).to eq '1234'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#etag' do
|
47
|
-
let(:attributes) { { id: '1234' } }
|
48
|
-
|
49
|
-
it 'before save raises an error' do
|
50
|
-
expect { book.etag }
|
51
|
-
.to raise_error 'Unable to produce an etag for a unsaved object'
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'after save' do
|
55
|
-
before { book.save! }
|
56
|
-
|
57
|
-
it 'has the etag from the ldp_source' do
|
58
|
-
expect(book.etag).to eq book.ldp_source.head.etag
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'after delete raises Ldp::Gone' do
|
62
|
-
book.destroy!
|
63
|
-
expect { book.etag }.to raise_error Ldp::Gone
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#freeze" do
|
69
|
-
before { book.freeze }
|
70
|
-
|
71
|
-
it "is frozen" do
|
72
|
-
expect(book).to be_frozen
|
73
|
-
end
|
74
|
-
|
75
|
-
it "makes the associations immutable" do
|
76
|
-
expect {
|
77
|
-
book.library_id = Library.create!.id
|
78
|
-
}.to raise_error RuntimeError, "can't modify frozen Book"
|
79
|
-
expect(book.library_id).to eq library.id
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "when the association is set via an id" do
|
83
|
-
subject(:book) { Book.new(library_id: library.id) }
|
84
|
-
it "is able to load the association" do
|
85
|
-
expect(book.library).to eq library
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it "makes the properties immutable" do
|
90
|
-
expect {
|
91
|
-
book.publisher = "HEY"
|
92
|
-
}.to raise_error TypeError
|
93
|
-
expect(book.publisher).to eq "Random House"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "an object that hasn't loaded the associations" do
|
98
|
-
before { book.save! }
|
99
|
-
|
100
|
-
it "accesses associations" do
|
101
|
-
f = Book.find(book.id)
|
102
|
-
f.freeze
|
103
|
-
expect(f.library_id).to_not be_nil
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "#translate_id_to_uri" do
|
108
|
-
subject(:uri) { described_class.translate_id_to_uri }
|
109
|
-
context "when it's not set" do
|
110
|
-
it "is a FedoraIdTranslator" do
|
111
|
-
expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
|
112
|
-
end
|
113
|
-
end
|
114
|
-
context "when it's set to nil" do
|
115
|
-
before do
|
116
|
-
described_class.translate_id_to_uri = nil
|
117
|
-
end
|
118
|
-
it "is a FedoraIdTranslator" do
|
119
|
-
expect(uri).to eq ActiveFedora::Core::FedoraIdTranslator
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "#translate_uri_to_id" do
|
125
|
-
subject(:uri) { described_class.translate_uri_to_id }
|
126
|
-
context "when it's not set" do
|
127
|
-
it "is a FedoraUriTranslator" do
|
128
|
-
expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
|
129
|
-
end
|
130
|
-
end
|
131
|
-
context "when it's set to nil" do
|
132
|
-
before do
|
133
|
-
described_class.translate_uri_to_id = nil
|
134
|
-
end
|
135
|
-
it "is a FedoraIdTranslator" do
|
136
|
-
expect(uri).to eq ActiveFedora::Core::FedoraUriTranslator
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "id_to_uri" do
|
142
|
-
subject(:uri) { described_class.id_to_uri(id) }
|
143
|
-
let(:id) { '123456w' }
|
144
|
-
|
145
|
-
context "with no custom proc is set" do
|
146
|
-
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/123456w" }
|
147
|
-
it "justs call #translate_id_to_uri" do
|
148
|
-
allow(described_class).to receive(:translate_id_to_uri).and_call_original
|
149
|
-
allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
|
150
|
-
|
151
|
-
uri
|
152
|
-
|
153
|
-
expect(ActiveFedora::Core::FedoraIdTranslator).to have_received(:call).with(id)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context "when custom proc is set" do
|
158
|
-
before do
|
159
|
-
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.base_uri}/foo/#{id}" }
|
160
|
-
end
|
161
|
-
after { described_class.translate_id_to_uri = nil }
|
162
|
-
|
163
|
-
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
164
|
-
end
|
165
|
-
|
166
|
-
context "with an empty base path" do
|
167
|
-
it "produces a valid URI" do
|
168
|
-
allow(ActiveFedora.fedora).to receive(:base_path).and_return("/")
|
169
|
-
expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "with a really empty base path" do
|
174
|
-
it "produces a valid URI" do
|
175
|
-
allow(ActiveFedora.fedora).to receive(:base_path).and_return("")
|
176
|
-
expect(uri).to eq("#{ActiveFedora.fedora.host}/#{id}")
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe "uri_to_id" do
|
182
|
-
subject(:uri_id) { described_class.uri_to_id(uri) }
|
183
|
-
let(:uri) { "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
184
|
-
|
185
|
-
context "with no custom proc is set" do
|
186
|
-
it { is_expected.to eq 'foo/123456w' }
|
187
|
-
it "justs call #translate_uri_to_id" do
|
188
|
-
allow(described_class).to receive(:translate_uri_to_id).and_call_original
|
189
|
-
allow(ActiveFedora::Core::FedoraUriTranslator).to receive(:call).and_call_original
|
190
|
-
|
191
|
-
uri_id
|
192
|
-
|
193
|
-
expect(ActiveFedora::Core::FedoraUriTranslator).to have_received(:call).with(uri)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context "when custom proc is set" do
|
198
|
-
before do
|
199
|
-
described_class.translate_uri_to_id = lambda { |uri| uri.to_s.split('/')[-1] }
|
200
|
-
end
|
201
|
-
after { described_class.translate_uri_to_id = nil }
|
202
|
-
|
203
|
-
it { is_expected.to eq '123456w' }
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "to_class_uri" do
|
208
|
-
before do
|
209
|
-
module SpecModel
|
210
|
-
class CamelCased < ActiveFedora::Base
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
after do
|
216
|
-
Object.send(:remove_const, :SpecModel)
|
217
|
-
end
|
218
|
-
subject do
|
219
|
-
Deprecation.silence(ActiveFedora::Core::ClassMethods) do
|
220
|
-
SpecModel::CamelCased.to_class_uri
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
it { is_expected.to eq 'SpecModel::CamelCased' }
|
225
|
-
end
|
226
|
-
|
227
|
-
describe "to_rdf_representation" do
|
228
|
-
before do
|
229
|
-
module SpecModel
|
230
|
-
class CamelCased < ActiveFedora::Base
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
after do
|
236
|
-
Object.send(:remove_const, :SpecModel)
|
237
|
-
end
|
238
|
-
subject { SpecModel::CamelCased.to_rdf_representation }
|
239
|
-
|
240
|
-
it { is_expected.to eq 'SpecModel::CamelCased' }
|
241
|
-
end
|
242
|
-
end
|