blacklight 8.2.2 → 8.4.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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.github/workflows/ruby.yml +60 -62
  4. data/.rubocop.yml +229 -21
  5. data/.rubocop_todo.yml +22 -55
  6. data/Gemfile +2 -10
  7. data/README.md +2 -2
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +5 -1
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  11. data/app/assets/javascripts/blacklight/blacklight.js +5 -1
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  13. data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
  14. data/app/assets/stylesheets/blacklight/_bookmark.scss +30 -0
  15. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +0 -4
  16. data/app/assets/stylesheets/blacklight/_constraints.scss +15 -9
  17. data/app/assets/stylesheets/blacklight/_controls.scss +0 -1
  18. data/app/assets/stylesheets/blacklight/_facets.scss +33 -37
  19. data/app/assets/stylesheets/blacklight/_header.scss +2 -35
  20. data/app/assets/stylesheets/blacklight/_icons.scss +3 -2
  21. data/app/assets/stylesheets/blacklight/_layout.scss +3 -0
  22. data/app/assets/stylesheets/blacklight/_mixins.scss +6 -21
  23. data/app/assets/stylesheets/blacklight/_search_form.scss +3 -8
  24. data/app/assets/stylesheets/blacklight/_search_history.scss +5 -5
  25. data/app/assets/stylesheets/blacklight/_search_results.scss +5 -2
  26. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +16 -10
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  28. data/app/components/blacklight/advanced_search_form_component.rb +6 -0
  29. data/app/components/blacklight/constraint_layout_component.html.erb +2 -9
  30. data/app/components/blacklight/constraint_layout_component.rb +8 -0
  31. data/app/components/blacklight/constraints_component.rb +3 -3
  32. data/app/components/blacklight/document/action_component.rb +2 -1
  33. data/app/components/blacklight/document/bookmark_component.html.erb +2 -1
  34. data/app/components/blacklight/document/bookmark_component.rb +6 -0
  35. data/app/components/blacklight/document/page_header_component.html.erb +7 -0
  36. data/app/components/blacklight/document/page_header_component.rb +85 -0
  37. data/app/components/blacklight/document_component.rb +1 -1
  38. data/app/components/blacklight/facet_component.rb +1 -1
  39. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +1 -1
  40. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  41. data/app/components/blacklight/facet_field_inclusive_constraint_component.html.erb +1 -1
  42. data/app/components/blacklight/facet_field_list_component.html.erb +1 -1
  43. data/app/components/blacklight/facet_item_component.rb +1 -1
  44. data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
  45. data/app/components/blacklight/icons/bookmark_icon_component.rb +17 -0
  46. data/app/components/blacklight/icons/icon_component.rb +9 -4
  47. data/app/components/blacklight/icons/remove_component.rb +16 -0
  48. data/app/components/blacklight/metadata_field_component.html.erb +1 -1
  49. data/app/components/blacklight/metadata_field_component.rb +5 -0
  50. data/app/components/blacklight/response/facet_group_component.rb +1 -1
  51. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  52. data/app/components/blacklight/response/sort_component.html.erb +1 -6
  53. data/app/components/blacklight/response/sort_component.rb +15 -0
  54. data/app/components/blacklight/search/per_page_component.html.erb +2 -0
  55. data/app/components/blacklight/search/per_page_component.rb +50 -0
  56. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  57. data/app/components/blacklight/search_context/server_item_pagination_component.html.erb +4 -7
  58. data/app/components/blacklight/skip_link_component.html.erb +7 -0
  59. data/app/components/blacklight/skip_link_component.rb +17 -0
  60. data/app/components/blacklight/system/dropdown_button_component.rb +18 -0
  61. data/app/components/blacklight/system/dropdown_component.rb +4 -7
  62. data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
  63. data/app/components/blacklight/top_navbar_component.html.erb +2 -2
  64. data/app/components/blacklight/top_navbar_component.rb +4 -0
  65. data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -5
  66. data/app/helpers/blacklight/component_helper_behavior.rb +4 -4
  67. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -0
  68. data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
  69. data/app/javascript/blacklight/checkbox_submit.js +5 -1
  70. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -1
  71. data/app/presenters/blacklight/facet_checkbox_item_presenter.rb +11 -0
  72. data/app/presenters/blacklight/facet_field_presenter.rb +9 -1
  73. data/app/services/blacklight/search_service.rb +9 -1
  74. data/app/views/catalog/_per_page_widget.html.erb +1 -10
  75. data/app/views/catalog/_search_results.html.erb +1 -1
  76. data/app/views/catalog/_show_main_content.html.erb +1 -1
  77. data/app/views/catalog/show.html.erb +0 -2
  78. data/app/views/catalog/suggest.html.erb +1 -1
  79. data/app/views/kaminari/blacklight/_page.html.erb +14 -8
  80. data/app/views/layouts/blacklight/base.html.erb +3 -4
  81. data/app/views/shared/_flash_messages.html.erb +1 -1
  82. data/blacklight.gemspec +4 -0
  83. data/{docker-compose.yml → compose.yaml} +1 -1
  84. data/config/locales/blacklight.ar.yml +3 -0
  85. data/config/locales/blacklight.de.yml +3 -0
  86. data/config/locales/blacklight.en.yml +216 -229
  87. data/config/locales/blacklight.es.yml +3 -0
  88. data/config/locales/blacklight.fr.yml +3 -0
  89. data/config/locales/blacklight.hu.yml +3 -0
  90. data/config/locales/blacklight.it.yml +3 -0
  91. data/config/locales/blacklight.nl.yml +3 -0
  92. data/config/locales/blacklight.pt-BR.yml +3 -0
  93. data/config/locales/blacklight.sq.yml +3 -0
  94. data/config/locales/blacklight.zh.yml +3 -0
  95. data/lib/blacklight/abstract_repository.rb +6 -0
  96. data/lib/blacklight/configuration.rb +33 -19
  97. data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
  98. data/lib/blacklight/parameters.rb +1 -1
  99. data/lib/blacklight/solr/repository.rb +11 -4
  100. data/lib/blacklight/solr/request.rb +1 -1
  101. data/lib/blacklight/solr/response/facets.rb +1 -1
  102. data/lib/blacklight/solr/response/params.rb +1 -1
  103. data/lib/blacklight/solr/response.rb +0 -12
  104. data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
  105. data/lib/blacklight/solr.rb +0 -6
  106. data/lib/blacklight.rb +4 -14
  107. data/lib/generators/blacklight/assets/propshaft_generator.rb +2 -2
  108. data/lib/generators/blacklight/models_generator.rb +1 -1
  109. data/package.json +1 -1
  110. data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
  111. data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
  112. data/spec/components/blacklight/constraints_component_spec.rb +9 -9
  113. data/spec/components/blacklight/document/action_component_spec.rb +1 -1
  114. data/spec/components/blacklight/document/group_component_spec.rb +3 -3
  115. data/spec/components/blacklight/document/page_header_component_spec.rb +92 -0
  116. data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
  117. data/spec/components/blacklight/document_component_spec.rb +41 -25
  118. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  119. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
  120. data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
  121. data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
  122. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
  123. data/spec/components/blacklight/header_component_spec.rb +1 -2
  124. data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
  125. data/spec/components/blacklight/icons/icon_component_spec.rb +42 -0
  126. data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
  127. data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
  128. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
  129. data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +2 -4
  130. data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
  131. data/spec/controllers/blacklight/catalog_spec.rb +2 -2
  132. data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
  133. data/spec/controllers/bookmarks_controller_spec.rb +10 -10
  134. data/spec/controllers/catalog_controller_spec.rb +29 -31
  135. data/spec/features/advanced_search_spec.rb +30 -16
  136. data/spec/features/alternate_controller_spec.rb +9 -9
  137. data/spec/features/axe_spec.rb +4 -4
  138. data/spec/features/bookmarks_spec.rb +34 -19
  139. data/spec/features/citation_spec.rb +1 -1
  140. data/spec/features/did_you_mean_spec.rb +23 -23
  141. data/spec/features/facet_missing_spec.rb +9 -9
  142. data/spec/features/facets_spec.rb +21 -20
  143. data/spec/features/modal_spec.rb +4 -4
  144. data/spec/features/record_view_spec.rb +2 -2
  145. data/spec/features/search_context_spec.rb +6 -6
  146. data/spec/features/search_crawler_spec.rb +5 -5
  147. data/spec/features/search_filters_spec.rb +65 -65
  148. data/spec/features/search_history_spec.rb +12 -12
  149. data/spec/features/search_pagination_spec.rb +10 -10
  150. data/spec/features/search_results_spec.rb +1 -1
  151. data/spec/features/search_sort_spec.rb +4 -4
  152. data/spec/features/search_spec.rb +25 -25
  153. data/spec/features/sitelinks_search_box_spec.rb +2 -2
  154. data/spec/features/sms_spec.rb +1 -1
  155. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +2 -2
  156. data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
  157. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
  158. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
  159. data/spec/helpers/blacklight_helper_spec.rb +13 -15
  160. data/spec/helpers/catalog_helper_spec.rb +3 -6
  161. data/spec/i18n_spec.rb +2 -1
  162. data/spec/lib/blacklight/nested_open_struct_with_hash_access_spec.rb +1 -1
  163. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +1 -1
  164. data/spec/lib/blacklight/search_state_spec.rb +4 -4
  165. data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
  166. data/spec/models/blacklight/configurable_spec.rb +1 -1
  167. data/spec/models/blacklight/configuration/context_spec.rb +1 -1
  168. data/spec/models/blacklight/configuration_spec.rb +14 -14
  169. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
  170. data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
  171. data/spec/models/blacklight/document_spec.rb +1 -1
  172. data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
  173. data/spec/models/blacklight/icon_spec.rb +1 -1
  174. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  175. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  176. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
  177. data/spec/models/blacklight/solr/repository_spec.rb +33 -15
  178. data/spec/models/blacklight/solr/request_spec.rb +1 -1
  179. data/spec/models/blacklight/solr/response/facets_spec.rb +3 -3
  180. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
  181. data/spec/models/blacklight/solr/response/group_spec.rb +2 -2
  182. data/spec/models/blacklight/solr/response_spec.rb +3 -3
  183. data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +10 -20
  184. data/spec/models/blacklight/suggest/response_spec.rb +1 -1
  185. data/spec/models/blacklight/suggest_search_spec.rb +1 -1
  186. data/spec/models/blacklight/user_spec.rb +1 -1
  187. data/spec/models/bookmark_spec.rb +1 -1
  188. data/spec/models/solr_document_spec.rb +1 -1
  189. data/spec/presenters/blacklight/document_presenter_spec.rb +3 -4
  190. data/spec/presenters/blacklight/facet_checkbox_item_presenter_spec.rb +42 -0
  191. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +14 -0
  192. data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
  193. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
  194. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
  195. data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
  196. data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
  197. data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
  198. data/spec/requests/load_suggestions_spec.rb +5 -5
  199. data/spec/routing/catalog_routing_spec.rb +1 -1
  200. data/spec/services/blacklight/field_retriever_spec.rb +1 -1
  201. data/spec/services/blacklight/search_service_spec.rb +11 -11
  202. data/spec/spec_helper.rb +2 -2
  203. data/spec/support/features/search_helpers.rb +2 -2
  204. data/spec/support/features/session_helpers.rb +3 -3
  205. data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -3
  206. data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
  207. data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
  208. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
  209. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
  210. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
  211. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
  212. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
  213. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
  214. data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
  215. data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
  216. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
  217. data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
  218. data/spec/views/catalog/index.html.erb_spec.rb +2 -4
  219. data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
  220. data/spec/views/catalog/show.html.erb_spec.rb +3 -5
  221. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
  222. data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
  223. data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
  224. data/tasks/blacklight.rake +5 -5
  225. metadata +84 -12
@@ -36,12 +36,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
36
36
 
37
37
  before do
38
38
  # Every call to view_context returns a different object. This ensures it stays stable.
39
- allow(controller).to receive(:view_context).and_return(view_context)
40
- allow(controller).to receive(:current_or_guest_user).and_return(User.new)
41
- allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
42
- allow(view_context).to receive(:search_session).and_return({})
43
- allow(view_context).to receive(:current_search_session).and_return(nil)
44
- allow(view_context).to receive(:current_bookmarks).and_return([])
39
+ allow(controller).to receive_messages(view_context: view_context, current_or_guest_user: User.new, blacklight_config: blacklight_config)
40
+ allow(view_context).to receive_messages(search_session: {}, current_search_session: nil, current_bookmarks: [])
45
41
  end
46
42
 
47
43
  it 'has some defined content areas' do
@@ -61,8 +57,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
61
57
  it 'has schema.org properties' do
62
58
  component.set_slot(:body) { '-' }
63
59
 
64
- expect(rendered).to have_selector 'article[@itemtype="http://schema.org/Thing"]'
65
- expect(rendered).to have_selector 'article[@itemscope]'
60
+ expect(rendered).to have_css 'article[@itemtype="http://schema.org/Thing"]'
61
+ expect(rendered).to have_css 'article[@itemscope]'
66
62
  end
67
63
 
68
64
  context 'with a provided body' do
@@ -70,8 +66,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
70
66
  component.set_slot(:body) { 'Body content' }
71
67
 
72
68
  expect(rendered).to have_content 'Body content'
73
- expect(rendered).not_to have_selector 'header'
74
- expect(rendered).not_to have_selector 'dl'
69
+ expect(rendered).to have_no_css 'header'
70
+ expect(rendered).to have_no_css 'dl'
75
71
  end
76
72
  end
77
73
 
@@ -85,8 +81,8 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
85
81
  it 'has data properties' do
86
82
  component.set_slot(:body) { '-' }
87
83
 
88
- expect(rendered).to have_selector 'article[@data-document-id="x"]'
89
- expect(rendered).to have_selector 'article[@data-document-counter="5"]'
84
+ expect(rendered).to have_css 'article[@data-document-id="x"]'
85
+ expect(rendered).to have_css 'article[@data-document-counter="5"]'
90
86
  end
91
87
 
92
88
  it 'renders a linked title' do
@@ -94,7 +90,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
94
90
  end
95
91
 
96
92
  it 'renders a counter with the title' do
97
- expect(rendered).to have_selector 'header', text: '5. Title'
93
+ expect(rendered).to have_css 'header', text: '5. Title'
98
94
  end
99
95
 
100
96
  context 'with a document rendered as part of a collection' do
@@ -104,24 +100,24 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
104
100
 
105
101
  it 'renders a counter with the title' do
106
102
  # after ViewComponent 2.5, collection counter params are 1-indexed
107
- expect(rendered).to have_selector 'header', text: '111. Title'
103
+ expect(rendered).to have_css 'header', text: '111. Title'
108
104
  end
109
105
  end
110
106
 
111
107
  it 'renders actions' do
112
- expect(rendered).to have_selector '.index-document-functions'
108
+ expect(rendered).to have_css '.index-document-functions'
113
109
  end
114
110
 
115
111
  it 'renders a thumbnail' do
116
- expect(rendered).to have_selector 'a[href="/catalog/x"] img[src="http://example.com/image.jpg"]'
112
+ expect(rendered).to have_css 'a[href="/catalog/x"] img[src="http://example.com/image.jpg"]'
117
113
  end
118
114
 
119
115
  context 'with default metadata component' do
120
116
  it 'renders metadata' do
121
- expect(rendered).to have_selector 'dl.document-metadata'
122
- expect(rendered).to have_selector 'dt', text: 'Title:'
123
- expect(rendered).to have_selector 'dd', text: 'Title'
124
- expect(rendered).not_to have_selector 'dt', text: 'ISBN:'
117
+ expect(rendered).to have_css 'dl.document-metadata'
118
+ expect(rendered).to have_css 'dt', text: 'Title:'
119
+ expect(rendered).to have_css 'dd', text: 'Title'
120
+ expect(rendered).to have_no_css 'dt', text: 'ISBN:'
125
121
  end
126
122
  end
127
123
  end
@@ -136,17 +132,17 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
136
132
  it 'renders with an id' do
137
133
  component.set_slot(:body) { '-' }
138
134
 
139
- expect(rendered).to have_selector 'article#document'
135
+ expect(rendered).to have_css 'article#document'
140
136
  end
141
137
 
142
138
  it 'renders a title' do
143
- expect(rendered).to have_selector 'h1', text: 'Title'
139
+ expect(rendered).to have_css 'h1', text: 'Title'
144
140
  end
145
141
 
146
142
  it 'renders with show-specific metadata' do
147
- expect(rendered).to have_selector 'dl.document-metadata'
148
- expect(rendered).to have_selector 'dt', text: 'ISBN:'
149
- expect(rendered).to have_selector 'dd', text: 'Value'
143
+ expect(rendered).to have_css 'dl.document-metadata'
144
+ expect(rendered).to have_css 'dt', text: 'ISBN:'
145
+ expect(rendered).to have_css 'dd', text: 'Value'
150
146
  end
151
147
 
152
148
  it 'renders an embed' do
@@ -162,6 +158,26 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
162
158
  expect(rendered).to have_content 'embed'
163
159
  end
164
160
 
161
+ context 'show view with custom translation' do
162
+ let!(:original_translations) { I18n.backend.send(:translations).deep_dup }
163
+
164
+ before do
165
+ controller.action_name = "show"
166
+ I18n.backend.store_translations(:en, blacklight: { search: { show: { label: "testing:%{label}" } } })
167
+ end
168
+
169
+ after do
170
+ I18n.backend.reload!
171
+ I18n.backend.store_translations(:en, original_translations[:en])
172
+ end
173
+
174
+ it 'renders with show-specific metadata with correct translation' do
175
+ expect(rendered).to have_css 'dl.document-metadata'
176
+ expect(rendered).to have_css 'dt', text: 'testing:ISBN'
177
+ expect(rendered).to have_css 'dd', text: 'Value'
178
+ end
179
+ end
180
+
165
181
  context 'with configured metadata component' do
166
182
  let(:custom_component_class) do
167
183
  Class.new(Blacklight::DocumentMetadataComponent) do
@@ -18,7 +18,7 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
18
18
  let(:facet_config) { Blacklight::Configuration::FacetField.new(key: 'field').normalize! }
19
19
 
20
20
  it 'delegates to the configured component to render something' do
21
- expect(rendered).to have_selector 'ul.facet-values'
21
+ expect(rendered).to have_css 'ul.facet-values'
22
22
  end
23
23
 
24
24
  context 'with a provided component' do
@@ -52,7 +52,7 @@ RSpec.describe Blacklight::FacetComponent, type: :component do
52
52
  before do
53
53
  replace_hash = { 'catalog/_facet_partial.html.erb' => 'facet partial' }
54
54
 
55
- if ::Rails.version.to_f >= 7.1
55
+ if Rails.version.to_f >= 7.1
56
56
  controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
57
57
  else
58
58
  controller.view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
@@ -33,15 +33,15 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
33
33
  let(:params) { { f: { field: ['a'] } } }
34
34
 
35
35
  it 'renders a collapsible card' do
36
- expect(rendered).to have_selector '.card'
36
+ expect(rendered).to have_css '.card'
37
37
  expect(rendered).to have_button 'Field'
38
- expect(rendered).to have_selector 'button[data-bs-target="#facet-field"]'
39
- expect(rendered).to have_selector '#facet-field.collapse.show'
38
+ expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
39
+ expect(rendered).to have_css '#facet-field.collapse.show'
40
40
  end
41
41
 
42
42
  it 'renders the facet items' do
43
- expect(rendered).to have_selector 'ul.facet-values'
44
- expect(rendered).to have_selector 'li', count: 3
43
+ expect(rendered).to have_css 'ul.facet-values'
44
+ expect(rendered).to have_css 'li', count: 3
45
45
 
46
46
  expect(rendered).to have_field 'f_inclusive[field][]', with: 'a'
47
47
  expect(rendered).to have_field 'f_inclusive[field][]', with: 'b'
@@ -31,15 +31,15 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
31
31
  end
32
32
 
33
33
  it 'renders a collapsible card' do
34
- expect(rendered).to have_selector '.card'
34
+ expect(rendered).to have_css '.card'
35
35
  expect(rendered).to have_button 'Field'
36
- expect(rendered).to have_selector 'button[data-bs-target="#facet-field"]'
37
- expect(rendered).to have_selector '#facet-field.collapse.show'
36
+ expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
37
+ expect(rendered).to have_css '#facet-field.collapse.show'
38
38
  end
39
39
 
40
40
  it 'renders the facet items' do
41
- expect(rendered).to have_selector 'ul.facet-values'
42
- expect(rendered).to have_selector 'li', count: 2
41
+ expect(rendered).to have_css 'ul.facet-values'
42
+ expect(rendered).to have_css 'li', count: 2
43
43
  end
44
44
 
45
45
  context 'with an active facet' do
@@ -58,7 +58,7 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
58
58
  end
59
59
 
60
60
  it 'adds the facet-limit-active class' do
61
- expect(rendered).to have_selector 'div.facet-limit-active'
61
+ expect(rendered).to have_css 'div.facet-limit-active'
62
62
  end
63
63
  end
64
64
 
@@ -78,13 +78,13 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
78
78
  end
79
79
 
80
80
  it 'renders a collapsed facet' do
81
- expect(rendered).to have_selector '.facet-content.collapse'
82
- expect(rendered).not_to have_selector '.facet-content.collapse.show'
81
+ expect(rendered).to have_css '.facet-content.collapse'
82
+ expect(rendered).to have_no_css '.facet-content.collapse.show'
83
83
  end
84
84
 
85
85
  it 'renders the toggle button in the collapsed state' do
86
- expect(rendered).to have_selector '.btn.collapsed'
87
- expect(rendered).to have_selector '.btn[aria-expanded="false"]'
86
+ expect(rendered).to have_css '.btn.collapsed'
87
+ expect(rendered).to have_css '.btn[aria-expanded="false"]'
88
88
  end
89
89
  end
90
90
 
@@ -134,11 +134,11 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
134
134
 
135
135
  it 'displays the constraint above the list' do
136
136
  expect(rendered).to have_content 'Any of:'
137
- expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'a'
137
+ expect(rendered).to have_css '.inclusive_or .facet-label', text: 'a'
138
138
  expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=b&f_inclusive%5Bfield%5D%5B%5D=c'
139
- expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'b'
139
+ expect(rendered).to have_css '.inclusive_or .facet-label', text: 'b'
140
140
  expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=c'
141
- expect(rendered).to have_selector '.inclusive_or .facet-label', text: 'c'
141
+ expect(rendered).to have_css '.inclusive_or .facet-label', text: 'c'
142
142
  expect(rendered).to have_link '[remove]', href: 'http://test.host/catalog?f_inclusive%5Bfield%5D%5B%5D=a&f_inclusive%5Bfield%5D%5B%5D=b'
143
143
  end
144
144
  end
@@ -19,11 +19,11 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
19
19
  end
20
20
 
21
21
  it 'links to the facet and shows the number of hits' do
22
- expect(rendered).to have_selector 'li'
22
+ expect(rendered).to have_css 'li'
23
23
  expect(rendered).to have_link 'x', href: '/catalog?f=x' do |link|
24
24
  link['rel'] == 'nofollow'
25
25
  end
26
- expect(rendered).to have_selector '.facet-count', text: '10'
26
+ expect(rendered).to have_css '.facet-count', text: '10'
27
27
  end
28
28
 
29
29
  context 'with a selected facet' do
@@ -39,12 +39,12 @@ RSpec.describe Blacklight::FacetItemComponent, type: :component do
39
39
  end
40
40
 
41
41
  it 'links to the facet and shows the number of hits' do
42
- expect(rendered).to have_selector 'li'
43
- expect(rendered).to have_selector '.selected', text: 'x'
42
+ expect(rendered).to have_css 'li'
43
+ expect(rendered).to have_css '.selected', text: 'x'
44
44
  expect(rendered).to have_link '[remove]', href: '/catalog' do |link|
45
45
  link['rel'] == 'nofollow'
46
46
  end
47
- expect(rendered).to have_selector '.selected.facet-count', text: '10'
47
+ expect(rendered).to have_css '.selected.facet-count', text: '10'
48
48
  end
49
49
  end
50
50
  end
@@ -34,13 +34,13 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
34
34
  let(:facet_config) { Blacklight::Configuration::NullField.new(key: 'z', item_component: Blacklight::FacetItemComponent, item_presenter: Blacklight::FacetItemPivotPresenter) }
35
35
 
36
36
  it 'links to the facet and shows the number of hits' do
37
- expect(rendered).to have_selector 'li'
37
+ expect(rendered).to have_css 'li'
38
38
  expect(rendered).to have_link 'x', href: nokogiri_mediated_href(facet_item.href)
39
- expect(rendered).to have_selector '.facet-count', text: '10'
39
+ expect(rendered).to have_css '.facet-count', text: '10'
40
40
  end
41
41
 
42
42
  it 'has the facet hierarchy' do
43
- expect(rendered).to have_selector 'li ul.pivot-facet'
43
+ expect(rendered).to have_css 'li ul.pivot-facet'
44
44
  expect(rendered).to have_link 'x:1', href: nokogiri_mediated_href(facet_item.facet_item_presenters.first.href)
45
45
  end
46
46
 
@@ -60,10 +60,10 @@ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
60
60
  end
61
61
 
62
62
  it 'links to the facet and shows the number of hits' do
63
- expect(rendered).to have_selector 'li'
64
- expect(rendered).to have_selector '.selected', text: 'x'
63
+ expect(rendered).to have_css 'li'
64
+ expect(rendered).to have_css '.selected', text: 'x'
65
65
  expect(rendered).to have_link '[remove]', href: '/catalog'
66
- expect(rendered).to have_selector '.selected.facet-count', text: '10'
66
+ expect(rendered).to have_css '.selected.facet-count', text: '10'
67
67
  end
68
68
  end
69
69
  end
@@ -3,8 +3,7 @@
3
3
  RSpec.describe Blacklight::HeaderComponent, type: :component do
4
4
  before do
5
5
  with_controller_class(CatalogController) do
6
- allow(controller).to receive(:current_user).and_return(nil)
7
- allow(controller).to receive(:search_action_url).and_return('/search')
6
+ allow(controller).to receive_messages(current_user: nil, search_action_url: '/search')
8
7
  render
9
8
  end
10
9
  end
@@ -13,11 +13,11 @@ RSpec.describe Blacklight::HiddenSearchStateComponent, type: :component do
13
13
  let(:instance) { described_class.new(params: params) }
14
14
 
15
15
  it "converts a hash with nested complex data to Rails-style hidden form fields" do
16
- expect(rendered).to have_selector("input[type='hidden'][name='q'][value='query']", visible: :hidden)
17
- expect(rendered).to have_selector("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
18
- expect(rendered).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
19
- expect(rendered).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
20
- expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
21
- expect(rendered).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
16
+ expect(rendered).to have_css("input[type='hidden'][name='q'][value='query']", visible: :hidden)
17
+ expect(rendered).to have_css("input[type='hidden'][name='per_page'][value='10']", visible: :hidden)
18
+ expect(rendered).to have_css("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']", visible: :hidden)
19
+ expect(rendered).to have_css("input[type='hidden'][name='f[field2][]'][value='z']", visible: :hidden)
20
+ expect(rendered).to have_css("input[type='hidden'][name='f[field1][]'][value='a']", visible: :hidden)
21
+ expect(rendered).to have_css("input[type='hidden'][name='f[field1][]'][value='b']", visible: :hidden)
22
22
  end
23
23
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::Icons::IconComponent, type: :component do
6
+ subject(:component) { sub_component.new }
7
+
8
+ let(:sub_component) do
9
+ Class.new(described_class) do
10
+ def self.name
11
+ 'TestIconComponent'
12
+ end
13
+ end
14
+ end
15
+
16
+ context 'when no classes are passed in' do
17
+ subject(:component) { sub_component.new }
18
+
19
+ it "renders component" do
20
+ render_inline(component)
21
+ expect(page).to have_css "span[class='blacklight-icons blacklight-icons-test_icon']"
22
+ end
23
+ end
24
+
25
+ context 'when classes are passed in' do
26
+ subject(:component) { sub_component.new(classes: 'my-icon') }
27
+
28
+ it "renders component" do
29
+ render_inline(component)
30
+ expect(page).to have_css "span[class='my-icon blacklight-icons blacklight-icons-test_icon']"
31
+ end
32
+ end
33
+
34
+ context 'when name is passed in' do
35
+ subject(:component) { sub_component.new(name: 'my-icon') }
36
+
37
+ it "renders component" do
38
+ render_inline(component)
39
+ expect(page).to have_css "span[class='blacklight-icons blacklight-icons-my-icon']"
40
+ end
41
+ end
42
+ end
@@ -16,11 +16,11 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
16
16
  end
17
17
 
18
18
  it 'renders the field label' do
19
- expect(rendered).to have_selector 'dt.blacklight-field', text: 'Field label'
19
+ expect(rendered).to have_css 'dt.blacklight-field', text: 'Field label'
20
20
  end
21
21
 
22
22
  it 'renders the field value' do
23
- expect(rendered).to have_selector 'dd.blacklight-field', text: 'Value'
23
+ expect(rendered).to have_css 'dd.blacklight-field', text: 'Value'
24
24
  end
25
25
 
26
26
  context 'from a show view' do
@@ -31,7 +31,7 @@ RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
31
31
  it 'renders the right field label' do
32
32
  allow(field).to receive(:label).with('show').and_return('custom label')
33
33
 
34
- expect(rendered).to have_selector 'dt.blacklight-field', text: 'custom label'
34
+ expect(rendered).to have_css 'dt.blacklight-field', text: 'custom label'
35
35
  end
36
36
  end
37
37
  end
@@ -18,10 +18,10 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
18
18
  before { render }
19
19
 
20
20
  it "has links to deep pages" do
21
- expect(page).not_to have_link '98'
21
+ expect(page).to have_no_link '98'
22
22
  expect(page).to have_link '99'
23
23
  expect(page).to have_link '100'
24
- expect(page).not_to have_link '101'
24
+ expect(page).to have_no_link '101'
25
25
  end
26
26
  end
27
27
 
@@ -32,7 +32,7 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
32
32
 
33
33
  it "does not link to deep pages" do
34
34
  expect(page).to have_link '1'
35
- expect(page).not_to have_link '100'
35
+ expect(page).to have_no_link '100'
36
36
  end
37
37
  end
38
38
 
@@ -46,7 +46,7 @@ RSpec.describe Blacklight::Response::PaginationComponent, type: :component do
46
46
 
47
47
  it "does not link to deep pages" do
48
48
  expect(page).to have_link '1'
49
- expect(page).not_to have_link '100'
49
+ expect(page).to have_no_link '100'
50
50
  end
51
51
  end
52
52
  end
@@ -15,7 +15,7 @@ RSpec.describe Blacklight::SearchContext::ServerAppliedParamsComponent, type: :c
15
15
  # https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
16
16
  # https://github.com/rspec/rspec-rails/issues/2696
17
17
  replace_hash = { 'application/_start_over.html.erb' => 'start over' }
18
- if ::Rails.version.to_f >= 7.1
18
+ if Rails.version.to_f >= 7.1
19
19
  controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
20
20
  else
21
21
  view_context.view_paths.unshift(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
@@ -30,14 +30,12 @@ RSpec.describe Blacklight::SearchContext::ServerItemPaginationComponent, type: :
30
30
 
31
31
  before do
32
32
  # allow(controller).to receive(:controller_tracking_method).and_return('track_catalog_path')
33
- allow(controller).to receive(:controller_name).and_return('catalog')
34
33
 
35
- allow(controller).to receive(:link_to_previous_document).and_return('')
36
- allow(controller).to receive(:link_to_next_document).and_return('')
34
+ allow(controller).to receive_messages(controller_name: 'catalog', link_to_previous_document: '', link_to_next_document: '')
37
35
  end
38
36
 
39
37
  it "renders content" do
40
- expect(render.css('.pagination-search-widgets').to_html).not_to be_blank
38
+ expect(render.css('.search-context.page-links').to_html).not_to be_blank
41
39
  end
42
40
 
43
41
  context "session and document are out of sync" do
@@ -17,14 +17,14 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
17
17
  let(:type) { 'whatever' }
18
18
 
19
19
  it 'renders a message inside an alert' do
20
- expect(rendered).to have_selector 'div.alert.alert-whatever', text: message
20
+ expect(rendered).to have_css 'div.alert.alert-whatever', text: message
21
21
  end
22
22
 
23
23
  context 'with a success message' do
24
24
  let(:type) { 'success' }
25
25
 
26
26
  it 'adds some styling' do
27
- expect(rendered).to have_selector 'div.alert-success'
27
+ expect(rendered).to have_css 'div.alert-success'
28
28
  end
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
32
32
  let(:type) { 'notice' }
33
33
 
34
34
  it 'adds some styling' do
35
- expect(rendered).to have_selector 'div.alert-info'
35
+ expect(rendered).to have_css 'div.alert-info'
36
36
  end
37
37
  end
38
38
 
@@ -40,7 +40,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
40
40
  let(:type) { 'alert' }
41
41
 
42
42
  it 'adds some styling' do
43
- expect(rendered).to have_selector 'div.alert-warning'
43
+ expect(rendered).to have_css 'div.alert-warning'
44
44
  end
45
45
  end
46
46
 
@@ -48,7 +48,7 @@ RSpec.describe Blacklight::System::FlashMessageComponent, type: :component do
48
48
  let(:type) { 'error' }
49
49
 
50
50
  it 'adds some styling' do
51
- expect(rendered).to have_selector 'div.alert-danger'
51
+ expect(rendered).to have_css 'div.alert-danger'
52
52
  end
53
53
  end
54
54
  end
@@ -8,7 +8,7 @@ RSpec.describe Blacklight::Catalog do
8
8
  describe "#search_state" do
9
9
  subject { controller.send(:search_state) }
10
10
 
11
- let(:raw_params) { HashWithIndifferentAccess.new a: 1 }
11
+ let(:raw_params) { ActiveSupport::HashWithIndifferentAccess.new a: 1 }
12
12
  let(:params) { ActionController::Parameters.new raw_params }
13
13
 
14
14
  before do
@@ -17,7 +17,7 @@ RSpec.describe Blacklight::Catalog do
17
17
  end
18
18
 
19
19
  it "creates a path object" do
20
- expect(subject).to be_kind_of Blacklight::SearchState
20
+ expect(subject).to be_a Blacklight::SearchState
21
21
  expect(subject.params).to eq raw_params
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe CatalogController do
3
+ RSpec.describe Blacklight::Configurable do
4
4
  subject do
5
5
  Class.new do
6
6
  include Blacklight::Configurable
@@ -15,8 +15,8 @@ RSpec.describe BookmarksController do
15
15
  it "has a 200 status code when creating a new one" do
16
16
  put :update, xhr: true, params: { id: '2007020969', format: :js }
17
17
  expect(response).to be_successful
18
- expect(response.code).to eq "200"
19
- expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 1
18
+ expect(response).to have_http_status :ok
19
+ expect(response.parsed_body["bookmarks"]["count"]).to eq 1
20
20
  end
21
21
 
22
22
  it "has a 500 status code when create is not success" do
@@ -26,7 +26,7 @@ RSpec.describe BookmarksController do
26
26
  allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :create!).and_raise(ActiveRecord::RecordInvalid)
27
27
  allow(@controller).to receive_message_chain(:current_or_guest_user, :errors, :full_messages).and_return([1])
28
28
  put :update, xhr: true, params: { id: 'iamabooboo', format: :js }
29
- expect(response.code).to eq "500"
29
+ expect(response).to have_http_status :internal_server_error
30
30
  end
31
31
  end
32
32
 
@@ -44,8 +44,8 @@ RSpec.describe BookmarksController do
44
44
  }
45
45
 
46
46
  expect(response).to be_successful
47
- expect(response.code).to eq "200"
48
- expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 3
47
+ expect(response).to have_http_status :ok
48
+ expect(response.parsed_body["bookmarks"]["count"]).to eq 3
49
49
  end
50
50
  end
51
51
 
@@ -58,8 +58,8 @@ RSpec.describe BookmarksController do
58
58
  it "has a 200 status code when delete is success" do
59
59
  delete :destroy, xhr: true, params: { id: '2007020969', format: :js }
60
60
  expect(response).to be_successful
61
- expect(response.code).to eq "200"
62
- expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 0
61
+ expect(response).to have_http_status :ok
62
+ expect(response.parsed_body["bookmarks"]["count"]).to eq 0
63
63
  end
64
64
 
65
65
  it "can handle bookmark deletion via :bookmarks param" do
@@ -74,8 +74,8 @@ RSpec.describe BookmarksController do
74
74
  format: :js
75
75
  }
76
76
  expect(response).to be_successful
77
- expect(response.code).to eq "200"
78
- expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 0
77
+ expect(response).to have_http_status :ok
78
+ expect(response.parsed_body["bookmarks"]["count"]).to eq 0
79
79
  end
80
80
 
81
81
  it "has a 500 status code when delete is not success" do
@@ -85,7 +85,7 @@ RSpec.describe BookmarksController do
85
85
 
86
86
  delete :destroy, xhr: true, params: { id: 'pleasekillme', format: :js }
87
87
 
88
- expect(response.code).to eq "500"
88
+ expect(response).to have_http_status :internal_server_error
89
89
  end
90
90
  end
91
91