blacklight 8.2.2 → 8.3.0

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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.github/workflows/ruby.yml +56 -62
  4. data/.rubocop.yml +226 -21
  5. data/VERSION +1 -1
  6. data/app/assets/stylesheets/blacklight/_mixins.scss +2 -17
  7. data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
  8. data/app/components/blacklight/system/dropdown_component.rb +1 -1
  9. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -5
  10. data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
  11. data/app/views/shared/_flash_messages.html.erb +1 -1
  12. data/lib/blacklight/configuration.rb +1 -0
  13. data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
  14. data/lib/blacklight/solr/request.rb +1 -1
  15. data/lib/blacklight/solr/response/facets.rb +1 -1
  16. data/lib/blacklight/solr/search_builder_behavior.rb +1 -1
  17. data/package.json +1 -1
  18. data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
  19. data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
  20. data/spec/components/blacklight/constraints_component_spec.rb +9 -9
  21. data/spec/components/blacklight/document/group_component_spec.rb +3 -3
  22. data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
  23. data/spec/components/blacklight/document_component_spec.rb +21 -25
  24. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  25. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
  26. data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
  27. data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
  28. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
  29. data/spec/components/blacklight/header_component_spec.rb +1 -2
  30. data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
  31. data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
  32. data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
  33. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
  34. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +1 -3
  35. data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
  36. data/spec/controllers/blacklight/catalog_spec.rb +1 -1
  37. data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
  38. data/spec/controllers/bookmarks_controller_spec.rb +10 -10
  39. data/spec/controllers/catalog_controller_spec.rb +24 -26
  40. data/spec/features/advanced_search_spec.rb +14 -14
  41. data/spec/features/alternate_controller_spec.rb +9 -9
  42. data/spec/features/axe_spec.rb +4 -4
  43. data/spec/features/bookmarks_spec.rb +19 -19
  44. data/spec/features/citation_spec.rb +1 -1
  45. data/spec/features/did_you_mean_spec.rb +23 -23
  46. data/spec/features/facet_missing_spec.rb +9 -9
  47. data/spec/features/facets_spec.rb +21 -20
  48. data/spec/features/modal_spec.rb +4 -4
  49. data/spec/features/record_view_spec.rb +2 -2
  50. data/spec/features/search_context_spec.rb +6 -6
  51. data/spec/features/search_crawler_spec.rb +5 -5
  52. data/spec/features/search_filters_spec.rb +65 -65
  53. data/spec/features/search_history_spec.rb +12 -12
  54. data/spec/features/search_pagination_spec.rb +10 -10
  55. data/spec/features/search_results_spec.rb +1 -1
  56. data/spec/features/search_sort_spec.rb +4 -4
  57. data/spec/features/search_spec.rb +25 -25
  58. data/spec/features/sitelinks_search_box_spec.rb +2 -2
  59. data/spec/features/sms_spec.rb +1 -1
  60. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
  61. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
  62. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
  63. data/spec/helpers/blacklight_helper_spec.rb +13 -15
  64. data/spec/helpers/catalog_helper_spec.rb +3 -6
  65. data/spec/i18n_spec.rb +2 -1
  66. data/spec/lib/blacklight/search_state_spec.rb +4 -4
  67. data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
  68. data/spec/models/blacklight/configurable_spec.rb +1 -1
  69. data/spec/models/blacklight/configuration/context_spec.rb +1 -1
  70. data/spec/models/blacklight/configuration_spec.rb +2 -2
  71. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
  72. data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
  73. data/spec/models/blacklight/document_spec.rb +1 -1
  74. data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
  75. data/spec/models/blacklight/icon_spec.rb +1 -1
  76. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  77. data/spec/models/blacklight/solr/document_spec.rb +1 -1
  78. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
  79. data/spec/models/blacklight/solr/repository_spec.rb +2 -2
  80. data/spec/models/blacklight/solr/request_spec.rb +1 -1
  81. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
  82. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
  83. data/spec/models/blacklight/solr/response/group_spec.rb +1 -1
  84. data/spec/models/blacklight/solr/response_spec.rb +1 -1
  85. data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +9 -19
  86. data/spec/models/blacklight/suggest/response_spec.rb +1 -1
  87. data/spec/models/blacklight/suggest_search_spec.rb +1 -1
  88. data/spec/models/blacklight/user_spec.rb +1 -1
  89. data/spec/models/solr_document_spec.rb +1 -1
  90. data/spec/presenters/blacklight/document_presenter_spec.rb +1 -2
  91. data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
  92. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
  93. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
  94. data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
  95. data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
  96. data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
  97. data/spec/routing/catalog_routing_spec.rb +1 -1
  98. data/spec/services/blacklight/field_retriever_spec.rb +1 -1
  99. data/spec/services/blacklight/search_service_spec.rb +9 -9
  100. data/spec/spec_helper.rb +2 -2
  101. data/spec/support/features/search_helpers.rb +2 -2
  102. data/spec/support/features/session_helpers.rb +3 -3
  103. data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -2
  104. data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
  105. data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
  106. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
  107. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
  108. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
  109. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
  110. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
  111. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
  112. data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
  113. data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
  114. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
  115. data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
  116. data/spec/views/catalog/index.html.erb_spec.rb +2 -4
  117. data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
  118. data/spec/views/catalog/show.html.erb_spec.rb +3 -5
  119. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
  120. data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
  121. data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
  122. metadata +10 -10
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::FacetPaginator, api: true do
4
- let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
5
- let(:f2) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
6
- let(:f3) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '58', value: 'Serial') }
7
- let(:f4) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '48', value: 'Musical Recording') }
8
- let(:f5) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '37', value: 'Microform') }
9
- let(:f6) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '27', value: 'Thesis') }
10
- let(:f7) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '0') }
11
- let(:seven_facet_values) { [f1, f2, f3, f4, f5, f6, f7] }
12
- let(:six_facet_values) { [f1, f2, f3, f4, f5, f6] }
3
+ RSpec.describe Blacklight::FacetPaginator, :api do
4
+ let(:book) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
5
+ let(:musical_score) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '65', value: 'Musical Score') }
6
+ let(:serial) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '58', value: 'Serial') }
7
+ let(:musical_recording) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '48', value: 'Musical Recording') }
8
+ let(:microform) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '37', value: 'Microform') }
9
+ let(:thesis) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '27', value: 'Thesis') }
10
+ let(:blank) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '0') }
11
+ let(:seven_facet_values) { [book, musical_score, serial, musical_recording, microform, thesis, blank] }
12
+ let(:six_facet_values) { [book, musical_score, serial, musical_recording, microform, thesis] }
13
13
  let(:limit) { 6 }
14
14
 
15
15
  context 'on the first page of two pages' do
@@ -42,7 +42,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
42
42
  end
43
43
 
44
44
  context 'on the last page of two pages' do
45
- subject(:paginator) { described_class.new([f7], offset: 6, limit: limit) }
45
+ subject(:paginator) { described_class.new([blank], offset: 6, limit: limit) }
46
46
 
47
47
  it { is_expected.not_to be_first_page }
48
48
  it { is_expected.to be_last_page }
@@ -124,7 +124,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
124
124
  context 'when sorting by "count"' do
125
125
  subject { described_class.new([]) }
126
126
 
127
- let(:params) { HashWithIndifferentAccess.new 'facet.prefix': 'A' }
127
+ let(:params) { ActiveSupport::HashWithIndifferentAccess.new 'facet.prefix': 'A' }
128
128
 
129
129
  it 'includes the prefix filter for "index" sorting' do
130
130
  expect(subject.params_for_resort_url('index', params)).to include 'facet.prefix': 'A'
@@ -159,7 +159,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
159
159
  end
160
160
 
161
161
  describe "#as_json" do
162
- subject { described_class.new([f1], offset: 0, limit: nil).as_json }
162
+ subject { described_class.new([book], offset: 0, limit: nil).as_json }
163
163
 
164
164
  it "is well structured" do
165
165
  expect(subject).to eq("items" => [{ "hits" => "792", "value" => "Book" }], "limit" => nil,
@@ -169,7 +169,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
169
169
 
170
170
  describe "#total_pages" do
171
171
  # this method is just for API compatability with kaminari 0.16.1
172
- subject { described_class.new([f1], offset: 0, limit: nil).total_pages }
172
+ subject { described_class.new([book], offset: 0, limit: nil).total_pages }
173
173
 
174
174
  it { is_expected.to eq -1 }
175
175
  end
@@ -39,7 +39,7 @@ RSpec.describe Blacklight::Icon do
39
39
 
40
40
  it 'does not add title' do
41
41
  expect(Capybara.string(subject.svg))
42
- .not_to have_css 'title', text: 'Test'
42
+ .to have_no_css 'title', text: 'Test'
43
43
  end
44
44
  end
45
45
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::SearchBuilder, api: true do
3
+ RSpec.describe Blacklight::SearchBuilder, :api do
4
4
  subject(:builder) { described_class.new processor_chain, scope }
5
5
 
6
6
  let(:processor_chain) { [] }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe "Blacklight::Solr::Document", api: true do
3
+ RSpec.describe "Blacklight::Solr::Document", :api do
4
4
  class MockDocument
5
5
  include Blacklight::Solr::Document
6
6
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::FacetPaginator, api: true do
3
+ RSpec.describe Blacklight::Solr::FacetPaginator, :api do
4
4
  let(:f1) { Blacklight::Solr::Response::Facets::FacetItem.new(hits: '792', value: 'Book') }
5
5
 
6
6
  describe "#as_json" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::Repository, api: true do
3
+ RSpec.describe Blacklight::Solr::Repository, :api do
4
4
  subject(:repository) do
5
5
  described_class.new blacklight_config
6
6
  end
@@ -183,7 +183,7 @@ RSpec.describe Blacklight::Solr::Repository, api: true do
183
183
  end
184
184
  end
185
185
 
186
- describe "http_method configuration", integration: true do
186
+ describe "http_method configuration", :integration do
187
187
  let (:blacklight_config) { config = Blacklight::Configuration.new; config.http_method = :post; config }
188
188
 
189
189
  it "sends a post request to solr and get a response back" do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::Request, api: true do
3
+ RSpec.describe Blacklight::Solr::Request, :api do
4
4
  context 'with some solr parameter keys' do
5
5
  before do
6
6
  subject[:qt] = 'hey'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::Response::Facets, api: true do
3
+ RSpec.describe Blacklight::Solr::Response::Facets, :api do
4
4
  describe Blacklight::Solr::Response::Facets::FacetField do
5
5
  describe "A field with default options" do
6
6
  subject(:field) { described_class.new "my_field", [] }
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- RSpec.describe Blacklight::Solr::Response::GroupResponse, api: true do
5
+ RSpec.describe Blacklight::Solr::Response::GroupResponse, :api do
6
6
  let(:response) do
7
7
  create_response(sample_response)
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- RSpec.describe Blacklight::Solr::Response::Group, api: true do
5
+ RSpec.describe Blacklight::Solr::Response::Group, :api do
6
6
  subject do
7
7
  group.groups.first
8
8
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::Response, api: true do
3
+ RSpec.describe Blacklight::Solr::Response, :api do
4
4
  let(:raw_response) { eval(mock_query_response) }
5
5
 
6
6
  let(:config) { Blacklight::Configuration.new }
@@ -1,9 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
3
+ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
4
4
  subject { search_builder.with(user_params) }
5
5
 
6
6
  let(:single_facet) { { format: ['Book'] } }
7
+ let(:search_builder_class) do
8
+ Class.new(Blacklight::SearchBuilder) do
9
+ include Blacklight::Solr::SearchBuilderBehavior
10
+ end
11
+ end
12
+ let(:search_builder) { search_builder_class.new(context) }
7
13
  let(:multi_facets) { { format: ['Book'], language_ssim: ['Tibetan'] } }
8
14
  let(:mult_word_query) { 'tibetan history' }
9
15
  let(:subject_search_params) { { commit: "search", search_field: "subject", action: "index", controller: "catalog", rows: "10", q: "wome" } }
@@ -14,13 +20,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
14
20
 
15
21
  before { allow(context).to receive(:blacklight_config).and_return(blacklight_config) }
16
22
 
17
- let(:search_builder_class) do
18
- Class.new(Blacklight::SearchBuilder) do
19
- include Blacklight::Solr::SearchBuilderBehavior
20
- end
21
- end
22
- let(:search_builder) { search_builder_class.new(context) }
23
-
24
23
  context "with default processor chain" do
25
24
  subject { search_builder }
26
25
 
@@ -117,7 +116,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
117
116
  end
118
117
 
119
118
  it 'is negative' do
120
- expect(subject[:'f.subject_ssim.facet.limit']).to eq -1
119
+ expect(subject[:'f.subject_ssim.facet.limit']).to eq(-1)
121
120
  end
122
121
  end
123
122
 
@@ -522,15 +521,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
522
521
  expect(subject[:qq1]).to eq 'xyz'
523
522
  end
524
523
  end
525
-
526
- describe "mapping facet.field" do
527
- let(:blacklight_config) do
528
- Blacklight::Configuration.new do |config|
529
- config.add_facet_field 'some_field'
530
- config.add_facet_fields_to_solr_request!
531
- end
532
- end
533
- end
534
524
  end
535
525
 
536
526
  describe "#facet_value_to_fq_string" do
@@ -564,7 +554,7 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
564
554
  expect(subject.send(:facet_value_to_fq_string, "facet_name", 1.11)).to eq '{!term f=facet_name}1.11'
565
555
  end
566
556
 
567
- it "passes floats through" do
557
+ it "passes floats in strings through" do
568
558
  expect(subject.send(:facet_value_to_fq_string, "facet_name", "1.11")).to eq '{!term f=facet_name}1.11'
569
559
  end
570
560
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::Suggest::Response, api: true do
3
+ RSpec.describe Blacklight::Suggest::Response, :api do
4
4
  let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest', 'mySuggester') }
5
5
  let(:full_response) do
6
6
  described_class.new(
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::SuggestSearch, api: true do
3
+ RSpec.describe Blacklight::SuggestSearch, :api do
4
4
  let(:params) { { q: 'test' } }
5
5
  let(:response) { instance_double(Blacklight::Suggest::Response) }
6
6
  let(:repository) { instance_double(Blacklight::Solr::Repository, suggestions: response) }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe "Blacklight::User", api: true do
3
+ RSpec.describe "Blacklight::User", :api do
4
4
  subject { User.create! email: 'xyz@example.com', password: 'xyz12345' }
5
5
 
6
6
  def mock_bookmark document_id
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe SolrDocument, api: true do
3
+ RSpec.describe SolrDocument, :api do
4
4
  describe "access methods" do
5
5
  let(:solrdoc) do
6
6
  described_class.new(id: '00282214', format: ['Book'], title_tsim: 'some-title')
@@ -11,8 +11,7 @@ RSpec.describe Blacklight::DocumentPresenter do
11
11
  let(:search_state) { Blacklight::SearchState.new(params, blacklight_config, controller) }
12
12
 
13
13
  before do
14
- allow(request_context).to receive(:search_state).and_return(search_state)
15
- allow(request_context).to receive(:action_name).and_return(:show)
14
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :show)
16
15
  end
17
16
 
18
17
  describe '#fields_to_render' do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::FieldPresenter, api: true do
3
+ RSpec.describe Blacklight::FieldPresenter, :api do
4
4
  subject(:presenter) { described_class.new(request_context, document, field_config, options) }
5
5
 
6
6
  let(:request_context) { double('View context', params: { x: '1' }, search_state: search_state, should_render_field?: true, blacklight_config: config) }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::IndexPresenter, api: true do
3
+ RSpec.describe Blacklight::IndexPresenter, :api do
4
4
  include Capybara::RSpecMatchers
5
5
  subject { presenter }
6
6
 
@@ -21,8 +21,7 @@ RSpec.describe Blacklight::IndexPresenter, api: true do
21
21
  end
22
22
 
23
23
  before do
24
- allow(request_context).to receive(:search_state).and_return(search_state)
25
- allow(request_context).to receive(:action_name).and_return(:index)
24
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :index)
26
25
  end
27
26
 
28
27
  describe '#fields' do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Blacklight::JsonPresenter, api: true do
5
+ RSpec.describe Blacklight::JsonPresenter, :api do
6
6
  let(:response) do
7
7
  instance_double(Blacklight::Solr::Response,
8
8
  documents: docs,
@@ -25,7 +25,7 @@ RSpec.describe Blacklight::Rendering::Pipeline do
25
25
  let(:values) { ['a'] }
26
26
  let(:field_config) { Blacklight::Configuration::NullField.new(itemprop: 'some-prop', separator_options: nil) }
27
27
 
28
- it { is_expected.to have_selector("span[@itemprop='some-prop']", text: "a") }
28
+ it { is_expected.to have_css("span[@itemprop='some-prop']", text: "a") }
29
29
  end
30
30
 
31
31
  it 'sets the operations on the instance as equal to the class variable' do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::ShowPresenter, api: true do
3
+ RSpec.describe Blacklight::ShowPresenter, :api do
4
4
  include Capybara::RSpecMatchers
5
5
  subject { presenter }
6
6
 
@@ -18,8 +18,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
18
18
  end
19
19
 
20
20
  before do
21
- allow(request_context).to receive(:search_state).and_return(search_state)
22
- allow(request_context).to receive(:action_name).and_return(:show)
21
+ allow(request_context).to receive_messages(search_state: search_state, action_name: :show)
23
22
  end
24
23
 
25
24
  describe "link_rel_alternates" do
@@ -64,7 +63,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
64
63
  tmp_value = Capybara.ignore_hidden_elements
65
64
  Capybara.ignore_hidden_elements = false
66
65
  document.export_formats.each_pair do |format, _spec|
67
- expect(subject).to have_selector("link[href$='.#{format}']", count: 1) do |tag|
66
+ expect(subject).to have_css("link[href$='.#{format}']", count: 1) do |tag|
68
67
  expect(tag["rel"]).to eq "alternate"
69
68
  expect(tag["title"]).to eq format.to_s
70
69
  expect(tag["href"]).to eq "url.#{format}"
@@ -82,7 +81,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
82
81
  it "respects unique: true" do
83
82
  tmp_value = Capybara.ignore_hidden_elements
84
83
  Capybara.ignore_hidden_elements = false
85
- expect(subject).to have_selector("link[type='application/weird']", count: 1)
84
+ expect(subject).to have_css("link[type='application/weird']", count: 1)
86
85
  Capybara.ignore_hidden_elements = tmp_value
87
86
  end
88
87
  end
@@ -93,7 +92,7 @@ RSpec.describe Blacklight::ShowPresenter, api: true do
93
92
  it "excludes formats from :exclude" do
94
93
  tmp_value = Capybara.ignore_hidden_elements
95
94
  Capybara.ignore_hidden_elements = false
96
- expect(subject).not_to have_selector("link[href$='.weird_dup']")
95
+ expect(subject).to have_no_css("link[href$='.weird_dup']")
97
96
  Capybara.ignore_hidden_elements = tmp_value
98
97
  end
99
98
  end
@@ -75,10 +75,10 @@ RSpec.describe Blacklight::ThumbnailPresenter do
75
75
  end
76
76
 
77
77
  it "calls the provided thumbnail method" do
78
- expect(view_context).to receive_messages(xyz: "some-thumbnail")
79
78
  allow(view_context).to receive(:link_to_document).with(document, "some-thumbnail", {})
80
79
  .and_return("link")
81
80
  expect(subject).to eq "link"
81
+ expect(view_context).to have_received(:xyz)
82
82
  end
83
83
 
84
84
  context "and url options have :suppress_link" do
@@ -107,8 +107,9 @@ RSpec.describe Blacklight::ThumbnailPresenter do
107
107
  it "creates an image tag from the given field" do
108
108
  allow(document).to receive(:fetch).with(:xyz, nil).and_return("http://example.com/some.jpg")
109
109
  allow(view_context).to receive(:image_tag).with("http://example.com/some.jpg", {}).and_return('<img src="image.jpg">')
110
- expect(view_context).to receive(:link_to_document).with(document, '<img src="image.jpg">', {})
110
+ allow(view_context).to receive(:link_to_document)
111
111
  subject
112
+ expect(view_context).to have_received(:link_to_document).with(document, '<img src="image.jpg">', {})
112
113
  end
113
114
 
114
115
  it "returns nil if no thumbnail is in the document" do
@@ -126,8 +127,9 @@ RSpec.describe Blacklight::ThumbnailPresenter do
126
127
 
127
128
  it "creates an image tag from the given field" do
128
129
  allow(view_context).to receive(:image_tag).with("http://example.com/some.jpg", {}).and_return('<img src="image.jpg">')
129
- expect(view_context).to receive(:link_to_document).with(document, '<img src="image.jpg">', {}).and_return('<a><img></a>')
130
+ allow(view_context).to receive(:link_to_document).and_return('<a><img></a>')
130
131
  expect(presenter.thumbnail_tag).to eq '<a><img></a>'
132
+ expect(view_context).to have_received(:link_to_document).with(document, '<img src="image.jpg">', {})
131
133
  end
132
134
  end
133
135
  end
@@ -30,7 +30,7 @@ RSpec.describe "Routing" do
30
30
  end
31
31
  end
32
32
 
33
- describe "solr_document_path for SolrDocument", test: true do
33
+ describe "solr_document_path for SolrDocument", :test do
34
34
  it "routes correctly" do
35
35
  expect(get: solr_document_path(SolrDocument.new(id: 'asdf'))).to route_to(controller: 'catalog', action: 'show', id: 'asdf')
36
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe Blacklight::FieldRetriever, api: true do
3
+ RSpec.describe Blacklight::FieldRetriever, :api do
4
4
  let(:service) { described_class.new(document, blacklight_field_config) }
5
5
 
6
6
  let(:blacklight_field_config) { Blacklight::Configuration::Field.new(field: 'author_field', highlight: true) }
@@ -8,7 +8,7 @@
8
8
  # to talk with solr and get results)? when we do a document request, does
9
9
  # blacklight code get a single document returned?)
10
10
  #
11
- RSpec.describe Blacklight::SearchService, api: true do
11
+ RSpec.describe Blacklight::SearchService, :api do
12
12
  subject { service }
13
13
 
14
14
  let(:context) { { whatever: :value } }
@@ -17,7 +17,7 @@ RSpec.describe Blacklight::SearchService, api: true do
17
17
  let(:user_params) { {} }
18
18
 
19
19
  let(:blacklight_config) { Blacklight::Configuration.new }
20
- let(:copy_of_catalog_config) { ::CatalogController.blacklight_config.deep_copy }
20
+ let(:copy_of_catalog_config) { CatalogController.blacklight_config.deep_copy }
21
21
  let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config.except(:adapter)) }
22
22
 
23
23
  let(:all_docs_query) { '' }
@@ -49,7 +49,7 @@ RSpec.describe Blacklight::SearchService, api: true do
49
49
  end
50
50
 
51
51
  # SPECS FOR SEARCH RESULTS FOR QUERY
52
- describe 'Search Results', integration: true do
52
+ describe 'Search Results', :integration do
53
53
  let(:blacklight_config) { copy_of_catalog_config }
54
54
 
55
55
  describe 'for a sample query returning results' do
@@ -81,7 +81,7 @@ RSpec.describe Blacklight::SearchService, api: true do
81
81
  end
82
82
  end
83
83
 
84
- describe "for a query returning multiple groups", integration: true do
84
+ describe "for a query returning multiple groups", :integration do
85
85
  let(:blacklight_config) { copy_of_catalog_config }
86
86
  let(:user_params) { { q: all_docs_query } }
87
87
 
@@ -139,7 +139,7 @@ RSpec.describe Blacklight::SearchService, api: true do
139
139
  end # Search Results
140
140
 
141
141
  # SPECS FOR SEARCH RESULTS FOR FACETS
142
- describe 'Facets in Search Results for All Docs Query', integration: true do
142
+ describe 'Facets in Search Results for All Docs Query', :integration do
143
143
  let(:blacklight_config) { copy_of_catalog_config }
144
144
  let(:user_params) { { q: all_docs_query } }
145
145
 
@@ -184,7 +184,7 @@ RSpec.describe Blacklight::SearchService, api: true do
184
184
  end # facet specs
185
185
 
186
186
  # SPECS FOR SEARCH RESULTS FOR PAGING
187
- describe 'Paging', integration: true do
187
+ describe 'Paging', :integration do
188
188
  let(:blacklight_config) { copy_of_catalog_config }
189
189
  let(:user_params) { { q: all_docs_query } }
190
190
 
@@ -276,7 +276,7 @@ RSpec.describe Blacklight::SearchService, api: true do
276
276
  end # page specs
277
277
 
278
278
  # SPECS FOR SINGLE DOCUMENT REQUESTS
279
- describe 'Get Document By Id', integration: true do
279
+ describe 'Get Document By Id', :integration do
280
280
  let(:doc_id) { '2007020969' }
281
281
  let(:bad_id) { 'redrum' }
282
282
 
@@ -299,7 +299,7 @@ RSpec.describe Blacklight::SearchService, api: true do
299
299
  end
300
300
  end
301
301
 
302
- describe 'Get multiple documents By Id', integration: true do
302
+ describe 'Get multiple documents By Id', :integration do
303
303
  let(:doc_id) { '2007020969' }
304
304
  let(:bad_id) { 'redrum' }
305
305
  let(:response) { service.fetch([doc_id]) }
@@ -318,7 +318,7 @@ RSpec.describe Blacklight::SearchService, api: true do
318
318
  end
319
319
 
320
320
  # SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
321
- describe "Searches should return spelling suggestions", integration: true do
321
+ describe "Searches should return spelling suggestions", :integration do
322
322
  context "for just-poor-enough-query term" do
323
323
  let(:user_params) { { q: 'boo' } }
324
324
 
data/spec/spec_helper.rb CHANGED
@@ -28,7 +28,7 @@ Capybara.javascript_driver = :headless_chrome
28
28
 
29
29
  Capybara.register_driver :headless_chrome do |app|
30
30
  Capybara::Selenium::Driver.load_selenium
31
- capabilities = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
31
+ capabilities = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
32
32
  opts.args << '--headless'
33
33
  opts.args << '--disable-gpu'
34
34
  opts.args << '--no-sandbox'
@@ -41,7 +41,7 @@ end
41
41
  # in spec/support/ and its subdirectories.
42
42
  # Blacklight, again, make sure we're looking in the right place for em.
43
43
  # Relative to HERE, NOT to Rails.root, which is off somewhere else.
44
- Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].sort.each { |f| require f }
44
+ Dir[Pathname.new(File.expand_path('support/**/*.rb', __dir__))].each { |f| require f }
45
45
 
46
46
  RSpec.configure do |config|
47
47
  config.disable_monkey_patching!
@@ -6,7 +6,7 @@ module Features
6
6
  def search_for q
7
7
  visit root_path
8
8
  fill_in "q", with: q
9
- click_button 'search'
9
+ click_on 'search'
10
10
  end
11
11
 
12
12
  def position_in_result_page(page, id)
@@ -20,7 +20,7 @@ module Features
20
20
  def number_of_results_for_query(query)
21
21
  visit root_path
22
22
  fill_in "q", with: query
23
- click_button "search"
23
+ click_on "search"
24
24
  get_number_of_results_from_page(page)
25
25
  end
26
26
 
@@ -9,7 +9,7 @@ module Features
9
9
  fill_in 'Email', with: email
10
10
  fill_in 'Password', with: password
11
11
  fill_in 'Password confirmation', with: password
12
- click_button 'Sign up'
12
+ click_on 'Sign up'
13
13
  end
14
14
 
15
15
  def sign_in(login = 'user1')
@@ -20,9 +20,9 @@ module Features
20
20
  fill_in("user_password", with: "password")
21
21
 
22
22
  if has_button? "Sign in"
23
- click_button("Sign in")
23
+ click_on("Sign in")
24
24
  elsif has_button? "Log in"
25
- click_button("Log in")
25
+ click_on("Log in")
26
26
  else
27
27
  raise "Unable to find sign in button"
28
28
  end
@@ -20,13 +20,13 @@ class TestAppGenerator < Rails::Generators::Base
20
20
  options += ' --skip-assets'
21
21
  end
22
22
 
23
- generate 'blacklight:install', options
23
+ generate :'blacklight:install', options
24
24
  end
25
25
 
26
26
  def run_test_support_generator
27
27
  say_status("warning", "GENERATING test_support", :yellow)
28
28
 
29
- generate 'blacklight:test_support'
29
+ generate(:'blacklight:test_support')
30
30
  end
31
31
 
32
32
  def add_local_assets_for_propshaft
@@ -6,10 +6,7 @@ RSpec.describe "catalog/_document" do
6
6
 
7
7
  before do
8
8
  allow(controller).to receive(:controller_name).and_return('test')
9
- allow(view).to receive(:render_grouped_response?).and_return(false)
10
- allow(view).to receive(:blacklight_config).and_return(blacklight_config)
11
- allow(view).to receive(:search_session).and_return({})
12
- allow(view).to receive(:current_search_session).and_return(nil)
9
+ allow(view).to receive_messages(render_grouped_response?: false, blacklight_config: blacklight_config, search_session: {}, current_search_session: nil)
13
10
  allow(view.main_app).to receive(:track_test_path).and_return('/track')
14
11
  assign(:response, instance_double(Blacklight::Solr::Response, start: 20))
15
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe "catalog/_document_list", type: :view do
3
+ RSpec.describe "catalog/_document_list" do
4
4
  let(:view_type) { 'some-view' }
5
5
  let(:view_config) { double(Blacklight::Configuration::ViewConfig) }
6
6
 
@@ -12,6 +12,6 @@ RSpec.describe "catalog/_document_list", type: :view do
12
12
 
13
13
  it "includes a class for the current view" do
14
14
  render(partial: "catalog/document_list", locals: { view_config: view_config })
15
- expect(rendered).to have_selector(".documents-some-view")
15
+ expect(rendered).to have_css(".documents-some-view")
16
16
  end
17
17
  end