blacklight_oai_provider 6.0.0 → 7.0.2
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 +5 -5
- data/.github/workflows/ci.yml +37 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +53 -18
- data/.solr_wrapper +0 -1
- data/Gemfile +3 -0
- data/README.md +24 -3
- data/Rakefile +0 -2
- data/VERSION +1 -1
- data/blacklight_oai_provider.gemspec +8 -8
- data/lib/blacklight_oai_provider/solr_document_provider.rb +30 -10
- data/lib/blacklight_oai_provider/solr_document_wrapper.rb +60 -27
- data/lib/blacklight_oai_provider/solr_set.rb +6 -2
- data/lib/generators/blacklight_oai_provider/install_generator.rb +2 -2
- data/solr/conf/schema.xml +322 -563
- data/solr/sample_solr_documents.yml +724 -722
- data/spec/controllers/catalog_controller_spec.rb +2 -2
- data/spec/integration/blacklight_oai_provider/solr_document_wrapper_spec.rb +64 -0
- data/spec/lib/blacklight_oai_provider/solr_document_provider_spec.rb +65 -0
- data/spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb +206 -9
- data/spec/lib/blacklight_oai_provider/solr_set_spec.rb +7 -7
- data/spec/requests/identify_spec.rb +1 -1
- data/spec/requests/list_identifiers_spec.rb +4 -4
- data/spec/requests/list_records_spec.rb +4 -4
- data/spec/requests/list_sets_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -11
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +29 -20
- metadata +40 -43
- data/.travis.yml +0 -18
@@ -19,7 +19,7 @@ describe CatalogController do
|
|
19
19
|
it 'returns correct provider configuration' do
|
20
20
|
expect(controller.oai_config).to include(
|
21
21
|
provider: {
|
22
|
-
repository_name: "
|
22
|
+
repository_name: "Catalog Repository",
|
23
23
|
repository_url: "http://localhost/catalog/oai",
|
24
24
|
record_prefix: "oai:test",
|
25
25
|
admin_email: "root@localhost",
|
@@ -29,7 +29,7 @@ describe CatalogController do
|
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
|
-
it 'return
|
32
|
+
it 'return correct document configuration' do
|
33
33
|
expect(controller.oai_config[:document][:limit]).to be 25
|
34
34
|
end
|
35
35
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
|
4
|
+
subject(:wrapper) { described_class.new(controller, options) }
|
5
|
+
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:controller_class) { CatalogController }
|
8
|
+
let(:controller) { controller_class.new }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(controller).to receive(:params).and_return({})
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#earliest' do
|
15
|
+
it 'returns the earliest timestamp of all the records' do
|
16
|
+
expect(wrapper.earliest).to eq Time.parse('2014-02-03 18:42:53.056000000 +0000').utc
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#latest' do
|
21
|
+
it 'returns the latest timestamp of all the records' do
|
22
|
+
expect(wrapper.latest).to eq Time.parse('2015-02-03 18:42:53.056000000 +0000').utc
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#find' do
|
27
|
+
context 'when selector is :all' do
|
28
|
+
it 'returns a limited list of all records' do
|
29
|
+
expect(wrapper.find(:all)).to be_a OAI::Provider::PartialResult
|
30
|
+
expect(wrapper.find(:all).records.size).to be 15
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when selector is an individual record' do
|
35
|
+
let(:search_builder_class) do
|
36
|
+
Class.new(Blacklight::SearchBuilder) do
|
37
|
+
include Blacklight::Solr::SearchBuilderBehavior
|
38
|
+
self.default_processor_chain += [:only_visible]
|
39
|
+
|
40
|
+
def only_visible(solr_parameters)
|
41
|
+
solr_parameters[:fq] ||= []
|
42
|
+
solr_parameters[:fq] << 'visibility_si:"open"'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
let(:controller_class) do
|
47
|
+
stub_const 'VisibilitySearchBuilder', search_builder_class
|
48
|
+
Class.new(CatalogController) do
|
49
|
+
blacklight_config.configure do |config|
|
50
|
+
config.search_builder_class = VisibilitySearchBuilder
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns nothing for a restricted work' do
|
56
|
+
expect(wrapper.find('2007020969')).to be_nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns a single record for a public work' do
|
60
|
+
expect(wrapper.find('2005553155')).to be_a SolrDocument
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe BlacklightOaiProvider::SolrDocumentProvider do
|
4
|
+
subject(:provider) { described_class.new(controller, options) }
|
5
|
+
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:controller) { CatalogController.new }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
let(:view_context) { instance_double("ViewContext") }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(controller).to receive(:view_context).and_return(view_context)
|
14
|
+
allow(view_context).to receive(:oai_catalog_url).and_return(:some_path)
|
15
|
+
allow(view_context).to receive(:application_name).and_return(:some_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with no options provided' do
|
19
|
+
it 'sets the default repository name and url' do
|
20
|
+
expect(provider.url).to eq :some_path
|
21
|
+
expect(provider.name).to eq :some_name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with options provided' do
|
26
|
+
let(:options) { { provider: { repository_url: '/my/custom/path', repository_name: 'My Custom Name' } } }
|
27
|
+
|
28
|
+
it 'uses the repository name and url set into the options' do
|
29
|
+
expect(provider.url).to eq '/my/custom/path'
|
30
|
+
expect(provider.name).to eq 'My Custom Name'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with Procs provided as option values' do
|
35
|
+
let(:alternate_controller) { AlternateController.new }
|
36
|
+
let(:alternate_provider) { described_class.new(alternate_controller, options) }
|
37
|
+
let(:alternate_view_context) { instance_double("ViewContext") }
|
38
|
+
let(:options) do
|
39
|
+
{
|
40
|
+
provider: {
|
41
|
+
repository_name: ->(kontroller) { "Hello #{kontroller.controller_name.titleize}" },
|
42
|
+
repository_url: ->(kontroller) { "Hello #{kontroller.view_context.send "oai_#{kontroller.controller_name}_url"}" }
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
before do
|
48
|
+
allow(alternate_controller).to receive(:view_context).and_return(alternate_view_context)
|
49
|
+
allow(alternate_view_context).to receive(:oai_alternate_url).and_return(:another_path)
|
50
|
+
allow(alternate_view_context).to receive(:application_name).and_return(:another_name)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'call()-s the Proc to set the option value' do
|
54
|
+
expect(provider.name).to eq "Hello Catalog"
|
55
|
+
expect(provider.url).to eq "Hello #{controller.view_context.oai_catalog_url}"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'does not pollute controller configurations from procs' do
|
59
|
+
provider.name
|
60
|
+
expect(alternate_provider.name).to eq "Hello Alternate"
|
61
|
+
expect(provider.name).to eq "Hello Catalog"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -4,10 +4,12 @@ RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
|
|
4
4
|
subject(:wrapper) { described_class.new(controller, options) }
|
5
5
|
|
6
6
|
let(:options) { {} }
|
7
|
-
let(:
|
7
|
+
let(:controller_class) { CatalogController }
|
8
|
+
let(:controller) { instance_double(CatalogController) }
|
9
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
8
10
|
|
9
11
|
before do
|
10
|
-
allow(controller).to
|
12
|
+
allow(controller).to receive_messages(params: {}, blacklight_config: blacklight_config)
|
11
13
|
end
|
12
14
|
|
13
15
|
describe '#initialize' do
|
@@ -30,29 +32,224 @@ RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
shared_context "timestamp_searches" do
|
36
|
+
let(:expected_timestamp) { '2014-02-03 18:42:53.056000000 +0000' }
|
37
|
+
let(:repository) { instance_double(Blacklight::Solr::Repository) }
|
38
|
+
let(:search_builder) { instance_double(Blacklight::SearchBuilder) }
|
39
|
+
let(:search_service) { instance_double(Blacklight::SearchService) }
|
40
|
+
let(:documents) { [SolrDocument.new('timestamp' => expected_timestamp)] }
|
41
|
+
let(:response) { OpenStruct.new(documents: documents, total: documents.length) }
|
42
|
+
|
43
|
+
before do
|
44
|
+
allow(controller).to receive(:search_service).and_return(search_service)
|
45
|
+
allow(search_service).to receive_messages(repository: repository, search_builder: search_builder)
|
46
|
+
allow(repository).to receive(:search).with(search_builder).and_return(response)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
33
50
|
describe '#earliest' do
|
51
|
+
include_context "timestamp_searches"
|
52
|
+
|
53
|
+
before do
|
54
|
+
allow(search_builder).to receive(:merge).with(hash_including(sort: "timestamp asc")).and_return(search_builder)
|
55
|
+
end
|
56
|
+
|
34
57
|
it 'returns the earliest timestamp of all the records' do
|
35
|
-
expect(wrapper.earliest).to eq Time.parse(
|
58
|
+
expect(wrapper.earliest).to eq Time.parse(expected_timestamp).utc
|
59
|
+
end
|
60
|
+
|
61
|
+
context "no documents are returned" do
|
62
|
+
let(:documents) { [] }
|
63
|
+
|
64
|
+
it 'returns a default timestamp' do
|
65
|
+
expect(Time.parse(wrapper.earliest).utc).to be_a Time
|
66
|
+
end
|
36
67
|
end
|
37
68
|
end
|
38
69
|
|
39
70
|
describe '#latest' do
|
71
|
+
include_context "timestamp_searches"
|
72
|
+
|
73
|
+
before do
|
74
|
+
allow(search_builder).to receive(:merge).with(hash_including(sort: "timestamp desc")).and_return(search_builder)
|
75
|
+
end
|
76
|
+
|
40
77
|
it 'returns the latest timestamp of all the records' do
|
41
|
-
expect(wrapper.latest).to eq Time.parse(
|
78
|
+
expect(wrapper.latest).to eq Time.parse(expected_timestamp).utc
|
79
|
+
end
|
80
|
+
|
81
|
+
context "no documents are returned" do
|
82
|
+
let(:documents) { [] }
|
83
|
+
|
84
|
+
it 'returns a default timestamp' do
|
85
|
+
expect(Time.parse(wrapper.latest).utc).to be_a Time
|
86
|
+
end
|
42
87
|
end
|
43
88
|
end
|
44
89
|
|
45
90
|
describe '#find' do
|
91
|
+
include_context "timestamp_searches"
|
92
|
+
|
93
|
+
subject(:result) { wrapper.find(selector) }
|
94
|
+
|
46
95
|
context 'when selector is :all' do
|
96
|
+
let(:selector) { :all }
|
97
|
+
let(:query) { {} }
|
98
|
+
let(:limit) { 1 }
|
99
|
+
let(:options) { { limit: limit } }
|
100
|
+
let(:response) { OpenStruct.new(documents: documents, total: limit + 1) }
|
101
|
+
let(:next_response) { OpenStruct.new(documents: documents, total: documents.length) }
|
102
|
+
|
103
|
+
before do
|
104
|
+
allow(search_builder).to receive_messages(merge: search_builder, query: query)
|
105
|
+
allow(repository).to receive(:search).with(query).and_return(response)
|
106
|
+
allow(repository).to receive(:search).with(hash_including(start: 0)).and_return(next_response)
|
107
|
+
end
|
108
|
+
|
47
109
|
it 'returns a limited list of all records' do
|
48
|
-
expect(
|
49
|
-
expect(
|
110
|
+
expect(result).to be_a OAI::Provider::PartialResult
|
111
|
+
expect(result.records.size).to be limit
|
50
112
|
end
|
51
113
|
end
|
52
114
|
|
53
|
-
context 'when selector is an
|
54
|
-
|
55
|
-
|
115
|
+
context 'when selector is an id value' do
|
116
|
+
let(:selector) { '2007020969' }
|
117
|
+
let(:query) { {} }
|
118
|
+
|
119
|
+
before do
|
120
|
+
allow(search_builder).to receive(:query).and_return(query)
|
121
|
+
allow(repository).to receive(:search).with(query).and_return(response)
|
122
|
+
allow(search_builder).to receive(:where).with(id: selector).and_return(search_builder)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'searches by id' do
|
126
|
+
expect(result).to be_a(SolrDocument)
|
127
|
+
expect(search_builder).to have_received(:where).with(id: selector)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#conditions' do
|
133
|
+
include_context "timestamp_searches"
|
134
|
+
|
135
|
+
subject(:result) { wrapper.conditions(constraints) }
|
136
|
+
|
137
|
+
let(:search_builder_class) do
|
138
|
+
Class.new(Blacklight::SearchBuilder) do
|
139
|
+
include Blacklight::Solr::SearchBuilderBehavior
|
140
|
+
end
|
141
|
+
end
|
142
|
+
let(:search_builder) { search_builder_class.new(controller) }
|
143
|
+
|
144
|
+
context 'time options' do
|
145
|
+
let(:constraints) { { from: Time.utc(2015, 1, 1), until: Time.utc(2015, 1, 2) } }
|
146
|
+
|
147
|
+
it 'sets options when from' do
|
148
|
+
constraints.delete(:until)
|
149
|
+
expect(result).to include(
|
150
|
+
"fq" => ["timestamp:[2015-01-01T00:00:00Z TO *]"],
|
151
|
+
"sort" => "timestamp asc"
|
152
|
+
)
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'sets options when until' do
|
156
|
+
constraints.delete(:from)
|
157
|
+
expect(result).to include(
|
158
|
+
"fq" => ["timestamp:[* TO 2015-01-02T00:00:00.999Z]"],
|
159
|
+
"sort" => "timestamp asc"
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'sets options when range' do
|
164
|
+
expect(result).to include(
|
165
|
+
"fq" => ["timestamp:[2015-01-01T00:00:00Z TO 2015-01-02T00:00:00.999Z]"],
|
166
|
+
"sort" => "timestamp asc"
|
167
|
+
)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'date options' do
|
172
|
+
let(:constraints) { { from: Date.parse('2015-01-01'), until: Date.parse('2015-01-02') } }
|
173
|
+
|
174
|
+
it 'sets options for high granularity' do
|
175
|
+
expect(result).to include(
|
176
|
+
"fq" => ["timestamp:[2015-01-01T00:00:00Z TO 2015-01-02T23:59:59.999Z]"],
|
177
|
+
"sort" => "timestamp asc"
|
178
|
+
)
|
179
|
+
end
|
180
|
+
# rubocop:disable RSpec/NestedGroups
|
181
|
+
context 'low granularity' do
|
182
|
+
let(:options) { { granularity: OAI::Const::Granularity::LOW } }
|
183
|
+
|
184
|
+
it 'sets options' do
|
185
|
+
expect(wrapper.granularity).to eql(OAI::Const::Granularity::LOW)
|
186
|
+
expect(result).to include(
|
187
|
+
"fq" => ["timestamp:[2015-01-01 TO 2015-01-02]"],
|
188
|
+
"sort" => "timestamp asc"
|
189
|
+
)
|
190
|
+
end
|
191
|
+
context 'same value for endpoints' do
|
192
|
+
let(:constraints) { { from: Date.parse('2015-01-01'), until: Date.parse('2015-01-01') } }
|
193
|
+
|
194
|
+
it 'sets options' do
|
195
|
+
expect(wrapper.granularity).to eql(OAI::Const::Granularity::LOW)
|
196
|
+
expect(result).to include(
|
197
|
+
"fq" => ["timestamp:\"2015-01-01\""],
|
198
|
+
"sort" => "timestamp asc"
|
199
|
+
)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
# rubocop:enable RSpec/NestedGroups
|
204
|
+
end
|
205
|
+
|
206
|
+
context 'string date options' do
|
207
|
+
let(:constraints) { { from: '2015-01-01', until: '2015-01-02' } }
|
208
|
+
|
209
|
+
it 'sets options when from' do
|
210
|
+
constraints.delete(:until)
|
211
|
+
expect(result).to include(
|
212
|
+
"fq" => ["timestamp:[2015-01-01 TO *]"],
|
213
|
+
"sort" => "timestamp asc"
|
214
|
+
)
|
215
|
+
end
|
216
|
+
it 'sets options when until' do
|
217
|
+
constraints.delete(:from)
|
218
|
+
expect(result).to include(
|
219
|
+
"fq" => ["timestamp:[* TO 2015-01-02]"],
|
220
|
+
"sort" => "timestamp asc"
|
221
|
+
)
|
222
|
+
end
|
223
|
+
it 'sets options when range' do
|
224
|
+
expect(result).to include(
|
225
|
+
"fq" => ["timestamp:[2015-01-01 TO 2015-01-02]"],
|
226
|
+
"sort" => "timestamp asc"
|
227
|
+
)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context 'string time options' do
|
232
|
+
let(:constraints) { { from: '2015-01-01T00:00:00.000Z', until: '2015-01-02T00:00:00.000Z' } }
|
233
|
+
|
234
|
+
it 'sets options when from' do
|
235
|
+
constraints.delete(:until)
|
236
|
+
expect(result).to include(
|
237
|
+
"fq" => ["timestamp:[2015-01-01T00:00:00.000Z TO *]"],
|
238
|
+
"sort" => "timestamp asc"
|
239
|
+
)
|
240
|
+
end
|
241
|
+
it 'sets options when until' do
|
242
|
+
constraints.delete(:from)
|
243
|
+
expect(result).to include(
|
244
|
+
"fq" => ["timestamp:[* TO 2015-01-02T00:00:00.000Z]"],
|
245
|
+
"sort" => "timestamp asc"
|
246
|
+
)
|
247
|
+
end
|
248
|
+
it 'sets options when range' do
|
249
|
+
expect(result).to include(
|
250
|
+
"fq" => ["timestamp:[2015-01-01T00:00:00.000Z TO 2015-01-02T00:00:00.000Z]"],
|
251
|
+
"sort" => "timestamp asc"
|
252
|
+
)
|
56
253
|
end
|
57
254
|
end
|
58
255
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe BlacklightOaiProvider::SolrSet do
|
4
4
|
let(:controller) { CatalogController.new }
|
5
5
|
let(:fields) do
|
6
|
-
[{ label: 'language', solr_field: '
|
6
|
+
[{ label: 'language', solr_field: 'language_ssim' }]
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
@@ -23,7 +23,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
23
23
|
context 'with multiple fields' do
|
24
24
|
let(:fields) do
|
25
25
|
[
|
26
|
-
{ label: 'language', solr_field: '
|
26
|
+
{ label: 'language', solr_field: 'language_ssim' },
|
27
27
|
{ solr_field: 'format' }
|
28
28
|
]
|
29
29
|
end
|
@@ -35,7 +35,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
35
35
|
|
36
36
|
context 'for a field with no values' do
|
37
37
|
let(:fields) do
|
38
|
-
[{ label: 'author', solr_field: '
|
38
|
+
[{ label: 'author', solr_field: 'author_ts' }]
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns nil' do
|
@@ -45,12 +45,12 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
45
45
|
|
46
46
|
context 'for a field with facet config limit' do
|
47
47
|
let(:fields) do
|
48
|
-
[{ label: 'lc_alpha', solr_field: '
|
48
|
+
[{ label: 'lc_alpha', solr_field: 'lc_alpha_ssim' }]
|
49
49
|
end
|
50
50
|
|
51
51
|
before do
|
52
52
|
CatalogController.configure_blacklight do |config|
|
53
|
-
config.add_facet_field '
|
53
|
+
config.add_facet_field 'lc_alpha_ssim', label: 'lc_alpha', limit: 2
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -65,7 +65,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
65
65
|
let(:spec) { 'language:Hebrew' }
|
66
66
|
|
67
67
|
it 'returns the filter query' do
|
68
|
-
expect(described_class.from_spec(spec)).to eq '
|
68
|
+
expect(described_class.from_spec(spec)).to eq 'language_ssim:"Hebrew"'
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -94,7 +94,7 @@ RSpec.describe BlacklightOaiProvider::SolrSet do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'gets solr field' do
|
97
|
-
expect(set.solr_field).to eql '
|
97
|
+
expect(set.solr_field).to eql 'language_ssim'
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -12,7 +12,7 @@ describe 'OIA-PMH Identify Request' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "contains repository name" do
|
15
|
-
expect(xml.at_xpath('//xmlns:repositoryName').text).to eql '
|
15
|
+
expect(xml.at_xpath('//xmlns:repositoryName').text).to eql 'Catalog Repository'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "contains base url" do
|
@@ -18,7 +18,7 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'contains resumptionToken' do
|
21
|
-
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(
|
21
|
+
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(2015-02-03T18:42:53Z).t(30):25'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,8 +27,8 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
27
27
|
get '/catalog/oai?verb=ListIdentifiers&resumptionToken=oai_dc.f(2014-02-03T18:42:53Z).u(2014-03-03T18:42:53Z).t(30):25'
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'returns
|
31
|
-
expect(xml.xpath('//xmlns:ListIdentifiers/xmlns:header').count).to be
|
30
|
+
it 'returns 4 records' do
|
31
|
+
expect(xml.xpath('//xmlns:ListIdentifiers/xmlns:header').count).to be 4
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'first record has identifier and timestamp' do
|
@@ -57,7 +57,7 @@ describe 'OIA-PMH ListIdentifiers Request' do
|
|
57
57
|
|
58
58
|
context 'with different timestamp_field' do
|
59
59
|
before :all do
|
60
|
-
SolrDocument.timestamp_key = "
|
60
|
+
SolrDocument.timestamp_key = "record_creation_dtsi"
|
61
61
|
end
|
62
62
|
|
63
63
|
before do
|
@@ -24,7 +24,7 @@ describe 'OIA-PMH ListRecords Request' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'contains resumptionToken' do
|
27
|
-
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(
|
27
|
+
expect(xml.at_xpath('//xmlns:resumptionToken').text).to eql 'oai_dc.f(2014-02-03T18:42:53Z).u(2015-02-03T18:42:53Z).t(30):25'
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'for record' do
|
@@ -73,8 +73,8 @@ describe 'OIA-PMH ListRecords Request' do
|
|
73
73
|
get '/catalog/oai?verb=ListRecords&resumptionToken=oai_dc.f(2014-02-03T18:42:53Z).u(2014-02-03T18:42:53Z).t(29):25'
|
74
74
|
end
|
75
75
|
|
76
|
-
it 'returns
|
77
|
-
expect(xml.xpath('//xmlns:ListRecords/xmlns:record/xmlns:header').count).to be
|
76
|
+
it 'returns 3 records' do
|
77
|
+
expect(xml.xpath('//xmlns:ListRecords/xmlns:record/xmlns:header').count).to be 3
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'first record has oai_dc metadata element' do
|
@@ -119,7 +119,7 @@ describe 'OIA-PMH ListRecords Request' do
|
|
119
119
|
|
120
120
|
context 'throws noRecordsMatch error' do
|
121
121
|
before do
|
122
|
-
get '/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc&from=
|
122
|
+
get '/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc&from=2016-01-01'
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'returns no records error' do
|
data/spec/spec_helper.rb
CHANGED
@@ -6,18 +6,9 @@ EngineCart.load_application!
|
|
6
6
|
require 'rspec/rails'
|
7
7
|
require 'capybara/rspec'
|
8
8
|
require 'selenium-webdriver'
|
9
|
+
require 'webdrivers'
|
9
10
|
|
10
|
-
Capybara.javascript_driver = :
|
11
|
-
|
12
|
-
Capybara.register_driver :headless_chrome do |app|
|
13
|
-
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
14
|
-
chromeOptions: { args: %w[headless disable-gpu] }
|
15
|
-
)
|
16
|
-
|
17
|
-
Capybara::Selenium::Driver.new(app,
|
18
|
-
browser: :chrome,
|
19
|
-
desired_capabilities: capabilities)
|
20
|
-
end
|
11
|
+
Capybara.javascript_driver = :selenium_chrome_headless
|
21
12
|
|
22
13
|
RSpec.configure do |config|
|
23
14
|
config.infer_spec_type_from_file_location!
|
@@ -11,6 +11,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
11
11
|
say_status("warning", "GENERATING BL", :yellow)
|
12
12
|
|
13
13
|
generate 'blacklight:install', '--devise'
|
14
|
+
generate 'blacklight:test_support'
|
14
15
|
end
|
15
16
|
|
16
17
|
def change_migrations_if_rails_4_2
|
@@ -51,14 +52,35 @@ class TestAppGenerator < Rails::Generators::Base
|
|
51
52
|
generate 'blacklight_oai_provider:install'
|
52
53
|
end
|
53
54
|
|
54
|
-
def
|
55
|
+
def add_test_blacklight_oai_controller_config
|
56
|
+
%w[catalog alternate].each { |cn| add_test_config_for(cn) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_test_blacklight_oai_model_config
|
60
|
+
insert_into_file "app/models/solr_document.rb", after: "include BlacklightOaiProvider::SolrDocument\n" do
|
61
|
+
<<-CONFIG
|
62
|
+
field_semantics.merge!(
|
63
|
+
title: "title_tsim",
|
64
|
+
date: "pub_date_ssim",
|
65
|
+
subject: "subject_ssim",
|
66
|
+
creator: "author_tsim",
|
67
|
+
format: "format",
|
68
|
+
language: "language_ssim",
|
69
|
+
)
|
70
|
+
CONFIG
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def add_test_config_for(controller_basename)
|
55
77
|
say_status("warning", "ADDING BL OIA-PMH CONFIG")
|
56
78
|
|
57
|
-
insert_into_file "app/controllers
|
79
|
+
insert_into_file "app/controllers/#{controller_basename}_controller.rb", after: "config.default_solr_params = {" do
|
58
80
|
"\n fl: '*',\n"
|
59
81
|
end
|
60
82
|
|
61
|
-
insert_into_file "app/controllers
|
83
|
+
insert_into_file "app/controllers/#{controller_basename}_controller.rb", after: " configure_blacklight do |config|\n" do
|
62
84
|
<<-CONFIG
|
63
85
|
config.default_document_solr_params = {
|
64
86
|
qt: 'search',
|
@@ -69,12 +91,12 @@ class TestAppGenerator < Rails::Generators::Base
|
|
69
91
|
CONFIG
|
70
92
|
end
|
71
93
|
|
72
|
-
insert_into_file "app/controllers
|
94
|
+
insert_into_file "app/controllers/#{controller_basename}_controller.rb", after: "configure_blacklight do |config|\n" do
|
73
95
|
<<-CONFIG
|
74
96
|
config.oai = {
|
75
97
|
provider: {
|
76
|
-
repository_name: '
|
77
|
-
repository_url: 'http://localhost/
|
98
|
+
repository_name: '#{controller_basename.titleize} Repository',
|
99
|
+
repository_url: 'http://localhost/#{controller_basename}/oai',
|
78
100
|
record_prefix: 'oai:test',
|
79
101
|
admin_email: 'root@localhost',
|
80
102
|
deletion_support: 'persistent',
|
@@ -82,25 +104,12 @@ class TestAppGenerator < Rails::Generators::Base
|
|
82
104
|
},
|
83
105
|
document: {
|
84
106
|
set_fields: [
|
85
|
-
{ label: 'language', solr_field: '
|
107
|
+
{ label: 'language', solr_field: 'language_ssim' }
|
86
108
|
],
|
87
109
|
limit: 25
|
88
110
|
}
|
89
111
|
}
|
90
112
|
CONFIG
|
91
113
|
end
|
92
|
-
|
93
|
-
insert_into_file "app/models/solr_document.rb", after: "include BlacklightOaiProvider::SolrDocument\n" do
|
94
|
-
<<-CONFIG
|
95
|
-
field_semantics.merge!(
|
96
|
-
title: "title_display",
|
97
|
-
creator: "author_display",
|
98
|
-
date: "pub_date",
|
99
|
-
subject: "subject_topic_facet",
|
100
|
-
format: "format",
|
101
|
-
language: "language_facet"
|
102
|
-
)
|
103
|
-
CONFIG
|
104
|
-
end
|
105
114
|
end
|
106
115
|
end
|