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.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github_changelog_generator +2 -0
  3. data/CHANGELOG.md +3362 -0
  4. data/CONTRIBUTING.md +23 -1
  5. data/README.md +4 -0
  6. data/active-fedora.gemspec +14 -13
  7. data/lib/active_fedora/version.rb +1 -1
  8. metadata +104 -206
  9. data/spec/config_helper.rb +0 -17
  10. data/spec/fixtures/dino.jpg +0 -0
  11. data/spec/fixtures/dino_jpg_no_file_ext +0 -0
  12. data/spec/fixtures/minivan.jpg +0 -0
  13. data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
  14. data/spec/fixtures/rails_root/config/fedora.yml +0 -12
  15. data/spec/fixtures/rails_root/config/solr.yml +0 -15
  16. data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
  17. data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
  18. data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
  19. data/spec/integration/associations/rdf_spec.rb +0 -61
  20. data/spec/integration/associations_spec.rb +0 -680
  21. data/spec/integration/attached_files_spec.rb +0 -146
  22. data/spec/integration/attributes_spec.rb +0 -73
  23. data/spec/integration/autosave_association_spec.rb +0 -24
  24. data/spec/integration/base_spec.rb +0 -184
  25. data/spec/integration/basic_contains_association_spec.rb +0 -121
  26. data/spec/integration/belongs_to_association_spec.rb +0 -260
  27. data/spec/integration/caching_spec.rb +0 -59
  28. data/spec/integration/clean_connection_spec.rb +0 -21
  29. data/spec/integration/collection_association_spec.rb +0 -166
  30. data/spec/integration/date_time_properties_spec.rb +0 -41
  31. data/spec/integration/delete_all_spec.rb +0 -64
  32. data/spec/integration/direct_container_spec.rb +0 -250
  33. data/spec/integration/directly_contains_one_association_spec.rb +0 -96
  34. data/spec/integration/eradicate_spec.rb +0 -52
  35. data/spec/integration/fedora_solr_sync_spec.rb +0 -30
  36. data/spec/integration/file_fixity_spec.rb +0 -36
  37. data/spec/integration/file_spec.rb +0 -221
  38. data/spec/integration/generators/fedora_generator_spec.rb +0 -26
  39. data/spec/integration/generators/solr_generator_spec.rb +0 -23
  40. data/spec/integration/gone_spec.rb +0 -41
  41. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
  42. data/spec/integration/has_many_associations_spec.rb +0 -436
  43. data/spec/integration/has_subresource_spec.rb +0 -34
  44. data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
  45. data/spec/integration/indexing_spec.rb +0 -110
  46. data/spec/integration/indirect_container_spec.rb +0 -290
  47. data/spec/integration/json_serialization_spec.rb +0 -32
  48. data/spec/integration/marshal_spec.rb +0 -39
  49. data/spec/integration/nested_attribute_spec.rb +0 -177
  50. data/spec/integration/nested_hash_resources_spec.rb +0 -43
  51. data/spec/integration/persistence_spec.rb +0 -37
  52. data/spec/integration/query_result_builder_spec.rb +0 -37
  53. data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
  54. data/spec/integration/relation_delegation_spec.rb +0 -52
  55. data/spec/integration/relation_spec.rb +0 -117
  56. data/spec/integration/scoped_query_spec.rb +0 -134
  57. data/spec/integration/scoping_spec.rb +0 -48
  58. data/spec/integration/solr_hit_spec.rb +0 -32
  59. data/spec/integration/versionable_spec.rb +0 -256
  60. data/spec/integration/with_metadata_spec.rb +0 -111
  61. data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
  62. data/spec/rcov.opts +0 -2
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_helper.rb +0 -106
  65. data/spec/support/an_active_model.rb +0 -29
  66. data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
  67. data/spec/unit/active_fedora_spec.rb +0 -118
  68. data/spec/unit/aggregation/list_source_spec.rb +0 -134
  69. data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
  70. data/spec/unit/association_hash_spec.rb +0 -64
  71. data/spec/unit/attached_files_spec.rb +0 -218
  72. data/spec/unit/attributes_spec.rb +0 -146
  73. data/spec/unit/base_active_model_spec.rb +0 -28
  74. data/spec/unit/base_cma_spec.rb +0 -15
  75. data/spec/unit/base_extra_spec.rb +0 -33
  76. data/spec/unit/base_spec.rb +0 -328
  77. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
  78. data/spec/unit/callback_spec.rb +0 -65
  79. data/spec/unit/change_set_spec.rb +0 -60
  80. data/spec/unit/checksum_spec.rb +0 -25
  81. data/spec/unit/code_configurator_spec.rb +0 -41
  82. data/spec/unit/collection_proxy_spec.rb +0 -25
  83. data/spec/unit/config_spec.rb +0 -18
  84. data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
  85. data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
  86. data/spec/unit/core/logger_spec.rb +0 -18
  87. data/spec/unit/core_spec.rb +0 -242
  88. data/spec/unit/default_model_mapper_spec.rb +0 -39
  89. data/spec/unit/fedora_spec.rb +0 -31
  90. data/spec/unit/file/streaming_spec.rb +0 -33
  91. data/spec/unit/file_configurator_spec.rb +0 -295
  92. data/spec/unit/file_io_spec.rb +0 -137
  93. data/spec/unit/file_path_builder_spec.rb +0 -18
  94. data/spec/unit/file_spec.rb +0 -489
  95. data/spec/unit/files_hash_spec.rb +0 -52
  96. data/spec/unit/filter_spec.rb +0 -133
  97. data/spec/unit/finder_methods_spec.rb +0 -154
  98. data/spec/unit/fixity_service_spec.rb +0 -128
  99. data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
  100. data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
  101. data/spec/unit/has_many_association_spec.rb +0 -131
  102. data/spec/unit/indexers/global_indexer_spec.rb +0 -41
  103. data/spec/unit/indexing/map/index_object_spec.rb +0 -25
  104. data/spec/unit/indexing/map_spec.rb +0 -27
  105. data/spec/unit/indexing_service_spec.rb +0 -28
  106. data/spec/unit/indexing_spec.rb +0 -86
  107. data/spec/unit/inheritance_spec.rb +0 -60
  108. data/spec/unit/ldp_resource_spec.rb +0 -15
  109. data/spec/unit/loadable_from_json_spec.rb +0 -40
  110. data/spec/unit/logger_spec.rb +0 -19
  111. data/spec/unit/model_classifier_spec.rb +0 -49
  112. data/spec/unit/ordered_spec.rb +0 -367
  113. data/spec/unit/orders/list_node_spec.rb +0 -151
  114. data/spec/unit/orders/ordered_list_spec.rb +0 -335
  115. data/spec/unit/orders/reflection_spec.rb +0 -22
  116. data/spec/unit/pathing_spec.rb +0 -35
  117. data/spec/unit/persistence_spec.rb +0 -115
  118. data/spec/unit/property_predicate_spec.rb +0 -35
  119. data/spec/unit/property_spec.rb +0 -25
  120. data/spec/unit/query_result_builder_spec.rb +0 -31
  121. data/spec/unit/query_spec.rb +0 -307
  122. data/spec/unit/querying_spec.rb +0 -24
  123. data/spec/unit/rdf/indexing_service_spec.rb +0 -114
  124. data/spec/unit/rdf_vocab_spec.rb +0 -30
  125. data/spec/unit/readonly_spec.rb +0 -24
  126. data/spec/unit/reflection_spec.rb +0 -42
  127. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
  128. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
  129. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
  130. data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
  131. data/spec/unit/scoping_spec.rb +0 -67
  132. data/spec/unit/serializers_spec.rb +0 -19
  133. data/spec/unit/solr_config_options_spec.rb +0 -57
  134. data/spec/unit/solr_hit_spec.rb +0 -57
  135. data/spec/unit/solr_query_builder_spec.rb +0 -18
  136. data/spec/unit/solr_service_spec.rb +0 -165
  137. data/spec/unit/sparql_insert_spec.rb +0 -31
  138. data/spec/unit/validations_spec.rb +0 -92
  139. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
  140. data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Querying do
4
- before do
5
- class SpecModel < ActiveFedora::Base
6
- end
7
- end
8
-
9
- after do
10
- Object.send(:remove_const, :SpecModel)
11
- end
12
-
13
- describe '.solr_query_handler' do
14
- subject { SpecModel.solr_query_handler }
15
-
16
- it { is_expected.to eq 'standard' }
17
-
18
- context "when setting to something besides the default" do
19
- before { SpecModel.solr_query_handler = 'search' }
20
-
21
- it { is_expected.to eq 'search' }
22
- end
23
- end
24
- end
@@ -1,114 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::RDF::IndexingService do
4
- before do
5
- class MyObj < ActiveFedora::Base
6
- property :created, predicate: ::RDF::Vocab::DC.created
7
- property :title, predicate: ::RDF::Vocab::DC.title
8
- property :publisher, predicate: ::RDF::Vocab::DC.publisher
9
- property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
10
- property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
11
- property :rights, predicate: ::RDF::Vocab::DC.rights
12
- end
13
- end
14
-
15
- after do
16
- Object.send(:remove_const, :MyObj)
17
- end
18
-
19
- let(:f2) do
20
- MyObj.new.tap do |obj|
21
- obj.created = [Date.parse("2012-03-04")]
22
- obj.title = ["Of Mice and Men, The Sequel"]
23
- obj.publisher = [RDF::Literal.new("Bob's Blogtastic Publishing", language: :fr)]
24
- obj.based_near = ["Tacoma, WA", "Renton, WA"]
25
- obj.related_url = ["http://example.org/blogtastic/"]
26
- obj.rights = ["Totally open, y'all"]
27
- end
28
- end
29
-
30
- let(:index_config) do
31
- {}.tap do |index_config|
32
- index_config[:created] = ActiveFedora::Indexing::Map::IndexObject.new(:created) do |index|
33
- index.as :sortable, :displayable
34
- index.type :date
35
- end
36
- index_config[:title] = ActiveFedora::Indexing::Map::IndexObject.new(:title) do |index|
37
- index.as :stored_searchable, :sortable
38
- index.type :text
39
- end
40
- index_config[:publisher] = ActiveFedora::Indexing::Map::IndexObject.new(:publisher) do |index|
41
- index.as :facetable, :sortable, :stored_searchable
42
- end
43
- index_config[:based_near] = ActiveFedora::Indexing::Map::IndexObject.new(:based_near) do |index|
44
- index.as :facetable, :stored_searchable
45
- index.type :text
46
- end
47
- index_config[:related_url] = ActiveFedora::Indexing::Map::IndexObject.new(:related_url) do |index|
48
- index.as :stored_searchable
49
- end
50
- end
51
- end
52
-
53
- describe "#index_config" do
54
- subject { indexer.index_config }
55
- context "without passing one in" do
56
- before do
57
- expect(Deprecation).to receive(:warn)
58
- allow(MyObj).to receive(:index_config).and_return(index_config)
59
- end
60
-
61
- let(:indexer) { described_class.new(f2) }
62
- it { is_expected.to eq(index_config) }
63
- end
64
-
65
- context "when passing one in" do
66
- let(:indexer) { described_class.new(f2, index_config) }
67
- it { is_expected.to eq(index_config) }
68
- end
69
- end
70
-
71
- let(:indexer) { described_class.new(f2, index_config) }
72
-
73
- describe "#generate_solr_document" do
74
- let(:solr_obj) { indexer.generate_solr_document(lambda { |key| "solr_rdf__#{key}" }) }
75
- it "returns the right fields" do
76
- expect(solr_obj.keys).to include(ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string),
77
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string),
78
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable),
79
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable),
80
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :sortable, type: :date),
81
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__created", :displayable),
82
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", type: :string),
83
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__title", :sortable),
84
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string),
85
- ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable))
86
- end
87
-
88
- it "returns the right values" do
89
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__related_url", type: :string)]).to eq ["http://example.org/blogtastic/"]
90
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", type: :string)]).to contain_exactly "Tacoma, WA", "Renton, WA"
91
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__based_near", :facetable)]).to contain_exactly "Tacoma, WA", "Renton, WA"
92
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", type: :string)]).to eq ["Bob's Blogtastic Publishing"]
93
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :sortable)]).to eq "Bob's Blogtastic Publishing"
94
- expect(solr_obj[ActiveFedora.index_field_mapper.solr_name("solr_rdf__publisher", :facetable)]).to eq ["Bob's Blogtastic Publishing"]
95
- end
96
- end
97
-
98
- describe "#fields" do
99
- let(:fields) { indexer.send(:fields) }
100
-
101
- it "returns the right fields" do
102
- expect(fields.keys).to eq ["created", "title", "publisher", "based_near", "related_url"]
103
- end
104
-
105
- it "returns the right values" do
106
- expect(fields["related_url"].values).to eq ["http://example.org/blogtastic/"]
107
- expect(fields["based_near"].values).to contain_exactly "Tacoma, WA", "Renton, WA"
108
- end
109
-
110
- it "returns the right type information" do
111
- expect(fields["created"].type).to eq :date
112
- end
113
- end
114
- end
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe ActiveFedora::RDF do
5
- describe ActiveFedora::RDF::Fcrepo do
6
- it "registers the vocabularies" do
7
- namespaces = [
8
- "info:fedora/fedora-system:def/model#",
9
- "info:fedora/fedora-system:def/view#",
10
- "info:fedora/fedora-system:def/relations-external#",
11
- "info:fedora/fedora-system:"
12
- ]
13
- namespaces.each do |namespace|
14
- vocab = RDF::Vocabulary.find(namespace)
15
- expect(vocab.superclass).to be(RDF::StrictVocabulary)
16
- end
17
- end
18
- end
19
- describe ActiveFedora::RDF::ProjectHydra do
20
- it "registers the vocabularies" do
21
- namespaces = [
22
- "http://projecthydra.org/ns/relations#"
23
- ]
24
- namespaces.each do |namespace|
25
- vocab = RDF::Vocabulary.find(namespace)
26
- expect(vocab.superclass).to be(RDF::StrictVocabulary)
27
- end
28
- end
29
- end
30
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Base do
4
- subject(:object) { described_class.new }
5
- it { is_expected.not_to be_readonly }
6
-
7
- describe "#readonly!" do
8
- it "makes the object readonly" do
9
- expect { object.readonly! }.to change { object.readonly? }.from(false).to(true)
10
- end
11
- end
12
-
13
- context "a readonly record" do
14
- before { object.readonly! }
15
-
16
- it "does not be destroyable" do
17
- expect { object.destroy }.to raise_error ActiveFedora::ReadOnlyRecord
18
- end
19
-
20
- it "does not be mutable" do
21
- expect { object.save }.to raise_error ActiveFedora::ReadOnlyRecord
22
- end
23
- end
24
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Reflection::AssociationReflection do
4
- describe "#derive_foreign_key" do
5
- subject { instance.send :derive_foreign_key }
6
- let(:name) { 'dummy' }
7
- let(:options) { { inverse_of: :default_permissions } }
8
- let(:active_fedora) { instance_double(ActiveFedora::Base) }
9
-
10
- context "when a has_many" do
11
- let(:instance) { ActiveFedora::Reflection::HasManyReflection.new(name, nil, options, active_fedora) }
12
-
13
- context "and the inverse is a collection association" do
14
- let(:inverse) { instance_double(ActiveFedora::Reflection::HasAndBelongsToManyReflection, collection?: true) }
15
- before { allow(instance).to receive(:inverse_of).and_return(inverse) }
16
- it { is_expected.to eq 'default_permission_ids' }
17
- end
18
- end
19
- end
20
-
21
- describe "#automatic_inverse_of" do
22
- before do
23
- class Dummy < ActiveFedora::Base
24
- belongs_to :foothing, predicate: ::RDF::Vocab::DC.extent
25
- end
26
- end
27
-
28
- after { Object.send(:remove_const, :Dummy) }
29
- subject { instance.send :automatic_inverse_of }
30
- let(:name) { 'dummy' }
31
- let(:options) { { as: 'foothing' } }
32
- let(:active_fedora) { instance_double(ActiveFedora::Base) }
33
-
34
- context "when a has_many" do
35
- let(:instance) { ActiveFedora::Reflection::HasManyReflection.new(name, nil, options, active_fedora) }
36
-
37
- context "and the inverse is a collection association" do
38
- it { is_expected.to eq :foothing }
39
- end
40
- end
41
- end
42
- end
@@ -1,37 +0,0 @@
1
- require "spec_helper"
2
- require 'ostruct'
3
- require "active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher"
4
-
5
- describe RSpec::Matchers, ".belong_to_associated_active_fedora_object" do
6
- let(:open_struct) { OpenStruct.new(id: id) }
7
- let(:id) { 123 }
8
- let(:object1) { Object.new }
9
- let(:object2) { Object.new }
10
- let(:association) { :association }
11
-
12
- it 'matches when association is properly stored in fedora' do
13
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
14
- expect(open_struct).to receive(association).and_return(object1)
15
- expect(open_struct).to belong_to_associated_active_fedora_object(association).with_object(object1)
16
- end
17
-
18
- it 'does not match when association is different' do
19
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
20
- expect(open_struct).to receive(association).and_return(object1)
21
- expect {
22
- expect(open_struct).to belong_to_associated_active_fedora_object(association).with_object(object2)
23
- }.to raise_error RSpec::Expectations::ExpectationNotMetError,
24
- /expected #{open_struct.class} ID=#{id} association: #{association.inspect}/
25
- end
26
-
27
- it 'requires :with_object option' do
28
- expect {
29
- expect(open_struct).to belong_to_associated_active_fedora_object(association)
30
- }.to(
31
- raise_error(
32
- ArgumentError,
33
- "expect(subject).to belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)"
34
- )
35
- )
36
- end
37
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
- require 'ostruct'
3
- require "active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher"
4
-
5
- describe RSpec::Matchers, ".have_many_associated_active_fedora_objects" do
6
- let(:open_struct) { OpenStruct.new(id: id) }
7
- let(:id) { 123 }
8
- let(:object1) { Object.new }
9
- let(:object2) { Object.new }
10
- let(:object3) { Object.new }
11
- let(:association) { :association }
12
-
13
- it 'matches when association is properly stored in fedora' do
14
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
15
- expect(open_struct).to receive(association).and_return([object1, object2])
16
- expect(open_struct).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
17
- end
18
-
19
- it 'does not match when association is different' do
20
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
21
- expect(open_struct).to receive(association).and_return([object1, object3])
22
- expect {
23
- expect(open_struct).to have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
24
- }.to raise_error RSpec::Expectations::ExpectationNotMetError,
25
- /expected #{open_struct.class} ID=#{id} association: #{association.inspect}/
26
- end
27
-
28
- it 'requires :with_objects option' do
29
- expect {
30
- expect(open_struct).to have_many_associated_active_fedora_objects(association)
31
- }.to(
32
- raise_error(
33
- ArgumentError,
34
- "expect(subject).to have_many_associated_active_fedora_objects(<association_name>).with_objects(<objects[]>)"
35
- )
36
- )
37
- end
38
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
- require 'ostruct'
3
- require "active_fedora/rspec_matchers/have_predicate_matcher"
4
-
5
- describe RSpec::Matchers, ".have_predicate" do
6
- let(:open_struct) { OpenStruct.new(id: id) }
7
- let(:id) { 123 }
8
- let(:object1) { Object.new }
9
- let(:object2) { Object.new }
10
- let(:object3) { Object.new }
11
- let(:predicate) { :predicate }
12
-
13
- it 'matches when relationship is "what we have in Fedora"' do
14
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
15
- expect(open_struct).to receive(:relationships).with(predicate).and_return([object1, object2])
16
- expect(open_struct).to have_predicate(predicate).with_objects([object1, object2])
17
- end
18
-
19
- it 'does not match when relationship is different' do
20
- expect(open_struct.class).to receive(:find).with(id).and_return(open_struct)
21
- expect(open_struct).to receive(:relationships).with(predicate).and_return([object1, object3])
22
- expect {
23
- expect(open_struct).to have_predicate(predicate).with_objects([object1, object2])
24
- }.to raise_error RSpec::Expectations::ExpectationNotMetError,
25
- /expected #{open_struct.class} ID=#{id} relationship: #{predicate.inspect}/
26
- end
27
-
28
- it 'requires :with_objects option' do
29
- expect {
30
- expect(open_struct).to have_predicate(predicate)
31
- }.to(
32
- raise_error(
33
- ArgumentError,
34
- "expect(subject).to have_predicate(<predicate>).with_objects(<objects[]>)"
35
- )
36
- )
37
- end
38
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::SchemaIndexingStrategy do
4
- subject(:index_strategy) { described_class.new(property_indexer_factory) }
5
-
6
- describe "#apply" do
7
- let(:property) do
8
- p = object_double(ActiveTriples::Property.new(name: nil))
9
- allow(p).to receive(:to_h).and_return(options)
10
- allow(p).to receive(:name).and_return(name)
11
- p
12
- end
13
- let(:name) { "Name" }
14
- let(:options) do
15
- {
16
- class_name: "Test"
17
- }
18
- end
19
- let(:object) do
20
- o = object_double(ActiveFedora::Base)
21
- allow(o).to receive(:property).and_yield(index_configuration)
22
- o
23
- end
24
- let(:index_configuration) do
25
- d = double("index configuration")
26
- allow(d).to receive(:as)
27
- d
28
- end
29
- let(:property_indexer) do
30
- p = double("property_indexer")
31
- allow(p).to receive(:index).with(anything) do |index|
32
- index.as(*Array.wrap(index_types))
33
- end
34
- p
35
- end
36
- let(:property_indexer_factory) do
37
- p = double("property indexer factory")
38
- allow(p).to receive(:new).with(anything).and_return(property_indexer)
39
- p
40
- end
41
- let(:index_types) {}
42
- context "with no index types" do
43
- subject(:index_strategy) { described_class.new }
44
- it "does not try to index it" do
45
- index_strategy.apply(object, property)
46
-
47
- expect(object).to have_received(:property).with(property.name, property.to_h)
48
- expect(index_configuration).not_to have_received(:as)
49
- end
50
- end
51
- context "with one index type" do
52
- let(:index_types) { :symbol }
53
- it "applies that one" do
54
- index_strategy.apply(object, property)
55
-
56
- expect(index_configuration).to have_received(:as).with(:symbol)
57
- end
58
- end
59
- context "with multiple index types" do
60
- let(:index_types) { [:symbol, :stored_searchable] }
61
- it "applies all of them" do
62
- index_strategy.apply(object, property)
63
-
64
- expect(index_configuration).to have_received(:as).with(:symbol, :stored_searchable)
65
- end
66
- end
67
- end
68
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Scoping::Default do
4
- describe "when default_scope is overridden" do
5
- before do
6
- class Book < ActiveFedora::Base
7
- property :published, predicate: ::RDF::Vocab::EBUCore.pubStatus do |index|
8
- index.as :symbol
9
- end
10
-
11
- def self.default_scope
12
- where published_ssim: 'true'
13
- end
14
- end
15
-
16
- Book.destroy_all
17
- Book.create!(published: [true])
18
- Book.create!(published: [true])
19
- Book.create!(published: [false])
20
- end
21
-
22
- after do
23
- Object.send(:remove_const, :Book)
24
- end
25
-
26
- it "returns only the scoped records" do
27
- expect(Book.all.size).to eq 2
28
- end
29
-
30
- it "returns all the records" do
31
- Book.unscoped do
32
- expect(Book.all.size).to eq 3
33
- end
34
- end
35
- end
36
-
37
- describe "when default_scope is called" do
38
- before do
39
- class Book < ActiveFedora::Base
40
- property :published, predicate: ::RDF::Vocab::EBUCore.pubStatus do |index|
41
- index.as :symbol
42
- end
43
-
44
- default_scope -> { where published_ssim: 'true' }
45
- end
46
-
47
- Book.destroy_all
48
- Book.create!(published: [true])
49
- Book.create!(published: [true])
50
- Book.create!(published: [false])
51
- end
52
-
53
- after do
54
- Object.send(:remove_const, :Book)
55
- end
56
-
57
- it "returns only the scoped records" do
58
- expect(Book.all.size).to eq 2
59
- end
60
-
61
- it "returns all the records" do
62
- Book.unscoped do
63
- expect(Book.all.size).to eq 3
64
- end
65
- end
66
- end
67
- end