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,111 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::WithMetadata do
4
- before do
5
- class AdditionalSchema < ActiveTriples::Schema
6
- property :new_property, predicate: ::RDF::URI("http://my.new.property/")
7
- end
8
-
9
- ActiveFedora::WithMetadata::DefaultMetadataClassFactory.file_metadata_schemas << AdditionalSchema
10
-
11
- class SampleFile < ActiveFedora::File
12
- include ActiveFedora::WithMetadata
13
-
14
- metadata do
15
- property :title, predicate: ::RDF::Vocab::DC.title
16
- end
17
- end
18
- end
19
-
20
- after do
21
- Object.send(:remove_const, :SampleFile)
22
- Object.send(:remove_const, :AdditionalSchema)
23
- ActiveFedora::WithMetadata::DefaultMetadataClassFactory.file_metadata_schemas = [ActiveFedora::WithMetadata::DefaultSchema]
24
- end
25
-
26
- let(:file) { SampleFile.new }
27
-
28
- describe "properties" do
29
- before do
30
- file.title = ['one', 'two']
31
- end
32
- it "sets and retrieve properties" do
33
- expect(file.title).to contain_exactly 'one', 'two'
34
- end
35
-
36
- it "tracks changes" do
37
- expect(file.title_changed?).to be true
38
- end
39
-
40
- context "with defaults" do
41
- subject { file }
42
- it { is_expected.to respond_to(:label) }
43
- it { is_expected.to respond_to(:file_name) }
44
- it { is_expected.to respond_to(:file_size) }
45
- it { is_expected.to respond_to(:date_created) }
46
- it { is_expected.to respond_to(:mime_type) }
47
- it { is_expected.to respond_to(:date_modified) }
48
- it { is_expected.to respond_to(:byte_order) }
49
- it { is_expected.to respond_to(:file_hash) }
50
- end
51
- end
52
-
53
- describe "#save" do
54
- before do
55
- file.title = ["foo"]
56
- end
57
-
58
- context "if the object saves (because it has content)" do
59
- before do
60
- file.content = "Hey"
61
- file.save
62
- end
63
-
64
- let(:reloaded) { SampleFile.new(file.uri) }
65
-
66
- it "saves the metadata too" do
67
- expect(reloaded.title).to eq ['foo']
68
- end
69
- end
70
-
71
- context "if the object is a new_record (didn't save)" do
72
- it "doesn't save the metadata" do
73
- expect(file.metadata_node).not_to receive(:save)
74
- file.save
75
- end
76
- end
77
- end
78
-
79
- context "when RDF.type is set" do
80
- let(:book) { RDF::URI.new("http://example.com/ns/Book") }
81
-
82
- before do
83
- class SampleBook < ActiveFedora::File
84
- include ActiveFedora::WithMetadata
85
-
86
- metadata do
87
- configure type: RDF::URI.new("http://example.com/ns/Book")
88
- end
89
- end
90
-
91
- file.content = 'foo'
92
- file.save
93
- end
94
-
95
- after do
96
- Object.send(:remove_const, :SampleBook)
97
- end
98
-
99
- let(:file) { SampleBook.new }
100
- let(:reloaded_file) { SampleBook.new(file.uri) }
101
-
102
- it "persists the configured type" do
103
- expect(reloaded_file.metadata_node.query(predicate: ::RDF.type).map(&:object)).to include book
104
- end
105
- end
106
-
107
- context "when using additional schema" do
108
- subject { SampleFile.new }
109
- it { is_expected.to respond_to(:new_property) }
110
- end
111
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::NullLogger do
4
- [:debug?, :info?, :warn?, :error?, :fatal?].each do |method_name|
5
- describe "##{method_name}" do
6
- subject { described_class.new.public_send(method_name) }
7
- it { is_expected.to be_falsey }
8
- end
9
- end
10
- end
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails
@@ -1,5 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
5
-
@@ -1,106 +0,0 @@
1
- ENV["environment"] ||= "test"
2
-
3
- require "bundler/setup"
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
8
- [
9
- SimpleCov::Formatter::HTMLFormatter,
10
- Coveralls::SimpleCov::Formatter
11
- ]
12
- )
13
-
14
- SimpleCov.start "rails" do
15
- add_filter "/spec/"
16
- end
17
-
18
- require 'active-fedora'
19
- require 'rspec'
20
- require 'rspec/its'
21
- require 'equivalent-xml/rspec_matchers'
22
- require 'logger'
23
- require 'pry' unless ENV['CI']
24
-
25
- ActiveFedora::Base.logger = Logger.new(STDERR)
26
- ActiveFedora::Base.logger.level = Logger::WARN
27
-
28
- Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
29
-
30
- $VERBOSE = nil
31
-
32
- # This loads the Fedora and Solr config info from /config/fedora.yml
33
- # You can load it from a different location by passing a file path as an argument.
34
- def restore_spec_configuration
35
- ActiveFedora.init(fedora_config_path: File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
36
- end
37
- restore_spec_configuration
38
-
39
- require 'active_fedora/cleaner'
40
- RSpec.configure do |config|
41
- # Stub out test stuff.
42
- config.before(:each) do
43
- begin
44
- ActiveFedora::Cleaner.clean!
45
- rescue Faraday::ConnectionFailed, RSolr::Error::ConnectionRefused => e
46
- $stderr.puts e.message
47
- end
48
- end
49
-
50
- # rspec-expectations config goes here. You can use an alternate
51
- # assertion/expectation library such as wrong or the stdlib/minitest
52
- # assertions if you prefer.
53
- config.expect_with :rspec do |expectations|
54
- # This option will default to `true` in RSpec 4. It makes the `description`
55
- # and `failure_message` of custom matchers include text for helper methods
56
- # defined using `chain`, e.g.:
57
- # be_bigger_than(2).and_smaller_than(4).description
58
- # # => "be bigger than 2 and smaller than 4"
59
- # ...rather than:
60
- # # => "be bigger than 2"
61
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
62
- end
63
-
64
- config.default_formatter = 'doc' if config.files_to_run.one?
65
-
66
- config.shared_context_metadata_behavior = :apply_to_host_groups
67
-
68
- # This allows you to limit a spec run to individual examples or groups
69
- # you care about by tagging them with `:focus` metadata. When nothing
70
- # is tagged with `:focus`, all examples get run. RSpec also provides
71
- # aliases for `it`, `describe`, and `context` that include `:focus`
72
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
73
- config.filter_run_when_matching :focus
74
-
75
- config.example_status_persistence_file_path = 'spec/examples.txt'
76
- # Many RSpec users commonly either run the entire suite or an individual
77
- # file, and it's useful to allow more verbose output when running an
78
- # individual spec file.
79
- if config.files_to_run.one?
80
- # Use the documentation formatter for detailed output,
81
- # unless a formatter has already been configured
82
- # (e.g. via a command-line flag).
83
- config.default_formatter = 'doc'
84
- end
85
-
86
- # Print the 10 slowest examples and example groups at the
87
- # end of the spec run, to help surface which specs are running
88
- # particularly slow.
89
- config.profile_examples = 10
90
-
91
- # Run specs in random order to surface order dependencies. If you find an
92
- # order dependency and want to debug it, you can fix the order by providing
93
- # the seed, which is printed after each run.
94
- # --seed 1234
95
- config.order = :random
96
-
97
- # Seed global randomization in this process using the `--seed` CLI option.
98
- # Setting this allows you to use `--seed` to deterministically reproduce
99
- # test failures related to randomization by passing the same `--seed` value
100
- # as the one that triggered the failure.
101
- Kernel.srand config.seed
102
- end
103
-
104
- def fixture(file)
105
- File.open(File.join(File.dirname(__FILE__), 'fixtures', file), 'rb')
106
- end
@@ -1,29 +0,0 @@
1
- shared_examples_for "An ActiveModel" do
2
- def assert(test, *_args)
3
- expect(test).to be true
4
- end
5
-
6
- def assert_kind_of(klass, inspected_object)
7
- expect(inspected_object).to be_kind_of(klass)
8
- end
9
-
10
- def assert_equal(the_other, one)
11
- expect(one).to eq the_other
12
- end
13
-
14
- def assert_respond_to(obj, meth, _msg = nil)
15
- expect(obj).to respond_to meth
16
- end
17
-
18
- include ActiveModel::Lint::Tests
19
-
20
- ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |m|
21
- example m.tr('_', ' ') do
22
- send m
23
- end
24
- end
25
-
26
- def model
27
- subject
28
- end
29
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Indexing::Inserter do
4
- let(:solr_doc) { {} }
5
-
6
- it "handles many field types" do
7
- described_class.create_and_insert_terms('my_name', 'value', [:displayable, :searchable, :sortable], solr_doc)
8
- expect(solr_doc).to eq('my_name_ssm' => ['value'], 'my_name_si' => 'value', 'my_name_teim' => ['value'])
9
- end
10
-
11
- it "handles dates that are searchable" do
12
- described_class.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_searchable], solr_doc)
13
- expect(solr_doc).to eq('my_name_dtsim' => ['2013-01-10T00:00:00Z'])
14
- end
15
-
16
- it "handles dates that are stored_sortable" do
17
- described_class.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_sortable], solr_doc)
18
- expect(solr_doc).to eq('my_name_dtsi' => '2013-01-10T00:00:00Z')
19
- end
20
-
21
- it "handles dates that are displayable" do
22
- described_class.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:displayable], solr_doc)
23
- expect(solr_doc).to eq('my_name_ssm' => ['2013-01-10'])
24
- end
25
-
26
- it "handles dates that are sortable" do
27
- described_class.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:sortable], solr_doc)
28
- expect(solr_doc).to eq('my_name_dti' => '2013-01-10T00:00:00Z')
29
- end
30
-
31
- it "handles floating point integers" do
32
- described_class.create_and_insert_terms('my_number', (6.022140857*10**23).to_f, [:displayable, :searchable], solr_doc)
33
- expect(solr_doc).to eq('my_number_ssm' => ['6.0221408569999995e+23'], 'my_number_fim' => ['6.0221408569999995e+23'])
34
- end
35
- end
@@ -1,118 +0,0 @@
1
- require 'spec_helper'
2
- require 'config_helper'
3
-
4
- # For testing Module-level methods like ActiveFedora.init
5
-
6
- describe ActiveFedora do
7
- before do
8
- restore_spec_configuration
9
- end
10
-
11
- after :all do
12
- unstub_rails
13
- # Restore to default fedora configs
14
- restore_spec_configuration
15
- end
16
-
17
- describe "validate Fedora URL" do
18
- let(:good_url) { described_class.fedora_config.credentials[:url] }
19
- let(:bad_url) { good_url.gsub('/rest', '/') }
20
- let(:user) { described_class.fedora_config.credentials[:user] }
21
- let(:password) { described_class.fedora_config.credentials[:password] }
22
-
23
- it "connects OK" do
24
- expect(ActiveFedora::Base.logger).to_not receive(:warn)
25
- ActiveFedora::Fedora.new(url: good_url, base_path: '/test', user: user, password: password)
26
- end
27
-
28
- it "does not connect and warn" do
29
- expect(ActiveFedora::Base.logger).to receive(:warn)
30
- expect {
31
- ActiveFedora::Fedora.new(url: bad_url, base_path: '/test', user: user, password: password).connection.head
32
- }.to raise_error Ldp::HttpError
33
- end
34
- end
35
-
36
- describe "initialization methods" do
37
- describe "environment" do
38
- it "uses config_options[:environment] if set" do
39
- allow(described_class).to receive(:config_options).and_return(environment: "ballyhoo")
40
- expect(described_class.environment).to eql("ballyhoo")
41
- end
42
-
43
- it "uses Rails.env if no config_options and Rails.env is set" do
44
- stub_rails(env: "bedbugs")
45
- allow(described_class).to receive(:config_options).and_return({})
46
- expect(described_class.environment).to eql("bedbugs")
47
- unstub_rails
48
- end
49
-
50
- it "uses ENV['environment'] if neither config_options nor Rails.env are set" do
51
- ENV['environment'] = "wichita"
52
- allow(described_class).to receive(:config_options).and_return({})
53
- expect(described_class.environment).to eql("wichita")
54
- ENV['environment'] = 'test'
55
- end
56
-
57
- it "uses ENV['RAILS_ENV'] and log a warning if none of the above are set" do
58
- ENV['environment'] = nil
59
- ENV['RAILS_ENV'] = "rails_env"
60
- expect { described_class.environment }.to raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
61
- ENV['environment'] = 'test'
62
- end
63
-
64
- it "is development if none of the above are present" do
65
- ENV['environment'] = nil
66
- ENV['RAILS_ENV'] = nil
67
- allow(described_class).to receive(:config_options).and_return({})
68
- expect(described_class.environment).to eq 'development'
69
- ENV['environment'] = "test"
70
- end
71
- end
72
- end
73
-
74
- describe ".init" do
75
- after do
76
- # Restore to default fedora configs
77
- described_class.init(environment: "test", fedora_config_path: File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
78
- end
79
-
80
- describe "outside of rails" do
81
- it "loads the passed config if explicit config passed in as a string" do
82
- described_class.init(fedora_config_path: './spec/fixtures/rails_root/config/fedora.yml', environment: 'test')
83
- expect(described_class.config.credentials).to eq(url: "http://testhost.com:8983/fedora", user: 'fedoraAdmin', password: 'fedoraAdmin')
84
- end
85
- end
86
-
87
- describe "within rails" do
88
- after do
89
- unstub_rails
90
- end
91
-
92
- describe "versions prior to 3.0" do
93
- describe "with explicit config path passed in" do
94
- it "loads the specified config path" do
95
- fedora_config = "test:\n url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"
96
- solr_config = "test:\n default:\n url: http://foosolr:8983"
97
-
98
- fedora_config_path = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures/rails_root/config/fedora.yml"))
99
- solr_config_path = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures/rails_root/config/solr.yml"))
100
- allow(File).to receive(:open).with(fedora_config_path).and_return(fedora_config)
101
- allow(File).to receive(:open).with(solr_config_path).and_return(solr_config)
102
-
103
- described_class.init(fedora_config_path: fedora_config_path, solr_config_path: solr_config_path)
104
- expect(described_class.solr.class).to eq ActiveFedora::SolrService
105
- end
106
- end
107
-
108
- describe "with no explicit config path" do
109
- it "looks for the file in the path defined at Rails.root" do
110
- stub_rails(root: File.join(File.dirname(__FILE__), "../fixtures/rails_root"))
111
- described_class.init
112
- expect(described_class.config.credentials[:url]).to eq "http://testhost.com:8983/fedora"
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end
@@ -1,134 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Aggregation::ListSource do
4
- subject(:list_source) { described_class.new }
5
-
6
- describe "#head" do
7
- it "is nil by default" do
8
- expect(list_source.head).to eq nil
9
- end
10
-
11
- it "is settable" do
12
- list_source.head = RDF::URI("test.org")
13
-
14
- expect(list_source.head_id.first).to eq RDF::URI("test.org")
15
- end
16
-
17
- it "maps to IANA.first" do
18
- expect(list_source.class.properties["head"].predicate).to eq ::RDF::Vocab::IANA["first"]
19
- end
20
- end
21
-
22
- describe "#order_will_change!" do
23
- it "marks it as changed" do
24
- expect(list_source).not_to be_changed
25
- list_source.order_will_change!
26
- expect(list_source).to be_changed
27
- expect(list_source.ordered_self).to be_changed
28
- end
29
- end
30
-
31
- describe "#tail" do
32
- it "is nil by default" do
33
- expect(list_source.tail).to eq nil
34
- end
35
-
36
- it "is settable" do
37
- list_source.tail = RDF::URI("test.org")
38
-
39
- expect(list_source.tail_id.first).to eq RDF::URI("test.org")
40
- end
41
-
42
- it "maps to IANA.last" do
43
- expect(list_source.class.properties["tail"].predicate).to eq ::RDF::Vocab::IANA["last"]
44
- end
45
- end
46
-
47
- describe "#changed?" do
48
- context "when nothing has changed" do
49
- it "is false" do
50
- expect(list_source).not_to be_changed
51
- end
52
- end
53
- context "when the ordered list is changed" do
54
- it "is true" do
55
- allow(list_source.ordered_self).to receive(:changed?).and_return(true)
56
-
57
- expect(list_source).to be_changed
58
- end
59
- end
60
- context "when the ordered list is not changed" do
61
- it "is false" do
62
- allow(list_source.ordered_self).to receive(:changed?).and_return(false)
63
-
64
- expect(list_source).not_to be_changed
65
- end
66
- end
67
- end
68
-
69
- describe "#save" do
70
- context "when nothing has changed" do
71
- it "does not persist ordered_self" do
72
- allow(list_source.ordered_self).to receive(:to_graph)
73
-
74
- list_source.save
75
-
76
- expect(list_source.ordered_self).not_to have_received(:to_graph)
77
- end
78
- end
79
- context "when attributes have changed, but not ordered list" do
80
- it "does not persist ordered self" do
81
- allow(list_source.ordered_self).to receive(:to_graph)
82
- list_source.nodes += [RDF::URI("http://test.org")]
83
-
84
- list_source.save
85
-
86
- expect(list_source.ordered_self).not_to have_received(:to_graph)
87
- end
88
- end
89
- context "when ordered list has changed" do
90
- it "persists it" do
91
- allow(list_source.ordered_self).to receive(:to_graph).and_call_original
92
- allow(list_source.ordered_self).to receive(:changed?).and_return(true)
93
-
94
- list_source.save
95
-
96
- expect(list_source.ordered_self).to have_received(:to_graph)
97
- end
98
- end
99
- end
100
-
101
- describe "#serializable_hash" do
102
- it "does not serialize nodes" do
103
- list_source.nodes += [RDF::URI("http://test.org")]
104
-
105
- expect(list_source.serializable_hash).not_to have_key "nodes"
106
- end
107
- it "does not serialize head" do
108
- list_source.head = RDF::URI("http://test.org")
109
-
110
- expect(list_source.serializable_hash).not_to have_key "head"
111
- end
112
- it "does not serialize tail" do
113
- list_source.tail = RDF::URI("http://test.org")
114
-
115
- expect(list_source.serializable_hash).not_to have_key "tail"
116
- end
117
- end
118
-
119
- describe "#to_solr" do
120
- before do
121
- class Member < ActiveFedora::Base
122
- end
123
- end
124
- after do
125
- Object.send(:remove_const, :Member)
126
- end
127
- it "can index" do
128
- m = Member.create
129
- proxy_in = RDF::URI(ActiveFedora::Base.translate_id_to_uri.call("banana"))
130
- list_source.ordered_self.append_target m, proxy_in: proxy_in
131
- expect(list_source.to_solr).to include ordered_targets_ssim: [m.id], proxy_in_ssi: "banana"
132
- end
133
- end
134
- end