active-fedora 10.2.1 → 11.0.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/.gitignore +1 -0
- data/.rubocop.yml +6 -7
- data/.rubocop_todo.yml +55 -0
- data/active-fedora.gemspec +6 -10
- data/lib/active_fedora/aggregation/list_source.rb +2 -0
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -1
- data/lib/active_fedora/associations/builder/orders.rb +11 -3
- data/lib/active_fedora/associations/collection_association.rb +3 -3
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +2 -2
- data/lib/active_fedora/associations/orders_association.rb +4 -0
- data/lib/active_fedora/associations/rdf.rb +2 -0
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +4 -8
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/core.rb +22 -27
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/indexing.rb +0 -17
- data/lib/active_fedora/indexing_service.rb +0 -9
- data/lib/active_fedora/loadable_from_json.rb +12 -1
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/orders/list_node.rb +2 -2
- data/lib/active_fedora/orders/ordered_list.rb +7 -3
- data/lib/active_fedora/orders/target_proxy.rb +4 -0
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rdf/persistence.rb +1 -0
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/solr_hit.rb +0 -13
- data/lib/active_fedora/solr_query_builder.rb +17 -13
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -12
- data/lib/generators/active_fedora/model/model_generator.rb +1 -1
- data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +23 -24
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/basic_contains_association_spec.rb +1 -1
- data/spec/integration/clean_connection_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -17
- data/spec/integration/direct_container_spec.rb +12 -12
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +32 -34
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
- data/spec/integration/has_many_associations_spec.rb +9 -11
- data/spec/integration/indexing_spec.rb +2 -2
- data/spec/integration/indirect_container_spec.rb +11 -12
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/scoped_query_spec.rb +3 -3
- data/spec/integration/solr_hit_spec.rb +4 -15
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/integration/with_metadata_spec.rb +1 -1
- data/spec/spec_helper.rb +52 -10
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +16 -23
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +3 -4
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/filter_spec.rb +3 -3
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
- data/spec/unit/has_many_association_spec.rb +26 -11
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +6 -6
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +144 -147
- data/spec/unit/orders/list_node_spec.rb +21 -21
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +6 -6
- data/spec/unit/rdf/indexing_service_spec.rb +29 -29
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +17 -91
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/profile_indexing_service.rb +0 -11
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/lib/active_fedora/solr_instance_loader.rb +0 -47
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
- data/spec/integration/ntriples_datastream_spec.rb +0 -203
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/integration/solr_instance_loader_spec.rb +0 -156
- data/spec/samples/hydra-mods_article_datastream.rb +0 -517
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -170
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
require 'config_helper'
|
|
3
3
|
|
|
4
4
|
describe ActiveFedora::FileConfigurator do
|
|
5
|
-
subject { ActiveFedora.configurator }
|
|
5
|
+
subject(:configurator) { ActiveFedora.configurator }
|
|
6
6
|
|
|
7
7
|
after :all do
|
|
8
8
|
unstub_rails
|
|
@@ -19,111 +19,111 @@ describe ActiveFedora::FileConfigurator do
|
|
|
19
19
|
|
|
20
20
|
describe "#config_options" do
|
|
21
21
|
before do
|
|
22
|
-
|
|
22
|
+
configurator.reset!
|
|
23
23
|
end
|
|
24
24
|
it "is an empty hash" do
|
|
25
|
-
expect(
|
|
25
|
+
expect(configurator.config_options).to eq({})
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe "#fedora_config" do
|
|
30
30
|
before do
|
|
31
|
-
|
|
31
|
+
configurator.reset!
|
|
32
32
|
end
|
|
33
33
|
it "triggers configuration to load" do
|
|
34
|
-
expect(
|
|
35
|
-
|
|
34
|
+
expect(configurator).to receive(:load_fedora_config)
|
|
35
|
+
configurator.fedora_config
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
describe "#solr_config" do
|
|
39
39
|
before do
|
|
40
|
-
|
|
40
|
+
configurator.reset!
|
|
41
41
|
end
|
|
42
42
|
it "triggers configuration to load" do
|
|
43
|
-
expect(
|
|
44
|
-
|
|
43
|
+
expect(configurator).to receive(:load_solr_config)
|
|
44
|
+
configurator.solr_config
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
describe "#reset!" do
|
|
49
|
-
before {
|
|
49
|
+
before { configurator.reset! }
|
|
50
50
|
it "clears @fedora_config" do
|
|
51
|
-
expect(
|
|
51
|
+
expect(configurator.instance_variable_get(:@fedora_config)).to eq({})
|
|
52
52
|
end
|
|
53
53
|
it "clears @solr_config" do
|
|
54
|
-
expect(
|
|
54
|
+
expect(configurator.instance_variable_get(:@solr_config)).to eq({})
|
|
55
55
|
end
|
|
56
56
|
it "clears @config_options" do
|
|
57
|
-
expect(
|
|
57
|
+
expect(configurator.instance_variable_get(:@config_options)).to eq({})
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
describe "initialization methods" do
|
|
62
62
|
describe "config_path(:fedora)" do
|
|
63
63
|
it "uses the config_options[:config_path] if it exists" do
|
|
64
|
-
expect(
|
|
64
|
+
expect(configurator).to receive(:config_options).and_return(fedora_config_path: "/path/to/fedora.yml")
|
|
65
65
|
expect(File).to receive(:file?).with("/path/to/fedora.yml").and_return(true)
|
|
66
|
-
expect(
|
|
66
|
+
expect(configurator.config_path(:fedora)).to eql("/path/to/fedora.yml")
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "looks in Rails.root/config/fedora.yml if it exists and no fedora_config_path passed in" do
|
|
70
|
-
expect(
|
|
70
|
+
expect(configurator).to receive(:config_options).and_return({})
|
|
71
71
|
stub_rails(root: "/rails/root")
|
|
72
72
|
expect(File).to receive(:file?).with("/rails/root/config/fedora.yml").and_return(true)
|
|
73
|
-
expect(
|
|
73
|
+
expect(configurator.config_path(:fedora)).to eql("/rails/root/config/fedora.yml")
|
|
74
74
|
unstub_rails
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it "looks in ./config/fedora.yml if neither rails.root nor :fedora_config_path are set" do
|
|
78
|
-
expect(
|
|
78
|
+
expect(configurator).to receive(:config_options).and_return({})
|
|
79
79
|
allow(Dir).to receive(:getwd).and_return("/current/working/directory")
|
|
80
80
|
expect(File).to receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(true)
|
|
81
|
-
expect(
|
|
81
|
+
expect(configurator.config_path(:fedora)).to eql("/current/working/directory/config/fedora.yml")
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "returns default fedora.yml that ships with active-fedora if none of the above" do
|
|
85
|
-
expect(
|
|
85
|
+
expect(configurator).to receive(:config_options).and_return({})
|
|
86
86
|
expect(Dir).to receive(:getwd).and_return("/current/working/directory")
|
|
87
87
|
expect(File).to receive(:file?).with("/current/working/directory/config/fedora.yml").and_return(false)
|
|
88
88
|
expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'fedora.yml'))).and_return(true)
|
|
89
89
|
expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
|
|
90
|
-
expect(
|
|
90
|
+
expect(configurator.config_path(:fedora)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'fedora.yml')))
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
describe "config_path(:solr)" do
|
|
95
95
|
it "returns the solr_config_path if set in config_options hash" do
|
|
96
|
-
allow(
|
|
96
|
+
allow(configurator).to receive(:config_options).and_return(solr_config_path: "/path/to/solr.yml")
|
|
97
97
|
expect(File).to receive(:file?).with("/path/to/solr.yml").and_return(true)
|
|
98
|
-
expect(
|
|
98
|
+
expect(configurator.config_path(:solr)).to eql("/path/to/solr.yml")
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
it "returns the solr.yml file in the same directory as the fedora.yml if it exists" do
|
|
102
|
-
expect(
|
|
102
|
+
expect(configurator).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
|
|
103
103
|
expect(File).to receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(true)
|
|
104
|
-
expect(
|
|
104
|
+
expect(configurator.config_path(:solr)).to eql("/path/to/fedora/config/solr.yml")
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
context "no solr.yml in same directory as fedora.yml and fedora.yml does not contain solr url" do
|
|
108
|
-
before
|
|
109
|
-
allow(
|
|
110
|
-
expect(
|
|
108
|
+
before do
|
|
109
|
+
allow(configurator).to receive(:config_options).and_return({})
|
|
110
|
+
expect(configurator).to receive(:path).and_return("/path/to/fedora/config/fedora.yml")
|
|
111
111
|
expect(File).to receive(:file?).with("/path/to/fedora/config/solr.yml").and_return(false)
|
|
112
112
|
end
|
|
113
|
-
after
|
|
113
|
+
after do
|
|
114
114
|
unstub_rails
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
it "does not raise an error if there is not a solr.yml in the same directory as the fedora.yml and the fedora.yml has a solr url defined and look in rails.root" do
|
|
118
118
|
stub_rails(root: "/rails/root")
|
|
119
119
|
expect(File).to receive(:file?).with("/rails/root/config/solr.yml").and_return(true)
|
|
120
|
-
expect(
|
|
120
|
+
expect(configurator.config_path(:solr)).to eql("/rails/root/config/solr.yml")
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
it "looks in ./config/solr.yml if no rails root" do
|
|
124
124
|
allow(Dir).to receive(:getwd).and_return("/current/working/directory")
|
|
125
125
|
expect(File).to receive(:file?).with("/current/working/directory/config/solr.yml").and_return(true)
|
|
126
|
-
expect(
|
|
126
|
+
expect(configurator.config_path(:solr)).to eql("/current/working/directory/config/solr.yml")
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it "returns the default solr.yml file that ships with active-fedora if no other option is set" do
|
|
@@ -131,109 +131,109 @@ describe ActiveFedora::FileConfigurator do
|
|
|
131
131
|
expect(File).to receive(:file?).with("/current/working/directory/config/solr.yml").and_return(false)
|
|
132
132
|
expect(File).to receive(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'solr.yml'))).and_return(true)
|
|
133
133
|
expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default solr.yml that comes with active-fedora. If you want to override this, pass the path to solr.yml to ActiveFedora - ie. ActiveFedora.init(:solr_config_path => '/path/to/solr.yml') - or set Rails.root and put solr.yml into \#{Rails.root}/config.")
|
|
134
|
-
expect(
|
|
134
|
+
expect(configurator.config_path(:solr)).to eql(File.expand_path(File.join(File.dirname("__FILE__"), 'config', 'solr.yml')))
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
describe "load_fedora_config" do
|
|
140
|
-
before
|
|
141
|
-
|
|
140
|
+
before do
|
|
141
|
+
configurator.reset!
|
|
142
142
|
end
|
|
143
143
|
it "loads the file specified in fedora_config_path" do
|
|
144
|
-
allow(
|
|
145
|
-
expect(
|
|
146
|
-
expect(
|
|
144
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
145
|
+
expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
|
|
146
|
+
expect(configurator).to receive(:load_solr_config)
|
|
147
147
|
expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n url: http://myfedora:8080")
|
|
148
|
-
expect(
|
|
149
|
-
expect(
|
|
148
|
+
expect(configurator.load_fedora_config).to eq(url: "http://myfedora:8080")
|
|
149
|
+
expect(configurator.fedora_config).to eq(url: "http://myfedora:8080")
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
it "allows sharding" do
|
|
153
|
-
allow(
|
|
154
|
-
expect(
|
|
155
|
-
expect(
|
|
153
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
154
|
+
expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
|
|
155
|
+
expect(configurator).to receive(:load_solr_config)
|
|
156
156
|
expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:8983\ntest:\n- url: http://myfedora:8080\n- url: http://myfedora:8081")
|
|
157
|
-
expect(
|
|
158
|
-
expect(
|
|
157
|
+
expect(configurator.load_fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
|
|
158
|
+
expect(configurator.fedora_config).to eq [{ url: "http://myfedora:8080" }, { url: "http://myfedora:8081" }]
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
it "parses the file using ERb" do
|
|
162
|
-
allow(
|
|
163
|
-
expect(
|
|
164
|
-
expect(
|
|
162
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
163
|
+
expect(configurator).to receive(:config_path).with(:fedora).and_return("/path/to/fedora.yml")
|
|
164
|
+
expect(configurator).to receive(:load_solr_config)
|
|
165
165
|
expect(IO).to receive(:read).with("/path/to/fedora.yml").and_return("development:\n url: http://devfedora:<%= 8983 %>\ntest:\n url: http://myfedora:<%= 8081 %>")
|
|
166
|
-
expect(
|
|
167
|
-
expect(
|
|
166
|
+
expect(configurator.load_fedora_config).to eq(url: "http://myfedora:8081")
|
|
167
|
+
expect(configurator.fedora_config).to eq(url: "http://myfedora:8081")
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
describe "load_solr_config" do
|
|
172
|
-
before
|
|
173
|
-
|
|
172
|
+
before do
|
|
173
|
+
configurator.reset!
|
|
174
174
|
end
|
|
175
175
|
it "loads the file specified in solr_config_path" do
|
|
176
|
-
allow(
|
|
177
|
-
expect(
|
|
178
|
-
expect(
|
|
176
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
177
|
+
expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
|
|
178
|
+
expect(configurator).to receive(:load_fedora_config)
|
|
179
179
|
expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
|
|
180
|
-
expect(
|
|
181
|
-
expect(
|
|
180
|
+
expect(configurator.load_solr_config).to eq(url: "http://mysolr:8080")
|
|
181
|
+
expect(configurator.solr_config).to eq(url: "http://mysolr:8080")
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
it "parses the file using ERb" do
|
|
185
|
-
allow(
|
|
186
|
-
expect(
|
|
187
|
-
expect(
|
|
185
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
186
|
+
expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
|
|
187
|
+
expect(configurator).to receive(:load_fedora_config)
|
|
188
188
|
expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("development:\n default:\n url: http://devsolr:<%= 8983 %>\ntest:\n default:\n url: http://mysolr:<%= 8081 %>")
|
|
189
|
-
expect(
|
|
190
|
-
expect(
|
|
189
|
+
expect(configurator.load_solr_config).to eq(url: "http://mysolr:8081")
|
|
190
|
+
expect(configurator.solr_config).to eq(url: "http://mysolr:8081")
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
it "includes update_path and select_path in solr_config" do
|
|
194
|
-
allow(
|
|
195
|
-
expect(
|
|
196
|
-
expect(
|
|
194
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
195
|
+
expect(configurator).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
|
|
196
|
+
expect(configurator).to receive(:load_fedora_config)
|
|
197
197
|
expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("test:\n url: http://mysolr:8080\n update_path: update_test\n select_path: select_test\n")
|
|
198
|
-
expect(
|
|
199
|
-
expect(
|
|
198
|
+
expect(configurator.solr_config[:update_path]).to eq('update_test')
|
|
199
|
+
expect(configurator.solr_config[:select_path]).to eq('select_test')
|
|
200
200
|
end
|
|
201
201
|
end
|
|
202
202
|
|
|
203
203
|
describe "load_configs" do
|
|
204
204
|
describe "when config is not loaded" do
|
|
205
205
|
before do
|
|
206
|
-
|
|
206
|
+
configurator.instance_variable_set :@config_loaded, nil
|
|
207
207
|
end
|
|
208
208
|
it "loads the fedora and solr configs" do
|
|
209
|
-
expect(
|
|
210
|
-
|
|
211
|
-
expect(
|
|
209
|
+
expect(configurator).to_not be_config_loaded
|
|
210
|
+
configurator.load_configs
|
|
211
|
+
expect(configurator).to be_config_loaded
|
|
212
212
|
end
|
|
213
213
|
end
|
|
214
214
|
describe "when config is loaded" do
|
|
215
215
|
before do
|
|
216
|
-
|
|
216
|
+
configurator.instance_variable_set :@config_loaded, true
|
|
217
217
|
end
|
|
218
218
|
it "loads the fedora and solr configs" do
|
|
219
|
-
expect(
|
|
220
|
-
expect(
|
|
221
|
-
|
|
222
|
-
expect(
|
|
219
|
+
expect(configurator).to receive(:load_config).never
|
|
220
|
+
expect(configurator).to be_config_loaded
|
|
221
|
+
configurator.load_configs
|
|
222
|
+
expect(configurator).to be_config_loaded
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
describe "check_fedora_path_for_solr" do
|
|
228
228
|
it "finds the solr.yml file and return it if it exists" do
|
|
229
|
-
expect(
|
|
229
|
+
expect(configurator).to receive(:path).and_return("/path/to/fedora/fedora.yml")
|
|
230
230
|
expect(File).to receive(:file?).with("/path/to/fedora/solr.yml").and_return(true)
|
|
231
|
-
expect(
|
|
231
|
+
expect(configurator.check_fedora_path_for_solr).to eq "/path/to/fedora/solr.yml"
|
|
232
232
|
end
|
|
233
233
|
it "returns nil if the solr.yml file is not there" do
|
|
234
|
-
expect(
|
|
234
|
+
expect(configurator).to receive(:path).and_return("/path/to/fedora/fedora.yml")
|
|
235
235
|
expect(File).to receive(:file?).with("/path/to/fedora/solr.yml").and_return(false)
|
|
236
|
-
expect(
|
|
236
|
+
expect(configurator.check_fedora_path_for_solr).to be_nil
|
|
237
237
|
end
|
|
238
238
|
end
|
|
239
239
|
end
|
|
@@ -250,32 +250,32 @@ describe ActiveFedora::FileConfigurator do
|
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
it "can tell its config paths" do
|
|
253
|
-
|
|
254
|
-
expect(
|
|
253
|
+
configurator.init
|
|
254
|
+
expect(configurator).to respond_to(:solr_config_path)
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
it "loads a config from the current working directory as a second choice" do
|
|
258
|
-
allow(
|
|
258
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
259
259
|
allow(Dir).to receive(:getwd).and_return(@fake_rails_root)
|
|
260
|
-
|
|
261
|
-
expect(
|
|
262
|
-
expect(
|
|
260
|
+
configurator.init
|
|
261
|
+
expect(configurator.config_path(:fedora)).to eql("#{@fake_rails_root}/config/fedora.yml")
|
|
262
|
+
expect(configurator.solr_config_path).to eql("#{@fake_rails_root}/config/solr.yml")
|
|
263
263
|
end
|
|
264
264
|
|
|
265
265
|
it "loads the config that ships with this gem as a last choice" do
|
|
266
266
|
allow(Dir).to receive(:getwd).and_return("/fake/path")
|
|
267
|
-
allow(
|
|
267
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
268
268
|
expect(ActiveFedora::Base.logger).to receive(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml') - or set Rails.root and put fedora.yml into \#{Rails.root}/config.").exactly(3).times
|
|
269
|
-
|
|
269
|
+
configurator.init
|
|
270
270
|
expected_config = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config"))
|
|
271
|
-
expect(
|
|
272
|
-
expect(
|
|
271
|
+
expect(configurator.config_path(:fedora)).to eql(expected_config + '/fedora.yml')
|
|
272
|
+
expect(configurator.solr_config_path).to eql(expected_config + '/solr.yml')
|
|
273
273
|
end
|
|
274
274
|
it "raises an error if you pass in a string" do
|
|
275
|
-
expect(lambda {
|
|
275
|
+
expect(lambda { configurator.init("#{@fake_rails_root}/config/fake_fedora.yml") }).to raise_exception(ArgumentError)
|
|
276
276
|
end
|
|
277
277
|
it "raises an error if you pass in a non-existant config file" do
|
|
278
|
-
expect(lambda {
|
|
278
|
+
expect(lambda { configurator.init(fedora_config_path: "really_fake_fedora.yml") }).to raise_exception(ActiveFedora::ConfigurationError)
|
|
279
279
|
end
|
|
280
280
|
|
|
281
281
|
describe "within Rails" do
|
|
@@ -288,15 +288,15 @@ describe ActiveFedora::FileConfigurator do
|
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
it "loads a config from Rails.root as a first choice" do
|
|
291
|
-
allow(
|
|
292
|
-
|
|
293
|
-
expect(
|
|
294
|
-
expect(
|
|
291
|
+
allow(configurator).to receive(:load_solrizer_config)
|
|
292
|
+
configurator.init
|
|
293
|
+
expect(configurator.config_path(:fedora)).to eql("#{Rails.root}/config/fedora.yml")
|
|
294
|
+
expect(configurator.solr_config_path).to eql("#{Rails.root}/config/solr.yml")
|
|
295
295
|
end
|
|
296
296
|
|
|
297
297
|
it "can tell what environment it is set to run in" do
|
|
298
298
|
stub_rails(env: "development")
|
|
299
|
-
|
|
299
|
+
configurator.init
|
|
300
300
|
expect(ActiveFedora.environment).to eql("development")
|
|
301
301
|
end
|
|
302
302
|
end
|
|
@@ -9,7 +9,7 @@ describe ActiveFedora::FilePathBuilder do
|
|
|
9
9
|
|
|
10
10
|
context "when some datastreams exist" do
|
|
11
11
|
before do
|
|
12
|
-
allow(parent).to receive(:attached_files).and_return('FOO56' =>
|
|
12
|
+
allow(parent).to receive(:attached_files).and_return('FOO56' => instance_double(ActiveFedora::File))
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it { should eq 'FOO57' }
|
data/spec/unit/file_spec.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
|
3
3
|
describe ActiveFedora::File do
|
|
4
4
|
let(:file) { described_class.new }
|
|
5
5
|
|
|
6
|
-
subject { file }
|
|
6
|
+
subject(:af_file) { file }
|
|
7
7
|
|
|
8
8
|
it { is_expected.not_to be_metadata }
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ describe ActiveFedora::File do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
describe "#uri" do
|
|
46
|
-
subject { file.uri }
|
|
46
|
+
subject(:uri) { file.uri }
|
|
47
47
|
|
|
48
48
|
context "when the file is in an ldp:BasicContainer" do
|
|
49
49
|
let(:parent) { ActiveFedora::Base.new(id: '1234') }
|
|
@@ -51,14 +51,14 @@ describe ActiveFedora::File do
|
|
|
51
51
|
context "and it's initialized with the URI" do
|
|
52
52
|
let(:file) { described_class.new(parent.uri + "/FOO1") }
|
|
53
53
|
it "works" do
|
|
54
|
-
expect(
|
|
54
|
+
expect(uri.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
context "and it's initialized with an ID" do
|
|
59
59
|
let(:file) { described_class.new(parent.id + "/FOO1") }
|
|
60
60
|
it "works" do
|
|
61
|
-
expect(
|
|
61
|
+
expect(uri.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -91,18 +91,18 @@ describe ActiveFedora::File do
|
|
|
91
91
|
let(:ldp_source) { Ldp::Resource.new(mock_client, path) }
|
|
92
92
|
|
|
93
93
|
before do
|
|
94
|
-
allow(
|
|
94
|
+
allow(af_file).to receive(:ldp_source).and_return(ldp_source)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
describe '#persisted_size' do
|
|
98
98
|
it 'loads the file size attribute from the fedora repository' do
|
|
99
|
-
expect(
|
|
99
|
+
expect(af_file.size).to eq 9999
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it 'returns nil without making a head request to Ldp::Resource::BinarySource if it is a new record' do
|
|
103
|
-
allow(
|
|
104
|
-
expect(
|
|
105
|
-
expect(
|
|
103
|
+
allow(af_file).to receive(:new_record?).and_return(true)
|
|
104
|
+
expect(af_file.ldp_source).not_to receive(:head)
|
|
105
|
+
expect(af_file.persisted_size).to eq nil
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -110,17 +110,17 @@ describe ActiveFedora::File do
|
|
|
110
110
|
context 'when content has changed from what is currently persisted' do
|
|
111
111
|
context 'and has been set to something that has a #size method (i.e. string or File)' do
|
|
112
112
|
it 'returns the size of the dirty content' do
|
|
113
|
-
dirty_content =
|
|
113
|
+
dirty_content = instance_double(::File)
|
|
114
114
|
allow(dirty_content).to receive(:size) { 8_675_309 }
|
|
115
|
-
|
|
116
|
-
expect(
|
|
115
|
+
af_file.content = dirty_content
|
|
116
|
+
expect(af_file.size).to eq dirty_content.size
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
context 'when content has not changed from what is currently persisted' do
|
|
122
122
|
it 'returns nil, indicating that the content is not "dirty", but its not necessarily 0 either.' do
|
|
123
|
-
expect(
|
|
123
|
+
expect(af_file.dirty_size).to be_nil
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
end
|
|
@@ -128,55 +128,55 @@ describe ActiveFedora::File do
|
|
|
128
128
|
describe '#size' do
|
|
129
129
|
context 'when content has not changed' do
|
|
130
130
|
it 'returns the value of .persisted_size' do
|
|
131
|
-
expect(
|
|
131
|
+
expect(af_file.size).to eq af_file.persisted_size
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
context 'when content has changed' do
|
|
136
136
|
it 'returns the value of .dirty_size' do
|
|
137
|
-
|
|
138
|
-
expect(
|
|
137
|
+
af_file.content = "i have changed!"
|
|
138
|
+
expect(af_file.size).to eq af_file.dirty_size
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
it 'returns nil when #persisted_size and #dirty_size return nil' do
|
|
143
|
-
allow(
|
|
144
|
-
allow(
|
|
145
|
-
expect(
|
|
143
|
+
allow(af_file).to receive(:persisted_size) { nil }
|
|
144
|
+
allow(af_file).to receive(:dirty_size) { nil }
|
|
145
|
+
expect(af_file.size).to be_nil
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
describe ".empty?" do
|
|
150
150
|
it "does not be empty" do
|
|
151
|
-
expect(
|
|
151
|
+
expect(af_file.empty?).to be false
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
describe ".has_content?" do
|
|
156
156
|
context "when there's content" do
|
|
157
157
|
before do
|
|
158
|
-
allow(
|
|
158
|
+
allow(af_file).to receive(:size).and_return(10)
|
|
159
159
|
end
|
|
160
160
|
it "returns true" do
|
|
161
|
-
expect(
|
|
161
|
+
expect(af_file.has_content?).to be true
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
context "when size is nil" do
|
|
166
166
|
before do
|
|
167
|
-
allow(
|
|
167
|
+
allow(af_file).to receive(:size).and_return(nil)
|
|
168
168
|
end
|
|
169
169
|
it "does not have content" do
|
|
170
|
-
expect(
|
|
170
|
+
expect(af_file).to_not have_content
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
context "when content is zero" do
|
|
175
175
|
before do
|
|
176
|
-
allow(
|
|
176
|
+
allow(af_file).to receive(:size).and_return(0)
|
|
177
177
|
end
|
|
178
178
|
it "returns false" do
|
|
179
|
-
expect(
|
|
179
|
+
expect(af_file.has_content?).to be false
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
182
|
end
|
|
@@ -286,14 +286,14 @@ describe ActiveFedora::File do
|
|
|
286
286
|
describe "#checksum" do
|
|
287
287
|
let(:digest) { RDF::URI.new("urn:sha1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15") }
|
|
288
288
|
before do
|
|
289
|
-
allow(
|
|
289
|
+
allow(af_file).to receive(:digest) { [digest] }
|
|
290
290
|
end
|
|
291
291
|
its(:checksum) { is_expected.to be_a(ActiveFedora::Checksum) }
|
|
292
292
|
it "has the right value" do
|
|
293
|
-
expect(
|
|
293
|
+
expect(af_file.checksum.value).to eq("f1d2d2f924e986ac86fdf7b36c94bcdf32beec15")
|
|
294
294
|
end
|
|
295
295
|
it "has the right algorithm" do
|
|
296
|
-
expect(
|
|
296
|
+
expect(af_file.checksum.algorithm).to eq("SHA1")
|
|
297
297
|
end
|
|
298
298
|
end
|
|
299
299
|
|
|
@@ -358,7 +358,7 @@ describe ActiveFedora::File do
|
|
|
358
358
|
Object.send(:remove_const, :MyFile)
|
|
359
359
|
end
|
|
360
360
|
|
|
361
|
-
subject { MyFile.new }
|
|
361
|
+
subject(:my_file) { MyFile.new }
|
|
362
362
|
|
|
363
363
|
describe "initialize" do
|
|
364
364
|
specify {
|
|
@@ -370,21 +370,21 @@ describe ActiveFedora::File do
|
|
|
370
370
|
describe "create" do
|
|
371
371
|
describe "when content is not nil" do
|
|
372
372
|
specify {
|
|
373
|
-
expect(
|
|
374
|
-
expect(
|
|
375
|
-
expect(
|
|
376
|
-
expect(
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
expect(my_file).to receive(:b_create).once
|
|
374
|
+
expect(my_file).to receive(:a_create).once
|
|
375
|
+
expect(my_file).to receive(:b_save).once
|
|
376
|
+
expect(my_file).to receive(:a_save).once
|
|
377
|
+
my_file.content = "foo"
|
|
378
|
+
my_file.save
|
|
379
379
|
}
|
|
380
380
|
end
|
|
381
381
|
describe "when content is nil" do
|
|
382
382
|
specify {
|
|
383
|
-
expect(
|
|
384
|
-
expect(
|
|
385
|
-
expect(
|
|
386
|
-
expect(
|
|
387
|
-
|
|
383
|
+
expect(my_file).to receive(:b_create).once
|
|
384
|
+
expect(my_file).not_to receive(:a_create)
|
|
385
|
+
expect(my_file).to receive(:b_save).once
|
|
386
|
+
expect(my_file).not_to receive(:a_save)
|
|
387
|
+
my_file.save
|
|
388
388
|
}
|
|
389
389
|
end
|
|
390
390
|
end
|
|
@@ -392,36 +392,36 @@ describe ActiveFedora::File do
|
|
|
392
392
|
describe "update" do
|
|
393
393
|
describe "when content has changed" do
|
|
394
394
|
specify {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
expect(
|
|
398
|
-
expect(
|
|
399
|
-
expect(
|
|
400
|
-
expect(
|
|
401
|
-
|
|
402
|
-
|
|
395
|
+
my_file.content = "foo"
|
|
396
|
+
my_file.save
|
|
397
|
+
expect(my_file).to receive(:b_save).once
|
|
398
|
+
expect(my_file).to receive(:a_save).once
|
|
399
|
+
expect(my_file).to receive(:b_update).once
|
|
400
|
+
expect(my_file).to receive(:a_update).once
|
|
401
|
+
my_file.content = "bar"
|
|
402
|
+
my_file.save
|
|
403
403
|
}
|
|
404
404
|
end
|
|
405
405
|
describe "when content has not changed" do
|
|
406
406
|
specify {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
expect(
|
|
410
|
-
expect(
|
|
411
|
-
expect(
|
|
412
|
-
expect(
|
|
413
|
-
|
|
407
|
+
my_file.content = "foo"
|
|
408
|
+
my_file.save
|
|
409
|
+
expect(my_file).to receive(:b_save).once
|
|
410
|
+
expect(my_file).to receive(:a_save)
|
|
411
|
+
expect(my_file).to receive(:b_update).once
|
|
412
|
+
expect(my_file).to receive(:a_update)
|
|
413
|
+
my_file.save
|
|
414
414
|
}
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
418
418
|
describe "destroy" do
|
|
419
419
|
specify {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
expect(
|
|
423
|
-
expect(
|
|
424
|
-
|
|
420
|
+
my_file.content = "foo"
|
|
421
|
+
my_file.save
|
|
422
|
+
expect(my_file).to receive(:b_destroy).once
|
|
423
|
+
expect(my_file).to receive(:a_destroy).once
|
|
424
|
+
my_file.destroy
|
|
425
425
|
}
|
|
426
426
|
end
|
|
427
427
|
end
|