|
89 | 89 | before do
|
90 | 90 | raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class
|
91 | 91 | raise 'resource must be set with `let(:resource)` and is expected to be a kind of Hyrax::Resource' unless defined?(resource) && resource.kind_of?(Hyrax::Resource)
|
92 |
| - # optionally can pass in default_visibility by setting it with a let statement if your application changes the default; Hyrax defines this as 'restricted' |
93 |
| - # See samvera/hyrda-head hydra-access-controls/app/models/concerns/hydra/access_controls/access_rights.rb for possible VISIBILITY_TEXT_VALUE_...' |
94 | 92 | end
|
95 | 93 | subject(:indexer) { indexer_class.new(resource: resource) }
|
96 | 94 | let(:thumbnail_path) { '/downloads/foo12345?file=thumbnail' }
|
|
106 | 104 | end
|
107 | 105 | end
|
108 | 106 |
|
| 107 | +RSpec.shared_examples 'a location indexer' do |
| 108 | + before do |
| 109 | + raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class |
| 110 | + raise 'resource must be set with `let(:resource)` and is expected to be a kind of Hyrax::Resource' unless defined?(resource) && resource.kind_of?(Hyrax::Resource) |
| 111 | + resource.based_near = based_near |
| 112 | + end |
| 113 | + subject(:indexer) { indexer_class.new(resource: resource) } |
| 114 | + let(:based_near) { ["https://sws.geonames.org/4254679/"] } |
| 115 | + let(:based_near_label) { ["Bloomington, Indiana, United States"] } |
| 116 | + |
| 117 | + before do |
| 118 | + allow(Hyrax.config.location_service).to receive(:full_label).with(based_near[0]).and_return(based_near_label[0]) |
| 119 | + end |
| 120 | + |
| 121 | + describe '#to_solr' do |
| 122 | + it 'indexes locations' do |
| 123 | + expect(indexer.to_solr).to include(based_near_tesim: based_near, based_near_label_tesim: based_near_label) |
| 124 | + end |
| 125 | + end |
| 126 | +end |
| 127 | + |
109 | 128 | RSpec.shared_examples 'a Core metadata indexer' do
|
110 | 129 | before do
|
111 | 130 | raise 'indexer_class must be set with `let(:indexer_class)`' unless defined? indexer_class
|
|
138 | 157 | end
|
139 | 158 | subject(:indexer) { indexer_class.new(resource: resource) }
|
140 | 159 |
|
| 160 | + it_behaves_like 'a location indexer' |
| 161 | + |
141 | 162 | let(:attributes) do
|
142 | 163 | {
|
143 |
| - based_near: ['helsinki', 'finland'], |
144 | 164 | date_created: ['tuesday'],
|
145 | 165 | keyword: ['comic strip'],
|
146 | 166 | related_url: ['http://example.com/moomin'],
|
|
152 | 172 | describe '#to_solr' do
|
153 | 173 | it 'indexes basic metadata' do
|
154 | 174 | expect(indexer.to_solr)
|
155 |
| - .to include(based_near_tesim: a_collection_containing_exactly(*attributes[:based_near]), |
156 |
| - based_near_sim: a_collection_containing_exactly(*attributes[:based_near]), |
157 |
| - date_created_tesim: a_collection_containing_exactly(*attributes[:date_created]), |
| 175 | + .to include(date_created_tesim: a_collection_containing_exactly(*attributes[:date_created]), |
158 | 176 | keyword_sim: a_collection_containing_exactly(*attributes[:keyword]),
|
159 | 177 | related_url_tesim: a_collection_containing_exactly(*attributes[:related_url]),
|
160 | 178 | resource_type_tesim: a_collection_containing_exactly(*attributes[:resource_type]),
|
|
0 commit comments