blacklight 7.0.1 → 7.1.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +30 -49
  3. data/.travis.yml +4 -4
  4. data/VERSION +1 -1
  5. data/app/assets/javascripts/blacklight/blacklight.js +51 -65
  6. data/app/assets/stylesheets/blacklight/_pagination.scss +6 -0
  7. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -0
  8. data/app/controllers/concerns/blacklight/catalog.rb +2 -9
  9. data/app/controllers/concerns/blacklight/facet.rb +7 -2
  10. data/app/controllers/concerns/blacklight/searchable.rb +17 -0
  11. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  12. data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
  13. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  14. data/app/helpers/blacklight/render_partials_helper_behavior.rb +12 -0
  15. data/app/helpers/blacklight/url_helper_behavior.rb +2 -2
  16. data/app/models/concerns/blacklight/document/email.rb +4 -4
  17. data/app/models/concerns/blacklight/document/sms.rb +2 -2
  18. data/app/models/search.rb +1 -1
  19. data/app/services/blacklight/search_service.rb +4 -3
  20. data/app/views/catalog/_facet_group.html.erb +19 -0
  21. data/app/views/catalog/_facets.html.erb +3 -18
  22. data/app/views/catalog/index.atom.builder +14 -13
  23. data/app/views/catalog/index.rss.builder +1 -1
  24. data/app/views/shared/_flash_msg.html.erb +5 -3
  25. data/blacklight.gemspec +2 -3
  26. data/lib/blacklight/configuration.rb +2 -1
  27. data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
  28. data/lib/generators/blacklight/assets_generator.rb +0 -1
  29. data/lib/generators/blacklight/install_generator.rb +0 -8
  30. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +1 -1
  31. data/package-lock.json +2210 -1612
  32. data/package.json +5 -4
  33. data/spec/controllers/bookmarks_controller_spec.rb +4 -0
  34. data/spec/features/search_formats_spec.rb +3 -4
  35. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +5 -0
  36. data/spec/helpers/catalog_helper_spec.rb +11 -2
  37. data/spec/services/blacklight/search_service_spec.rb +8 -1
  38. data/spec/spec_helper.rb +1 -0
  39. data/spec/views/catalog/_facets.html.erb_spec.rb +30 -7
  40. metadata +12 -24
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "7.0.1",
3
+ "version": "7.1.0-alpha",
4
4
  "description": "[![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=master)](https://coveralls.io/github/projectblacklight/blacklight?branch=master)",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "scripts": {
@@ -17,12 +17,13 @@
17
17
  },
18
18
  "homepage": "https://github.com/projectblacklight/blacklight#readme",
19
19
  "devDependencies": {
20
- "babel-cli": "^6.26.0",
21
- "shx": "^0.2.2"
20
+ "@babel/cli": "^7.2.3",
21
+ "@babel/core": "^7.2.3",
22
+ "shx": "^0.3.2"
22
23
  },
23
24
  "dependencies": {
24
25
  "bloodhound-js": "^1.2.3",
25
- "bootstrap": "^4.1.3",
26
+ "bootstrap": "^4.3.1",
26
27
  "jquery": "^3.3.1",
27
28
  "typeahead.js": "^0.11.1"
28
29
  }
@@ -5,6 +5,10 @@ RSpec.describe BookmarksController do
5
5
  it 'uses POST requests for querying solr' do
6
6
  expect(@controller.blacklight_config.http_method).to eq :post
7
7
  end
8
+
9
+ it 'opts out of search session tracking' do
10
+ expect(@controller.blacklight_config.track_search_session).to eq false
11
+ end
8
12
  end
9
13
 
10
14
  # jquery 1.9 ajax does error callback if 200 returns empty body. so use 204 instead.
@@ -4,14 +4,13 @@ RSpec.describe "Search Formats" do
4
4
  it "has an RSS XML response" do
5
5
  visit "/catalog.rss?q="
6
6
  expect(page).to have_content "Blacklight Search Results"
7
- doc = Nokogiri::XML(page.body)
8
- expect(doc.xpath("//item")).to have(10).items
7
+ expect(page).to have_xpath('//item', count: 10)
9
8
  end
10
9
 
11
10
  it "has an ATOM XML response" do
12
11
  visit "/catalog.atom?q="
13
12
  expect(page).to have_content "Blacklight Search Results"
14
- doc = Nokogiri::XML(page.body)
15
- expect(doc.xpath("//atom:entry", atom: "http://www.w3.org/2005/Atom")).to have(10).entries
13
+
14
+ expect(page).to have_xpath('//entry', count: 10)
16
15
  end
17
16
  end
@@ -297,5 +297,10 @@ RSpec.describe Blacklight::UrlHelperBehavior do
297
297
  allow(helper.main_app).to receive(:track_test_path).with(id: have_attributes(id: 1), x: 1).and_return('x')
298
298
  expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
299
299
  end
300
+
301
+ it "uses the track_search_session configuration to determine whether to track the search session" do
302
+ blacklight_config.track_search_session = false
303
+ expect(helper.session_tracking_path(document, x: 1)).to eq nil
304
+ end
300
305
  end
301
306
  end
@@ -388,8 +388,17 @@ RSpec.describe CatalogHelper do
388
388
  end
389
389
 
390
390
  let(:blacklight_config) { Blacklight::Configuration.new }
391
- let(:params) { ActionController::Parameters.new(q: 'foobar', f: { format: ["Book"] }) }
392
391
 
393
- it { is_expected.to eq "foobar / Format: Book" }
392
+ context 'when the f param is an array' do
393
+ let(:params) { ActionController::Parameters.new(q: 'foobar', f: { format: ["Book"] }) }
394
+
395
+ it { is_expected.to eq "foobar / Format: Book" }
396
+ end
397
+
398
+ context 'when the f param is not an array' do
399
+ let(:params) { ActionController::Parameters.new(q: 'foobar', f: { format: 'Book' }) }
400
+
401
+ it { is_expected.to eq "foobar / Format: Book" }
402
+ end
394
403
  end
395
404
  end
@@ -11,7 +11,8 @@
11
11
  RSpec.describe Blacklight::SearchService, api: true do
12
12
  subject { service }
13
13
 
14
- let(:service) { described_class.new(config: blacklight_config, user_params: user_params) }
14
+ let(:context) { { whatever: :value } }
15
+ let(:service) { described_class.new(config: blacklight_config, user_params: user_params, **context) }
15
16
  let(:repository) { Blacklight::Solr::Repository.new(blacklight_config) }
16
17
  let(:user_params) { {} }
17
18
 
@@ -485,4 +486,10 @@ RSpec.describe Blacklight::SearchService, api: true do
485
486
  expect(service.opensearch_response.last).to match_array %w[A B C]
486
487
  end
487
488
  end
489
+
490
+ describe '#context' do
491
+ it 'has a context attribute' do
492
+ expect(subject.context).to eq context
493
+ end
494
+ end
488
495
  end
@@ -22,6 +22,7 @@ require 'rspec/collection_matchers'
22
22
  require 'capybara/rspec'
23
23
  require 'selenium-webdriver'
24
24
  require 'equivalent-xml'
25
+ require 'chromedriver-helper'
25
26
 
26
27
  Capybara.javascript_driver = :headless_chrome
27
28
 
@@ -16,23 +16,46 @@ RSpec.describe "catalog/_facets" do
16
16
  end
17
17
  end
18
18
 
19
- context "with facet fields" do
19
+ context "with facet groups" do
20
20
  let :facet_field do
21
- Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label').normalize!
21
+ Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: nil).normalize!
22
22
  end
23
23
 
24
24
  before do
25
25
  blacklight_config.facet_fields['facet_field_1'] = facet_field
26
26
  @mock_display_facet_1 = double(name: 'facet_field_1', sort: nil, offset: nil, prefix: nil, items: [Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Value', hits: 1234)])
27
- allow(view).to receive_messages(facet_field_names: [:facet_field_1], facet_limit_for: 10)
27
+ allow(view).to receive_messages(facet_group_names: [nil], facet_field_names: [:facet_field_1], facet_limit_for: 10)
28
28
  @response = double
29
29
  allow(@response).to receive(:aggregations).and_return("facet_field_1" => @mock_display_facet_1)
30
30
  end
31
31
 
32
- it "has a header" do
33
- allow(view).to receive_messages(render_facet_partials: '')
34
- render
35
- expect(rendered).to have_selector('.facets-heading')
32
+ context "with the default facet group" do
33
+ it "has a header" do
34
+ allow(view).to receive_messages(render_facet_partials: '')
35
+ render
36
+ expect(rendered).to have_selector('.facets-heading')
37
+ end
38
+ end
39
+
40
+ context "with a named facet group" do
41
+ let :facet_field do
42
+ Blacklight::Configuration::FacetField.new(field: 'facet_field_1', label: 'label', group: 'group_1').normalize!
43
+ end
44
+
45
+ before do
46
+ blacklight_config.facet_fields['facet_field_1'] = facet_field
47
+ @mock_display_facet_1 = double(name: 'facet_field_1', sort: nil, offset: nil, prefix: nil, items: [Blacklight::Solr::Response::Facets::FacetItem.new(value: 'Value', hits: 1234)])
48
+ allow(view).to receive_messages(facet_group_names: [nil, 'group_1'], facet_field_names: [:facet_field_1], facet_limit_for: 10)
49
+ @response = double
50
+ allow(@response).to receive(:aggregations).and_return("facet_field_1" => @mock_display_facet_1)
51
+ end
52
+
53
+ it "has a header" do
54
+ allow(view).to receive_messages(render_facet_partials: '')
55
+ render
56
+ expect(rendered).to have_selector('.facets-heading')
57
+ expect(rendered).to have_selector('#facets-group_1')
58
+ end
36
59
  end
37
60
 
38
61
  describe "facet display" 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: 7.0.1
4
+ version: 7.1.0.alpha
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: 2019-01-13 00:00:00.000000000 Z
20
+ date: 2019-04-30 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -61,20 +61,6 @@ dependencies:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '2.7'
64
- - !ruby/object:Gem::Dependency
65
- name: nokogiri
66
- requirement: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - "~>"
69
- - !ruby/object:Gem::Version
70
- version: '1.6'
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '1.6'
78
64
  - !ruby/object:Gem::Dependency
79
65
  name: kaminari
80
66
  requirement: !ruby/object:Gem::Requirement
@@ -197,16 +183,16 @@ dependencies:
197
183
  name: chromedriver-helper
198
184
  requirement: !ruby/object:Gem::Requirement
199
185
  requirements:
200
- - - "<"
186
+ - - "~>"
201
187
  - !ruby/object:Gem::Version
202
- version: 2.0.0
188
+ version: '2.1'
203
189
  type: :development
204
190
  prerelease: false
205
191
  version_requirements: !ruby/object:Gem::Requirement
206
192
  requirements:
207
- - - "<"
193
+ - - "~>"
208
194
  - !ruby/object:Gem::Version
209
- version: 2.0.0
195
+ version: '2.1'
210
196
  - !ruby/object:Gem::Dependency
211
197
  name: selenium-webdriver
212
198
  requirement: !ruby/object:Gem::Requirement
@@ -269,14 +255,14 @@ dependencies:
269
255
  requirements:
270
256
  - - "~>"
271
257
  - !ruby/object:Gem::Version
272
- version: 0.61.1
258
+ version: 0.63.0
273
259
  type: :development
274
260
  prerelease: false
275
261
  version_requirements: !ruby/object:Gem::Requirement
276
262
  requirements:
277
263
  - - "~>"
278
264
  - !ruby/object:Gem::Version
279
- version: 0.61.1
265
+ version: 0.63.0
280
266
  - !ruby/object:Gem::Dependency
281
267
  name: rubocop-rspec
282
268
  requirement: !ruby/object:Gem::Requirement
@@ -369,6 +355,7 @@ files:
369
355
  - app/controllers/concerns/blacklight/search_context.rb
370
356
  - app/controllers/concerns/blacklight/search_fields.rb
371
357
  - app/controllers/concerns/blacklight/search_history.rb
358
+ - app/controllers/concerns/blacklight/searchable.rb
372
359
  - app/controllers/concerns/blacklight/token_based_user.rb
373
360
  - app/controllers/search_history_controller.rb
374
361
  - app/helpers/blacklight/blacklight_helper_behavior.rb
@@ -451,6 +438,7 @@ files:
451
438
  - app/views/catalog/_document_action.html.erb
452
439
  - app/views/catalog/_document_list.html.erb
453
440
  - app/views/catalog/_email_form.html.erb
441
+ - app/views/catalog/_facet_group.html.erb
454
442
  - app/views/catalog/_facet_index_navigation.html.erb
455
443
  - app/views/catalog/_facet_layout.html.erb
456
444
  - app/views/catalog/_facet_limit.html.erb
@@ -751,9 +739,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
751
739
  version: '2.1'
752
740
  required_rubygems_version: !ruby/object:Gem::Requirement
753
741
  requirements:
754
- - - ">="
742
+ - - ">"
755
743
  - !ruby/object:Gem::Version
756
- version: '0'
744
+ version: 1.3.1
757
745
  requirements: []
758
746
  rubyforge_project:
759
747
  rubygems_version: 2.7.6