blacklight 7.20.1 → 7.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.babelrc +11 -0
  3. data/.docker/app/Dockerfile +3 -1
  4. data/.dockerignore +3 -0
  5. data/.env +2 -2
  6. data/.github/workflows/ruby.yml +3 -2
  7. data/Gemfile +1 -1
  8. data/README.md +1 -1
  9. data/VERSION +1 -1
  10. data/app/assets/javascripts/blacklight/blacklight.js +62 -32
  11. data/app/assets/stylesheets/blacklight/_constraints.scss +3 -1
  12. data/app/assets/stylesheets/blacklight/_controls.scss +2 -1
  13. data/app/components/blacklight/constraints_component.rb +3 -7
  14. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  15. data/app/components/blacklight/facet_item_pivot_component.rb +1 -1
  16. data/app/components/blacklight/system/modal_component.html.erb +2 -2
  17. data/app/controllers/concerns/blacklight/catalog.rb +2 -2
  18. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  19. data/app/helpers/blacklight/render_partials_helper_behavior.rb +4 -1
  20. data/app/javascript/blacklight/core.js +8 -2
  21. data/app/javascript/blacklight/modal.js +20 -4
  22. data/app/models/concerns/blacklight/document/email.rb +18 -6
  23. data/app/models/concerns/blacklight/document/sms.rb +16 -4
  24. data/app/models/record_mailer.rb +9 -1
  25. data/app/presenters/blacklight/facet_item_presenter.rb +2 -0
  26. data/app/views/bookmarks/index.html.erb +1 -1
  27. data/app/views/catalog/_search_results.html.erb +1 -1
  28. data/app/views/record_mailer/sms_record.text.erb +1 -1
  29. data/config/locales/blacklight.de.yml +1 -1
  30. data/docker-compose.yml +5 -2
  31. data/lib/blacklight/configuration/facet_field.rb +2 -0
  32. data/lib/blacklight/configuration.rb +9 -0
  33. data/lib/blacklight/engine.rb +2 -0
  34. data/lib/blacklight/search_state/filter_field.rb +34 -19
  35. data/lib/blacklight/solr/response/facets.rb +14 -5
  36. data/lib/blacklight/solr/search_builder_behavior.rb +2 -14
  37. data/package.json +4 -2
  38. data/spec/controllers/catalog_controller_spec.rb +14 -2
  39. data/spec/features/axe_spec.rb +6 -7
  40. data/spec/features/facet_missing_spec.rb +12 -4
  41. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +7 -7
  42. data/spec/lib/blacklight/search_state/filter_field_spec.rb +3 -17
  43. data/spec/models/blacklight/configuration_spec.rb +92 -0
  44. data/spec/models/blacklight/document/email_spec.rb +32 -0
  45. data/spec/models/blacklight/document/sms_spec.rb +33 -0
  46. data/spec/models/blacklight/solr/response/facets_spec.rb +7 -1
  47. data/spec/models/blacklight/solr/search_builder_spec.rb +0 -13
  48. data/spec/models/record_mailer_spec.rb +30 -2
  49. data/spec/spec_helper.rb +3 -3
  50. data/tasks/blacklight.rake +5 -1
  51. metadata +8 -6
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe "Blacklight::Document::Email" do
4
+ let(:config) do
5
+ Blacklight::Configuration.new
6
+ end
7
+
4
8
  before(:all) do
5
9
  SolrDocument.use_extension(Blacklight::Document::Email)
6
10
  end
@@ -22,4 +26,32 @@ RSpec.describe "Blacklight::Document::Email" do
22
26
  doc = SolrDocument.new(id: "1234")
23
27
  expect(doc.to_email_text).to be_nil
24
28
  end
29
+
30
+ context "we pass in configuration with email fields set" do
31
+ it "uses the email fields for to_email_text" do
32
+ config.add_email_field("foo", label: "Foo:")
33
+ config.add_email_field("bar", label: "Bar:")
34
+ doc = SolrDocument.new(id: "1234", foo: ["Fuzz Fuzz", "Fizz Fizz"], bar: ["Buzz Buzz", "Bizz Bizz"])
35
+
36
+ expect(doc.to_email_text(config)).to eq("Foo: Fuzz Fuzz Fizz Fizz\nBar: Buzz Buzz Bizz Bizz")
37
+ end
38
+ end
39
+
40
+ context "we pass in configuration with email fields no set" do
41
+ it "falls back on default semantics setup" do
42
+ doc = SolrDocument.new(id: "1234", title_tsim: ["My Title", "My Alt. Title"])
43
+ email_body = doc.to_email_text(config)
44
+ expect(email_body).to match(/Title: My Title/)
45
+ end
46
+ end
47
+
48
+ context "document field is single valued" do
49
+ it "handles the single value field correctly" do
50
+ config.add_email_field("foo", label: "Foo:")
51
+ config.add_email_field("bar", label: "Bar:")
52
+ doc = SolrDocument.new(id: "1234", foo: "Fuzz Fuzz", bar: ["Buzz Buzz", "Bizz Bizz"])
53
+
54
+ expect(doc.to_email_text(config)).to eq("Foo: Fuzz Fuzz\nBar: Buzz Buzz Bizz Bizz")
55
+ end
56
+ end
25
57
  end
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe "Blacklight::Document::Email" do
4
+ let(:config) do
5
+ Blacklight::Configuration.new
6
+ end
7
+
4
8
  before(:all) do
5
9
  SolrDocument.use_extension(Blacklight::Document::Sms)
6
10
  end
@@ -22,4 +26,33 @@ RSpec.describe "Blacklight::Document::Email" do
22
26
  doc = SolrDocument.new(id: "1234")
23
27
  expect(doc.to_sms_text).to be_nil
24
28
  end
29
+
30
+ context "we pass in configuration with sms fields set" do
31
+ it "uses the sms fields for to_sms_text" do
32
+ config.add_sms_field("foo", label: "Foo:")
33
+ config.add_sms_field("bar", label: " by")
34
+ doc = SolrDocument.new(id: "1234", foo: ["Fuzz Fuzz", "Fizz Fizz"], bar: ["Buzz Buzz", "Bizz Bizz"])
35
+
36
+ expect(doc.to_sms_text(config)).to eq("Foo: Fuzz Fuzz by Buzz Buzz")
37
+ end
38
+ end
39
+
40
+ context "we pass in configuration with sms fields no set" do
41
+ it "falls back on default semantics setup" do
42
+ doc = SolrDocument.new(id: "1234", title_tsim: ["My Title", "My Alt. Title"])
43
+ sms_text = doc.to_sms_text(config)
44
+ expect(sms_text).to match(/My Title/)
45
+ expect(sms_text).not_to match(/My Alt\. Title/)
46
+ end
47
+ end
48
+
49
+ context "document field is single valued" do
50
+ it "handles the single value field correctly" do
51
+ config.add_sms_field("foo", label: "Foo:")
52
+ config.add_sms_field("bar", label: " by")
53
+ doc = SolrDocument.new(id: "1234", foo: "Fuzz Fuzz", bar: ["Buzz Buzz", "Bizz Bizz"])
54
+
55
+ expect(doc.to_sms_text(config)).to eq("Foo: Fuzz Fuzz by Buzz Buzz")
56
+ end
57
+ end
25
58
  end
@@ -102,6 +102,12 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
102
102
  expect(subject.aggregations['my_field'].prefix).to be_nil
103
103
  end
104
104
  end
105
+
106
+ describe '#response' do
107
+ it 'provides access to the full solr response' do
108
+ expect(subject.aggregations['my_field'].response).to eq subject
109
+ end
110
+ end
105
111
  end
106
112
 
107
113
  describe "#merge_facet" do
@@ -155,7 +161,7 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
155
161
  end
156
162
 
157
163
  it "marks the facet.missing field with a human-readable label and fq" do
158
- missing = subject.aggregations["some_field"].items.find { |i| i.value.nil? }
164
+ missing = subject.aggregations["some_field"].items.find(&:missing)
159
165
 
160
166
  expect(missing.label).to eq "[Missing]"
161
167
  expect(missing.fq).to eq "-some_field:[* TO *]"
@@ -27,10 +27,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
27
27
  it "uses the class-level default_processor_chain" do
28
28
  expect(subject.processor_chain).to eq search_builder_class.default_processor_chain
29
29
  end
30
-
31
- it "appends the :add_missing_field_query processor" do
32
- expect(subject.processor_chain).to include(:add_missing_field_query)
33
- end
34
30
  end
35
31
 
36
32
  context 'with merged parameters from the defaults + the search field' do
@@ -826,13 +822,4 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
826
822
  expect(subject.to_hash).to include q: '{!lucene}id:(1 OR 2 OR 3)'
827
823
  end
828
824
  end
829
-
830
- describe "#add_missing_field_query" do
831
- it "precesses facet.missing query" do
832
- subject.with("f" => { "-hello:" => [""] })
833
- solr_params = { "facet.missing" => true, fq: [] }
834
-
835
- expect(subject.add_missing_field_query(solr_params)).to eq(["-hello:[* TO *]"])
836
- end
837
- end
838
825
  end
@@ -1,17 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe RecordMailer do
4
+ let(:config) do
5
+ Blacklight::Configuration.new
6
+ end
7
+
8
+ let(:document) do
9
+ SolrDocument.new(id: "123456", format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt")
10
+ end
11
+
4
12
  before do
5
13
  allow(described_class).to receive(:default).and_return(from: 'no-reply@projectblacklight.org')
6
14
  SolrDocument.use_extension(Blacklight::Document::Email)
7
15
  SolrDocument.use_extension(Blacklight::Document::Sms)
8
- document = SolrDocument.new(id: "123456", format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt")
9
16
  @documents = [document]
10
17
  end
11
18
 
12
19
  describe "email" do
13
20
  before do
14
- details = { to: 'test@test.com', message: "This is my message" }
21
+ details = { to: 'test@test.com', message: "This is my message", config: config }
15
22
  @email = described_class.email_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
16
23
  end
17
24
 
@@ -42,6 +49,27 @@ RSpec.describe RecordMailer do
42
49
  @https_email = described_class.email_record(@documents, details, host: 'projectblacklight.org', protocol: 'https')
43
50
  expect(@https_email.body).to match %r{https://projectblacklight.org/}
44
51
  end
52
+
53
+ context "email title_field is configured and multi valued" do
54
+ let(:document) { SolrDocument.new(id: "123456", foo: ["Fizz Fizz", "Fuzz Fuzz"], format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt") }
55
+
56
+ it "uses configured email title_field" do
57
+ config.email.title_field = "foo"
58
+ expect(@email.subject).to match("Fizz Fizz")
59
+ expect(@email.subject).not_to match("Fuzz Fuzz")
60
+ expect(@email.subject).not_to match("The horn")
61
+ end
62
+ end
63
+
64
+ context "email title_field is configured and single valued" do
65
+ let(:document) { SolrDocument.new(id: "123456", foo: "Fizz Fizz", format: ["book"], title_tsim: "The horn", language_ssim: "English", author_tsim: "Janetzky, Kurt") }
66
+
67
+ it "uses configured email title_field" do
68
+ config.email.title_field = "foo"
69
+ expect(@email.subject).to match("Fizz Fizz")
70
+ expect(@email.subject).not_to match("The horn")
71
+ end
72
+ end
45
73
  end
46
74
 
47
75
  describe "SMS" do
data/spec/spec_helper.rb CHANGED
@@ -10,9 +10,6 @@ SimpleCov.start do
10
10
  add_filter "/spec/"
11
11
  end
12
12
 
13
- require 'rsolr'
14
- require 'blacklight'
15
-
16
13
  require 'engine_cart'
17
14
  EngineCart.load_application!
18
15
 
@@ -25,6 +22,9 @@ require 'selenium-webdriver'
25
22
  require 'equivalent-xml'
26
23
  require 'axe-rspec'
27
24
 
25
+ require 'rsolr'
26
+ require 'blacklight'
27
+
28
28
  Capybara.javascript_driver = :headless_chrome
29
29
 
30
30
  Capybara.register_driver :headless_chrome do |app|
@@ -21,7 +21,11 @@ def system_with_error_handling(*args)
21
21
  end
22
22
 
23
23
  def with_solr
24
- if system('docker-compose -v')
24
+ # We're being invoked by the app entrypoint script and solr is already up via docker-compose
25
+ if ENV['SOLR_ENV'] == 'docker-compose'
26
+ yield
27
+ elsif system('docker-compose -v')
28
+ # We're not running docker-compose up but still want to use a docker instance of solr.
25
29
  begin
26
30
  puts "Starting Solr"
27
31
  system_with_error_handling "docker-compose up -d solr"
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.20.1
4
+ version: 7.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -14,10 +14,10 @@ authors:
14
14
  - Dan Funk
15
15
  - Naomi Dushay
16
16
  - Justin Coyne
17
- autorequire:
17
+ autorequire:
18
18
  bindir: exe
19
19
  cert_chain: []
20
- date: 2021-11-02 00:00:00.000000000 Z
20
+ date: 2021-12-03 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -378,8 +378,10 @@ executables: []
378
378
  extensions: []
379
379
  extra_rdoc_files: []
380
380
  files:
381
+ - ".babelrc"
381
382
  - ".docker/app/Dockerfile"
382
383
  - ".docker/app/entrypoint.sh"
384
+ - ".dockerignore"
383
385
  - ".env"
384
386
  - ".github/workflows/ruby.yml"
385
387
  - ".gitignore"
@@ -918,7 +920,7 @@ homepage: http://projectblacklight.org/
918
920
  licenses:
919
921
  - Apache 2.0
920
922
  metadata: {}
921
- post_install_message:
923
+ post_install_message:
922
924
  rdoc_options: []
923
925
  require_paths:
924
926
  - lib
@@ -933,8 +935,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
933
935
  - !ruby/object:Gem::Version
934
936
  version: '0'
935
937
  requirements: []
936
- rubygems_version: 3.1.4
937
- signing_key:
938
+ rubygems_version: 3.2.15
939
+ signing_key:
938
940
  specification_version: 4
939
941
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
940
942
  index.