blacklight 6.18.0 → 6.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop_todo.yml +1 -1
  3. data/.travis.yml +5 -0
  4. data/Gemfile +1 -0
  5. data/VERSION +1 -1
  6. data/app/controllers/concerns/blacklight/bookmarks.rb +17 -3
  7. data/app/controllers/concerns/blacklight/catalog.rb +4 -2
  8. data/app/controllers/concerns/blacklight/controller.rb +10 -7
  9. data/app/controllers/concerns/blacklight/search_context.rb +5 -3
  10. data/app/controllers/concerns/blacklight/token_based_user.rb +3 -1
  11. data/app/models/blacklight/suggest_search.rb +3 -14
  12. data/app/models/concerns/blacklight/document.rb +3 -1
  13. data/app/models/concerns/blacklight/suggest/response.rb +5 -3
  14. data/app/presenters/blacklight/index_presenter.rb +3 -3
  15. data/blacklight.gemspec +5 -4
  16. data/lib/blacklight.rb +4 -4
  17. data/lib/blacklight/abstract_repository.rb +13 -1
  18. data/lib/blacklight/configuration.rb +2 -1
  19. data/lib/blacklight/configuration/fields.rb +46 -41
  20. data/lib/blacklight/engine.rb +2 -1
  21. data/lib/blacklight/solr/repository.rb +36 -3
  22. data/lib/generators/blacklight/assets_generator.rb +7 -2
  23. data/lib/generators/blacklight/install_generator.rb +1 -1
  24. data/lib/generators/blacklight/templates/catalog_controller.rb +3 -0
  25. data/lib/railties/blacklight.rake +11 -16
  26. data/spec/controllers/bookmarks_controller_spec.rb +35 -0
  27. data/spec/models/blacklight/configuration_spec.rb +81 -79
  28. data/spec/models/blacklight/solr/repository_spec.rb +11 -4
  29. data/spec/models/blacklight/suggest/response_spec.rb +5 -4
  30. data/spec/models/blacklight/suggest_search_spec.rb +6 -13
  31. data/spec/presenters/index_presenter_spec.rb +9 -0
  32. data/spec/spec_helper.rb +10 -6
  33. data/tasks/blacklight.rake +4 -4
  34. metadata +36 -16
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Blacklight::Solr::Repository do
3
+ RSpec.describe Blacklight::Solr::Repository, api: true do
4
+ subject(:repository) do
5
+ described_class.new blacklight_config
6
+ end
4
7
 
5
8
  let :blacklight_config do
6
9
  CatalogController.blacklight_config.deep_copy
@@ -42,7 +45,7 @@ describe Blacklight::Solr::Repository do
42
45
  allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { id: '123', qt: 'abc'})).and_return(mock_response)
43
46
  expect(subject.find("123", {qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
44
47
  end
45
-
48
+
46
49
  it "should use the :qt parameter from the default_document_solr_params" do
47
50
  blacklight_config.default_document_solr_params[:qt] = 'abc'
48
51
  blacklight_config.document_solr_request_handler = 'xyz'
@@ -82,12 +85,12 @@ describe Blacklight::Solr::Repository do
82
85
  allow(subject.connection).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return(mock_response)
83
86
  expect(subject.search({qt: 'abc'})).to be_a_kind_of Blacklight::Solr::Response
84
87
  end
85
-
88
+
86
89
  it "should preserve the class of the incoming params" do
87
90
  search_params = ActiveSupport::HashWithIndifferentAccess.new
88
91
  search_params[:q] = "query"
89
92
  allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
90
-
93
+
91
94
  response = subject.search(search_params)
92
95
  expect(response).to be_a_kind_of Blacklight::Solr::Response
93
96
  expect(response.params).to be_a_kind_of ActiveSupport::HashWithIndifferentAccess
@@ -134,5 +137,9 @@ describe Blacklight::Solr::Repository do
134
137
  end
135
138
  end
136
139
 
140
+ describe '#ping' do
141
+ subject { repository.ping }
137
142
 
143
+ it { is_expected.to be true }
144
+ end
138
145
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Blacklight::Suggest::Response do
4
- let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest') }
3
+ RSpec.describe Blacklight::Suggest::Response, api: true do
4
+ let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest', 'mySuggester') }
5
5
  let(:full_response) do
6
6
  described_class.new(
7
7
  {
@@ -36,7 +36,8 @@ describe Blacklight::Suggest::Response do
36
36
  {
37
37
  q: 'new'
38
38
  },
39
- 'suggest'
39
+ 'suggest',
40
+ 'mySuggester'
40
41
  )
41
42
  end
42
43
 
@@ -52,4 +53,4 @@ describe Blacklight::Suggest::Response do
52
53
  expect(full_response.suggestions.first['term']).to eq 'new jersey'
53
54
  end
54
55
  end
55
- end
56
+ end
@@ -2,21 +2,14 @@
2
2
 
3
3
  describe Blacklight::SuggestSearch do
4
4
  let(:params) { {q: 'test'} }
5
- let(:suggest_path) { 'suggest' }
6
- let(:connection) { instance_double(RSolr::Client, send_and_receive: 'sent')}
7
- let(:repository) { instance_double(Blacklight::Solr::Repository, connection: connection) }
5
+ let(:response) { instance_double(Blacklight::Suggest::Response)}
6
+ let(:repository) { instance_double(Blacklight::Solr::Repository, suggestions: response) }
8
7
  let(:suggest_search) { described_class.new(params, repository)}
8
+
9
9
  describe '#suggestions' do
10
- it 'returns a Blacklight::Suggest::Response' do
11
- expect(suggest_search).to receive(:suggest_results).and_return([])
12
- expect(suggest_search).to receive(:suggest_handler_path).and_return(suggest_path)
13
- expect(suggest_search.suggestions).to be_an Blacklight::Suggest::Response
14
- end
15
- end
16
- describe '#suggest_results' do
17
- it 'calls send_and_recieve from a repository connection' do
18
- expect(suggest_search).to receive(:suggest_handler_path).and_return(suggest_path)
19
- expect(suggest_search.suggest_results).to eq 'sent'
10
+ it 'delegates to the repository' do
11
+ expect(repository).to receive(:suggestions).with(q: 'test').and_return(response)
12
+ expect(suggest_search.suggestions).to eq response
20
13
  end
21
14
  end
22
15
  end
@@ -49,6 +49,15 @@ describe Blacklight::IndexPresenter do
49
49
  expect(Deprecation).to receive(:warn)
50
50
  expect(subject).to eq 'document qwer value'
51
51
  end
52
+
53
+ context 'with a name as a symbol' do
54
+ subject { presenter.field_value :qwer }
55
+
56
+ it 'raises a deprecation' do
57
+ expect(Deprecation).to receive(:warn)
58
+ expect(subject).to eq 'document qwer value'
59
+ end
60
+ end
52
61
  end
53
62
 
54
63
  context 'when an explicit value is provided' do
data/spec/spec_helper.rb CHANGED
@@ -25,15 +25,19 @@ require 'rspec/rails'
25
25
  require 'rspec/its'
26
26
  require 'rspec/collection_matchers'
27
27
  require 'capybara/rspec'
28
- require 'capybara/poltergeist'
28
+ require 'selenium-webdriver'
29
29
  require 'equivalent-xml'
30
30
 
31
- Capybara.javascript_driver = :poltergeist
31
+ Capybara.javascript_driver = :headless_chrome
32
32
 
33
- Capybara.register_driver :poltergeist do |app|
34
- options = {}
35
- options[:timeout] = 120 if RUBY_PLATFORM == "java"
36
- Capybara::Poltergeist::Driver.new(app, options)
33
+ Capybara.register_driver :headless_chrome do |app|
34
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
35
+ chromeOptions: { args: %w[headless disable-gpu] }
36
+ )
37
+
38
+ Capybara::Selenium::Driver.new(app,
39
+ browser: :chrome,
40
+ desired_capabilities: capabilities)
37
41
  end
38
42
 
39
43
  # Requires supporting ruby files with custom matchers and macros, etc,
@@ -12,9 +12,9 @@ RuboCop::RakeTask.new(:rubocop)
12
12
  EngineCart.fingerprint_proc = EngineCart.rails_fingerprint_proc
13
13
 
14
14
  desc "Run test suite"
15
- task :ci => ['blacklight:generate'] do
15
+ task ci: ['blacklight:generate'] do
16
16
  SolrWrapper.wrap do |solr|
17
- solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path("..", File.dirname(__FILE__)), "solr", "conf")) do
17
+ solr.with_collection do
18
18
  within_test_app do
19
19
  system "RAILS_ENV=test rake blacklight:index:seed"
20
20
  end
@@ -52,8 +52,8 @@ namespace :blacklight do
52
52
  Rake::Task['engine_cart:generate'].invoke
53
53
  end
54
54
 
55
- SolrWrapper.wrap(port: '8983') do |solr|
56
- solr.with_collection(name: 'blacklight-core', dir: File.join(File.expand_path("..", File.dirname(__FILE__)), "solr", "conf")) do
55
+ SolrWrapper.wrap do |solr|
56
+ solr.with_collection do
57
57
  Rake::Task['blacklight:internal:seed'].invoke
58
58
 
59
59
  within_test_app do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.18.0
4
+ version: 6.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: exe
19
19
  cert_chain: []
20
- date: 2018-11-08 00:00:00.000000000 Z
20
+ date: 2018-12-17 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -57,16 +57,16 @@ dependencies:
57
57
  name: jbuilder
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: '2.7'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '2.7'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: nokogiri
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -217,44 +217,64 @@ dependencies:
217
217
  name: capybara
218
218
  requirement: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - "~>"
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
- version: '2.6'
222
+ version: '2'
223
+ - - "<"
224
+ - !ruby/object:Gem::Version
225
+ version: '4'
223
226
  type: :development
224
227
  prerelease: false
225
228
  version_requirements: !ruby/object:Gem::Requirement
226
229
  requirements:
227
- - - "~>"
230
+ - - ">="
228
231
  - !ruby/object:Gem::Version
229
- version: '2.6'
232
+ version: '2'
233
+ - - "<"
234
+ - !ruby/object:Gem::Version
235
+ version: '4'
230
236
  - !ruby/object:Gem::Dependency
231
- name: poltergeist
237
+ name: chromedriver-helper
238
+ requirement: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - "<"
241
+ - !ruby/object:Gem::Version
242
+ version: 2.0.0
243
+ type: :development
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "<"
248
+ - !ruby/object:Gem::Version
249
+ version: 2.0.0
250
+ - !ruby/object:Gem::Dependency
251
+ name: selenium-webdriver
232
252
  requirement: !ruby/object:Gem::Requirement
233
253
  requirements:
234
254
  - - ">="
235
255
  - !ruby/object:Gem::Version
236
- version: '0'
256
+ version: 3.13.1
237
257
  type: :development
238
258
  prerelease: false
239
259
  version_requirements: !ruby/object:Gem::Requirement
240
260
  requirements:
241
261
  - - ">="
242
262
  - !ruby/object:Gem::Version
243
- version: '0'
263
+ version: 3.13.1
244
264
  - !ruby/object:Gem::Dependency
245
265
  name: engine_cart
246
266
  requirement: !ruby/object:Gem::Requirement
247
267
  requirements:
248
268
  - - "~>"
249
269
  - !ruby/object:Gem::Version
250
- version: '1.0'
270
+ version: '1.2'
251
271
  type: :development
252
272
  prerelease: false
253
273
  version_requirements: !ruby/object:Gem::Requirement
254
274
  requirements:
255
275
  - - "~>"
256
276
  - !ruby/object:Gem::Version
257
- version: '1.0'
277
+ version: '1.2'
258
278
  - !ruby/object:Gem::Dependency
259
279
  name: equivalent-xml
260
280
  requirement: !ruby/object:Gem::Requirement
@@ -765,7 +785,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
765
785
  version: '0'
766
786
  requirements: []
767
787
  rubyforge_project:
768
- rubygems_version: 2.6.11
788
+ rubygems_version: 2.7.6
769
789
  signing_key:
770
790
  specification_version: 4
771
791
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)