blacklight 9.0.0 → 9.1.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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.env +3 -3
  3. data/.github/matrix.json +12 -18
  4. data/.github/workflows/lint.yml +1 -1
  5. data/.github/workflows/test.yml +4 -3
  6. data/.rubocop.yml +72 -7
  7. data/.rubocop_todo.yml +142 -268
  8. data/Gemfile +1 -1
  9. data/README.md +2 -9
  10. data/VERSION +1 -1
  11. data/app/assets/builds/blacklight.css +37 -23
  12. data/app/assets/images/blacklight/logo-dark.svg +184 -0
  13. data/app/assets/images/blacklight/logo.svg +184 -0
  14. data/app/assets/javascripts/blacklight/blacklight.esm.js +128 -45
  15. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  16. data/app/assets/javascripts/blacklight/blacklight.js +128 -45
  17. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  18. data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -1
  19. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +17 -0
  20. data/app/assets/stylesheets/blacklight/_constraints.scss +2 -2
  21. data/app/assets/stylesheets/blacklight/_facets.scss +14 -10
  22. data/app/assets/stylesheets/blacklight/_header.scss +0 -4
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +5 -9
  24. data/app/components/blacklight/facets/inclusive_constraint_component.html.erb +1 -1
  25. data/app/components/blacklight/icons/checkmark_component.rb +16 -0
  26. data/app/components/blacklight/icons/circle_half_component.rb +16 -0
  27. data/app/components/blacklight/icons/moon_stars_component.rb +17 -0
  28. data/app/components/blacklight/icons/sun_component.rb +16 -0
  29. data/app/components/blacklight/metadata_field_component.rb +1 -1
  30. data/app/components/blacklight/search_navbar_component.html.erb +1 -1
  31. data/app/components/blacklight/theme_switcher_component.html.erb +31 -0
  32. data/app/components/blacklight/theme_switcher_component.rb +6 -0
  33. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  34. data/app/controllers/concerns/blacklight/bookmarks.rb +8 -14
  35. data/app/controllers/concerns/blacklight/catalog.rb +9 -10
  36. data/app/controllers/concerns/blacklight/controller.rb +54 -11
  37. data/app/controllers/concerns/blacklight/guest_user.rb +51 -0
  38. data/app/controllers/concerns/blacklight/search_context.rb +1 -1
  39. data/app/controllers/concerns/blacklight/search_history.rb +3 -1
  40. data/app/controllers/concerns/blacklight/searchable.rb +18 -0
  41. data/app/helpers/blacklight/layout_helper_behavior.rb +7 -0
  42. data/app/javascript/blacklight-frontend/color_theme_switcher.js +85 -0
  43. data/app/javascript/blacklight-frontend/index.js +2 -0
  44. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -2
  45. data/app/models/concerns/blacklight/document.rb +1 -1
  46. data/app/models/concerns/blacklight/user.rb +36 -0
  47. data/app/presenters/blacklight/field_presenter.rb +1 -1
  48. data/app/presenters/blacklight/rendering/microdata.rb +1 -0
  49. data/app/services/blacklight/bookmarks_search_builder.rb +4 -4
  50. data/app/services/blacklight/search_service.rb +46 -33
  51. data/app/values/blacklight/types.rb +1 -1
  52. data/app/views/catalog/_email_form.html.erb +3 -3
  53. data/app/views/catalog/_home_text.html.erb +1 -1
  54. data/app/views/catalog/_sms_form.html.erb +4 -4
  55. data/app/views/catalog/index.rss.builder +4 -4
  56. data/app/views/catalog/opensearch.json.jbuilder +3 -0
  57. data/app/views/catalog/opensearch.xml.builder +2 -2
  58. data/app/views/layouts/blacklight/base.html.erb +13 -1
  59. data/app/views/shared/_user_util_links.html.erb +18 -5
  60. data/blacklight.gemspec +3 -3
  61. data/config/locales/blacklight.ar.yml +5 -0
  62. data/config/locales/blacklight.ca.yml +5 -0
  63. data/config/locales/blacklight.de.yml +6 -2
  64. data/config/locales/blacklight.en.yml +5 -0
  65. data/config/locales/blacklight.es.yml +5 -0
  66. data/config/locales/blacklight.fr.yml +5 -0
  67. data/config/locales/blacklight.hu.yml +5 -0
  68. data/config/locales/blacklight.it.yml +6 -2
  69. data/config/locales/blacklight.nl.yml +5 -0
  70. data/config/locales/blacklight.pt-BR.yml +6 -2
  71. data/config/locales/blacklight.sq.yml +5 -0
  72. data/config/locales/blacklight.zh.yml +5 -0
  73. data/lib/blacklight/component.rb +1 -1
  74. data/lib/blacklight/configuration/action_config_map_entry.rb +31 -0
  75. data/lib/blacklight/configuration/display_field.rb +1 -0
  76. data/lib/blacklight/configuration/field.rb +6 -6
  77. data/lib/blacklight/configuration/fields.rb +1 -1
  78. data/lib/blacklight/configuration/sort_field.rb +2 -2
  79. data/lib/blacklight/configuration.rb +30 -19
  80. data/lib/blacklight/parameters.rb +1 -1
  81. data/lib/blacklight/search_builder.rb +58 -19
  82. data/lib/blacklight/search_state.rb +4 -0
  83. data/lib/blacklight/solr/request.rb +8 -1
  84. data/lib/blacklight/solr/response/group_response.rb +1 -1
  85. data/lib/blacklight/solr/response/spelling.rb +8 -8
  86. data/lib/blacklight/solr/response.rb +2 -21
  87. data/lib/blacklight/solr/search_builder_behavior.rb +3 -9
  88. data/lib/blacklight.rb +2 -2
  89. data/lib/generators/blacklight/assets/importmap_generator.rb +2 -2
  90. data/lib/generators/blacklight/assets_generator.rb +1 -1
  91. data/lib/generators/blacklight/controller_generator.rb +1 -1
  92. data/lib/generators/blacklight/document_generator.rb +1 -1
  93. data/lib/generators/blacklight/install_generator.rb +6 -4
  94. data/lib/generators/blacklight/models_generator.rb +1 -1
  95. data/lib/generators/blacklight/search_builder_generator.rb +1 -1
  96. data/lib/generators/blacklight/solr_generator.rb +1 -1
  97. data/lib/generators/blacklight/templates/catalog_controller.rb +20 -1
  98. data/lib/generators/blacklight/templates/solr/conf/schema.xml +264 -178
  99. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +6 -14
  100. data/lib/generators/blacklight/test_support_generator.rb +1 -1
  101. data/lib/generators/blacklight/user_generator.rb +66 -5
  102. data/lib/railties/blacklight.rake +4 -4
  103. data/package.json +2 -2
  104. data/spec/components/blacklight/document/action_component_spec.rb +1 -1
  105. data/spec/components/blacklight/document/group_component_spec.rb +1 -1
  106. data/spec/components/blacklight/document_component_spec.rb +9 -9
  107. data/spec/components/blacklight/facet_component_spec.rb +2 -2
  108. data/spec/components/blacklight/facets/index_navigation_component_spec.rb +1 -2
  109. data/spec/components/blacklight/facets/list_component_spec.rb +1 -1
  110. data/spec/components/blacklight/facets/suggest_component_spec.rb +1 -2
  111. data/spec/components/blacklight/metadata_field_component_spec.rb +26 -0
  112. data/spec/components/blacklight/skip_link_component_spec.rb +2 -2
  113. data/spec/controllers/application_controller_spec.rb +71 -0
  114. data/spec/controllers/bookmarks_controller_spec.rb +18 -5
  115. data/spec/controllers/catalog_controller_spec.rb +7 -5
  116. data/spec/features/advanced_search_spec.rb +29 -16
  117. data/spec/features/alternate_controller_spec.rb +4 -4
  118. data/spec/features/axe_spec.rb +34 -22
  119. data/spec/features/bookmarks_spec.rb +13 -13
  120. data/spec/features/dark_mode_spec.rb +42 -0
  121. data/spec/features/did_you_mean_spec.rb +27 -27
  122. data/spec/features/facet_missing_spec.rb +3 -3
  123. data/spec/features/record_view_spec.rb +14 -14
  124. data/spec/features/search_context_spec.rb +8 -8
  125. data/spec/features/search_filters_spec.rb +16 -16
  126. data/spec/features/search_formats_spec.rb +2 -2
  127. data/spec/features/search_history_spec.rb +11 -11
  128. data/spec/features/search_pagination_spec.rb +17 -17
  129. data/spec/features/search_results_spec.rb +3 -3
  130. data/spec/features/search_sort_spec.rb +4 -4
  131. data/spec/features/search_spec.rb +20 -20
  132. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +15 -15
  133. data/spec/helpers/blacklight_helper_spec.rb +1 -1
  134. data/spec/helpers/catalog_helper_spec.rb +7 -7
  135. data/spec/integration/generators/blacklight/user_generator_spec.rb +60 -0
  136. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
  137. data/spec/models/blacklight/configurable_spec.rb +1 -1
  138. data/spec/models/blacklight/configuration_spec.rb +0 -19
  139. data/spec/models/blacklight/document/dublin_core_spec.rb +2 -2
  140. data/spec/models/blacklight/facet_paginator_spec.rb +1 -1
  141. data/spec/models/blacklight/search_builder_spec.rb +15 -3
  142. data/spec/models/blacklight/solr/repository_spec.rb +10 -2
  143. data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +3 -5
  144. data/spec/models/blacklight/user_spec.rb +32 -5
  145. data/spec/models/bookmark_spec.rb +1 -1
  146. data/spec/models/record_mailer_spec.rb +8 -8
  147. data/spec/models/search_spec.rb +1 -1
  148. data/spec/models/solr_document_spec.rb +4 -0
  149. data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
  150. data/spec/presenters/blacklight/rendering/pipeline_spec.rb +1 -0
  151. data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
  152. data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +1 -0
  153. data/spec/services/blacklight/search_service_spec.rb +7 -7
  154. data/spec/spec_helper.rb +3 -12
  155. data/spec/support/features/session_helpers.rb +13 -4
  156. data/spec/support/features/turbo_helpers.rb +13 -0
  157. data/spec/support/features.rb +2 -0
  158. data/spec/support/user_helpers.rb +24 -0
  159. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  160. data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
  161. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
  162. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +5 -5
  163. data/spec/views/catalog/index.html.erb_spec.rb +2 -2
  164. data/spec/views/catalog/show.html.erb_spec.rb +3 -4
  165. data/spec/views/shared/_user_util_links.html.erb_spec.rb +56 -0
  166. data/template.demo.rb +2 -1
  167. metadata +30 -22
  168. data/.hound.yml +0 -4
  169. data/.jshintrc +0 -22
  170. data/app/assets/images/blacklight/logo.png +0 -0
@@ -7,7 +7,7 @@ RSpec.describe "Facets" do
7
7
  click_on "Tibetan"
8
8
  end
9
9
  within "#sortAndPerPage" do
10
- expect(page).to have_content "1 - 6 of 6"
10
+ expect(page).to have_text "1 - 6 of 6"
11
11
  end
12
12
 
13
13
  expect(page).to have_css(".blacklight-language_ssim")
@@ -21,8 +21,8 @@ RSpec.describe "Facets" do
21
21
  within "#facet-subject_geo_ssim" do
22
22
  click_on "India"
23
23
  end
24
- within ("#sortAndPerPage") do
25
- expect(page).to have_content "1 - 2 of 2"
24
+ within("#sortAndPerPage") do
25
+ expect(page).to have_text "1 - 2 of 2"
26
26
  end
27
27
  within "#facet-language_ssim" do
28
28
  expect(page).to have_css("span.selected", text: "Tibetan")
@@ -38,29 +38,29 @@ RSpec.describe "Facets" do
38
38
  visit root_path
39
39
  fill_in "q", with: 'history'
40
40
  click_on 'search'
41
- within ("#sortAndPerPage") do
42
- expect(page).to have_content "1 - 10 of 11"
41
+ within("#sortAndPerPage") do
42
+ expect(page).to have_text "1 - 10 of 11"
43
43
  end
44
44
 
45
45
  within "#facet-language_ssim" do
46
46
  click_on "Tibetan"
47
47
  end
48
- within ("#sortAndPerPage") do
49
- expect(page).to have_content "1 - 2 of 2"
48
+ within("#sortAndPerPage") do
49
+ expect(page).to have_text "1 - 2 of 2"
50
50
  end
51
51
  within "#facet-language_ssim" do
52
52
  expect(page).to have_css("span.selected", text: "Tibetan")
53
53
  expect(page).to have_css("span.facet-count.selected", text: "2")
54
54
  end
55
55
  within "#appliedParams" do
56
- expect(page).to have_content "Your selections:"
57
- expect(page).to have_content "history"
56
+ expect(page).to have_text "Your selections:"
57
+ expect(page).to have_text "history"
58
58
  end
59
59
 
60
60
  click_on "2004"
61
61
 
62
- within ("#sortAndPerPage") do
63
- expect(page).to have_content "1 entry found"
62
+ within("#sortAndPerPage") do
63
+ expect(page).to have_text "1 entry found"
64
64
  end
65
65
  within "#facet-language_ssim" do
66
66
  expect(page).to have_css("span.selected", text: "Tibetan")
@@ -85,7 +85,7 @@ RSpec.describe "Facets" do
85
85
  click_on 'remove'
86
86
  end
87
87
  expect(page).to have_no_link 'remove'
88
- expect(page).to have_content('Welcome!')
88
+ expect(page).to have_text('Welcome!')
89
89
  end
90
90
 
91
91
  it "retains filters when you change the search term" do
@@ -140,8 +140,8 @@ RSpec.describe "Facets" do
140
140
  expect(page).to have_css("span.facet-count.selected", text: "2")
141
141
  end
142
142
  within "#appliedParams" do
143
- expect(page).to have_content "Your selections:"
144
- expect(page).to have_content "history"
143
+ expect(page).to have_text "Your selections:"
144
+ expect(page).to have_text "history"
145
145
  end
146
146
  end
147
147
 
@@ -164,8 +164,8 @@ RSpec.describe "Facets" do
164
164
  expect(page).to have_css("span.facet-count.selected", text: "2")
165
165
  end
166
166
  within "#appliedParams" do
167
- expect(page).to have_content "Your selections:"
168
- expect(page).to have_content "history"
167
+ expect(page).to have_text "Your selections:"
168
+ expect(page).to have_text "history"
169
169
  end
170
170
  end
171
171
 
@@ -3,13 +3,13 @@
3
3
  RSpec.describe "Search Formats" do
4
4
  it "has an RSS XML response" do
5
5
  visit "/catalog.rss?q="
6
- expect(page).to have_content "Blacklight Search Results"
6
+ expect(page).to have_text "Blacklight Search Results"
7
7
  expect(page).to have_xpath('//item', count: 10)
8
8
  end
9
9
 
10
10
  it "has an ATOM XML response" do
11
11
  visit "/catalog.atom?q="
12
- expect(page).to have_content "Blacklight Search Results"
12
+ expect(page).to have_text "Blacklight Search Results"
13
13
 
14
14
  expect(page).to have_xpath('//entry', count: 10)
15
15
  end
@@ -5,8 +5,8 @@ RSpec.describe "Search History Page" do
5
5
  it "has a link to the history page" do
6
6
  visit root_path
7
7
  click_on 'History'
8
- expect(page).to have_content 'Search History'
9
- expect(page).to have_content 'You have no search history'
8
+ expect(page).to have_text 'Search History'
9
+ expect(page).to have_text 'You have no search history'
10
10
  end
11
11
  end
12
12
 
@@ -19,15 +19,15 @@ RSpec.describe "Search History Page" do
19
19
  end
20
20
 
21
21
  it "shows searches" do
22
- expect(page).to have_content 'Your recent searches'
23
- expect(page).to have_content 'book'
24
- expect(page).to have_no_content 'dang'
22
+ expect(page).to have_text 'Your recent searches'
23
+ expect(page).to have_text 'book'
24
+ expect(page).to have_no_text 'dang'
25
25
  visit root_path
26
26
  fill_in "q", with: 'dang'
27
27
  click_on 'search'
28
28
  click_on 'History'
29
- expect(page).to have_content 'book'
30
- expect(page).to have_content 'dang'
29
+ expect(page).to have_text 'book'
30
+ expect(page).to have_text 'dang'
31
31
  end
32
32
  end
33
33
 
@@ -43,10 +43,10 @@ RSpec.describe "Search History Page" do
43
43
 
44
44
  it "is able to clear the history" do
45
45
  click_on "Clear Search History"
46
- expect(page).to have_content 'Cleared your search history.'
47
- expect(page).to have_content 'You have no search history'
48
- expect(page).to have_no_content 'book'
49
- expect(page).to have_no_content 'dang'
46
+ expect(page).to have_text 'Cleared your search history.'
47
+ expect(page).to have_text 'You have no search history'
48
+ expect(page).to have_no_text 'book'
49
+ expect(page).to have_no_text 'dang'
50
50
  end
51
51
  end
52
52
  end
@@ -5,8 +5,8 @@ RSpec.describe "Search Pagination" do
5
5
  visit root_path
6
6
  fill_in "q", with: ''
7
7
  click_on 'search'
8
- within ("#sortAndPerPage") do
9
- expect(page).to have_content "1 - 10 of "
8
+ within("#sortAndPerPage") do
9
+ expect(page).to have_text "1 - 10 of "
10
10
  within '#per_page-dropdown' do
11
11
  expect(page).to have_link('10')
12
12
  expect(page).to have_link('20')
@@ -18,11 +18,11 @@ RSpec.describe "Search Pagination" do
18
18
  click_on "Next »"
19
19
  end
20
20
  within "#sortAndPerPage" do
21
- expect(page).to have_content "11 - 20 of "
21
+ expect(page).to have_text "11 - 20 of "
22
22
  click_on "« Previous"
23
23
  end
24
24
  within "#sortAndPerPage" do
25
- expect(page).to have_content "1 - 10 of "
25
+ expect(page).to have_text "1 - 10 of "
26
26
  end
27
27
  end
28
28
 
@@ -30,15 +30,15 @@ RSpec.describe "Search Pagination" do
30
30
  visit root_path
31
31
  fill_in "q", with: ''
32
32
  click_on 'search'
33
- within ("#sortAndPerPage") do
34
- expect(page).to have_content "1 - 10 of "
33
+ within("#sortAndPerPage") do
34
+ expect(page).to have_text "1 - 10 of "
35
35
  end
36
36
 
37
- within ("#per_page-dropdown") do
37
+ within("#per_page-dropdown") do
38
38
  click_on '20'
39
39
  end
40
- within ("#sortAndPerPage") do
41
- expect(page).to have_content "1 - 20 of "
40
+ within("#sortAndPerPage") do
41
+ expect(page).to have_text "1 - 20 of "
42
42
  end
43
43
  end
44
44
 
@@ -60,18 +60,18 @@ RSpec.describe "Search Pagination" do
60
60
  visit root_path
61
61
  fill_in "q", with: ''
62
62
  click_on 'search'
63
- within ("#sortAndPerPage") do
64
- expect(page).to have_content "1 - 15 of "
63
+ within("#sortAndPerPage") do
64
+ expect(page).to have_text "1 - 15 of "
65
65
  within '#per_page-dropdown' do
66
66
  expect(page).to have_link('15')
67
67
  expect(page).to have_link('30')
68
68
  end
69
69
  end
70
- within ("#per_page-dropdown") do
70
+ within("#per_page-dropdown") do
71
71
  click_on '30'
72
72
  end
73
- within ("#sortAndPerPage") do
74
- expect(page).to have_content "1 - 30 of "
73
+ within("#sortAndPerPage") do
74
+ expect(page).to have_text "1 - 30 of "
75
75
  end
76
76
  end
77
77
  end
@@ -84,13 +84,13 @@ RSpec.describe "Search Pagination" do
84
84
  click_on "Next »"
85
85
  end
86
86
  within "#sortAndPerPage" do
87
- expect(page).to have_content "11 - 20 of "
87
+ expect(page).to have_text "11 - 20 of "
88
88
  end
89
- within ("#per_page-dropdown") do
89
+ within("#per_page-dropdown") do
90
90
  click_on '20'
91
91
  end
92
92
  within "#sortAndPerPage" do
93
- expect(page).to have_content "1 - 20 of "
93
+ expect(page).to have_text "1 - 20 of "
94
94
  end
95
95
  end
96
96
  end
@@ -44,7 +44,7 @@ RSpec.describe "Search Results" do
44
44
 
45
45
  it "provides search hints if there are no results" do
46
46
  search_for 'asdfghj'
47
- expect(page).to have_content "No results found for your search"
47
+ expect(page).to have_text "No results found for your search"
48
48
  end
49
49
 
50
50
  it "provides search hints if there are no results" do
@@ -52,8 +52,8 @@ RSpec.describe "Search Results" do
52
52
  fill_in "q", with: "inmul"
53
53
  select "Author", from: "search_field"
54
54
  click_on 'search'
55
- expect(page).to have_content "No results found for your search"
56
- expect(page).to have_content "you searched by Author"
55
+ expect(page).to have_text "No results found for your search"
56
+ expect(page).to have_text "you searched by Author"
57
57
  click_on "try searching everything"
58
58
  expect(page).to have_xpath("//a[contains(@href, 77826928)]")
59
59
  end
@@ -6,17 +6,17 @@ RSpec.describe "Search Sort" do
6
6
  within "#facet-language_ssim" do
7
7
  click_on 'English'
8
8
  end
9
- expect(page).to have_content 'Sort by relevance'
9
+ expect(page).to have_text 'Sort by relevance'
10
10
  click_on 'title'
11
- expect(page).to have_content 'Sort by title'
11
+ expect(page).to have_text 'Sort by title'
12
12
  end
13
13
 
14
14
  it "sorts on search" do
15
15
  visit root_path
16
16
  fill_in "q", with: 'bod'
17
17
  click_on 'search'
18
- expect(page).to have_content 'Sort by relevance'
18
+ expect(page).to have_text 'Sort by relevance'
19
19
  click_on 'title'
20
- expect(page).to have_content 'Sort by title'
20
+ expect(page).to have_text 'Sort by title'
21
21
  end
22
22
  end
@@ -9,7 +9,7 @@ RSpec.describe "Search Page" do
9
9
  it "shows welcome" do
10
10
  visit root_path
11
11
  expect(page).to have_field("search for")
12
- within ("select#search_field") do
12
+ within("select#search_field") do
13
13
  expect(page).to have_css('option', text: 'All Fields')
14
14
  expect(page).to have_css('option', text: 'Title')
15
15
  expect(page).to have_css('option', text: 'Author')
@@ -18,7 +18,7 @@ RSpec.describe "Search Page" do
18
18
  expect(page).to have_css("button[type='submit'] .submit-search-text")
19
19
  expect(page).to have_no_link "Start Over"
20
20
 
21
- expect(page).to have_content "Welcome!"
21
+ expect(page).to have_text "Welcome!"
22
22
  tmp_value = Capybara.ignore_hidden_elements
23
23
  Capybara.ignore_hidden_elements = false
24
24
  expect(page).to have_css("link[rel=stylesheet]")
@@ -44,17 +44,17 @@ RSpec.describe "Search Page" do
44
44
  Capybara.ignore_hidden_elements = tmp_value
45
45
 
46
46
  within "#appliedParams" do
47
- expect(page).to have_content "Your selections:"
48
- expect(page).to have_content "history"
47
+ expect(page).to have_text "Your selections:"
48
+ expect(page).to have_text "history"
49
49
  end
50
50
 
51
- within ("select#search_field") do
51
+ within("select#search_field") do
52
52
  expect(page).to have_css("option[selected]", text: "All Fields")
53
53
  end
54
54
 
55
- within ("#sortAndPerPage") do
56
- expect(page).to have_content "Sort by"
57
- expect(page).to have_content "1 - 10 of 11"
55
+ within("#sortAndPerPage") do
56
+ expect(page).to have_text "Sort by"
57
+ expect(page).to have_text "1 - 10 of 11"
58
58
  within '#sort-dropdown' do
59
59
  expect(page).to have_link('relevance')
60
60
  expect(page).to have_link('year')
@@ -74,18 +74,18 @@ RSpec.describe "Search Page" do
74
74
  click_on 'search'
75
75
 
76
76
  within "#appliedParams" do
77
- expect(page).to have_content "Your selections:"
78
- expect(page).to have_content "Title"
79
- expect(page).to have_content "inmul"
77
+ expect(page).to have_text "Your selections:"
78
+ expect(page).to have_text "Title"
79
+ expect(page).to have_text "inmul"
80
80
  end
81
- within ("select#search_field") do
81
+ within("select#search_field") do
82
82
  expect(page).to have_css("option[selected]", text: "Title")
83
83
  end
84
84
  within(".index_title") do
85
- expect(page).to have_content "1."
85
+ expect(page).to have_text "1."
86
86
  end
87
- within ("#sortAndPerPage") do
88
- expect(page).to have_content "1 entry found"
87
+ within("#sortAndPerPage") do
88
+ expect(page).to have_text "1 entry found"
89
89
  end
90
90
  end
91
91
 
@@ -94,8 +94,8 @@ RSpec.describe "Search Page" do
94
94
  fill_in "q", with: 'history'
95
95
  click_on 'search'
96
96
  within "#documents" do
97
- expect(page).to have_content "次按驟變"
98
- expect(page).to have_content "DK861.K3 V5"
97
+ expect(page).to have_text "次按驟變"
98
+ expect(page).to have_text "DK861.K3 V5"
99
99
  end
100
100
  end
101
101
 
@@ -104,15 +104,15 @@ RSpec.describe "Search Page" do
104
104
  fill_in "q", with: 'history'
105
105
  click_on 'search'
106
106
  within "#appliedParams" do
107
- expect(page).to have_content "Your selections:"
108
- expect(page).to have_content "history"
107
+ expect(page).to have_text "Your selections:"
108
+ expect(page).to have_text "history"
109
109
  end
110
110
 
111
111
  expect(page).to have_css "#q[value='history']"
112
112
 
113
113
  click_on "Start Over"
114
114
 
115
- expect(page).to have_content "Welcome!"
115
+ expect(page).to have_text "Welcome!"
116
116
  expect(page).to have_no_css "#q[value='history']"
117
117
  end
118
118
  end
@@ -13,7 +13,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
13
13
  before do
14
14
  allow(controller).to receive_messages(controller_name: 'test', search_state_class: Blacklight::SearchState)
15
15
  allow(helper).to receive(:search_action_path) do |*args|
16
- search_catalog_url *args
16
+ search_catalog_url(*args)
17
17
  end
18
18
 
19
19
  allow(helper).to receive_messages(blacklight_config: blacklight_config)
@@ -35,17 +35,17 @@ RSpec.describe Blacklight::UrlHelperBehavior do
35
35
  it "builds a link tag to catalog using session[:search] for query params" do
36
36
  allow(helper).to receive(:current_search_session).and_return double(query_params: query_params)
37
37
  tag = helper.link_back_to_catalog
38
- expect(tag).to match /q=query/
39
- expect(tag).to match /f=facets/
40
- expect(tag).not_to match /page=/
41
- expect(tag).not_to match /per_page=/
38
+ expect(tag).to include('q=query')
39
+ expect(tag).to include('f=facets')
40
+ expect(tag).not_to include('page=')
41
+ expect(tag).not_to include('per_page=')
42
42
  end
43
43
 
44
44
  it "builds a link tag to bookmarks using session[:search] for query params" do
45
45
  allow(helper).to receive(:current_search_session).and_return double(query_params: bookmarks_query_params)
46
46
  tag = helper.link_back_to_catalog
47
- expect(tag).to match /Back to Bookmarks/
48
- expect(tag).to match %r{/bookmarks}
47
+ expect(tag).to include('Back to Bookmarks')
48
+ expect(tag).to include('/bookmarks')
49
49
  end
50
50
 
51
51
  context "with a search context" do
@@ -53,16 +53,16 @@ RSpec.describe Blacklight::UrlHelperBehavior do
53
53
  allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
54
54
  allow(helper).to receive_messages(search_session: { 'per_page' => 15, 'counter' => 31 })
55
55
  tag = helper.link_back_to_catalog
56
- expect(tag).to match /page=3/
57
- expect(tag).to match /per_page=15/
56
+ expect(tag).to include('page=3')
57
+ expect(tag).to include('per_page=15')
58
58
  end
59
59
 
60
60
  it "omits per_page if the value is the same as the default" do
61
61
  allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
62
62
  allow(helper).to receive_messages(search_session: { 'per_page' => 10, 'counter' => 31 })
63
63
  tag = helper.link_back_to_catalog
64
- expect(tag).to match /page=4/
65
- expect(tag).not_to match /per_page=/
64
+ expect(tag).to include('page=4')
65
+ expect(tag).not_to include('per_page=')
66
66
  end
67
67
  end
68
68
 
@@ -92,8 +92,8 @@ RSpec.describe Blacklight::UrlHelperBehavior do
92
92
  expect(my_engine).to receive(:url_for)
93
93
  .with({ q: "query", f: "facets", controller: "catalog" })
94
94
  .and_return('link-url')
95
- expect(tag).to match /Back to Search/
96
- expect(tag).to match /link-url/
95
+ expect(tag).to include('Back to Search')
96
+ expect(tag).to include('link-url')
97
97
  end
98
98
  end
99
99
  end
@@ -130,11 +130,11 @@ RSpec.describe Blacklight::UrlHelperBehavior do
130
130
  end
131
131
 
132
132
  it "passes on the title attribute to the link_to_with_data method" do
133
- expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title="Some crazy longer label"/)
133
+ expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to include('title="Some crazy longer label"')
134
134
  end
135
135
 
136
136
  it "doesn't add an erroneous title attribute if one isn't provided" do
137
- expect(helper.link_to_document(document, "Some crazy long label...")).not_to match(/title=/)
137
+ expect(helper.link_to_document(document, "Some crazy long label...")).not_to include('title=')
138
138
  end
139
139
 
140
140
  context "with an integer id" do
@@ -4,7 +4,7 @@ RSpec.describe BlacklightHelper do
4
4
  before do
5
5
  allow(helper).to receive(:current_or_guest_user).and_return(User.new)
6
6
  allow(helper).to receive(:search_action_path) do |*args|
7
- search_catalog_url *args
7
+ search_catalog_url(*args)
8
8
  end
9
9
  end
10
10
 
@@ -112,7 +112,7 @@ RSpec.describe CatalogHelper do
112
112
  context "with an ActiveRecord collection" do
113
113
  subject { helper.page_entries_info(Bookmark.page(1).per(25)) }
114
114
 
115
- let(:user) { User.create! email: 'xyz@example.com', password: 'xyz12345' }
115
+ let(:user) { create_user email: 'xyz@example.com', password: 'xyz12345' }
116
116
 
117
117
  before { 50.times { Bookmark.create!(user: user) } }
118
118
 
@@ -135,9 +135,9 @@ RSpec.describe CatalogHelper do
135
135
 
136
136
  it "calls url_for on the engine scope" do
137
137
  expect(my_engine).to receive(:url_for).and_return('/rss-path')
138
- expect(tag).to match /title="RSS for results"/
139
- expect(tag).to match /rel="alternate"/
140
- expect(tag).to match %r{type="application/rss\+xml"}
138
+ expect(tag).to include('title="RSS for results"')
139
+ expect(tag).to include('rel="alternate"')
140
+ expect(tag).to include('type="application/rss+xml"')
141
141
  end
142
142
  end
143
143
  end
@@ -157,9 +157,9 @@ RSpec.describe CatalogHelper do
157
157
 
158
158
  it "calls url_for on the engine scope" do
159
159
  expect(my_engine).to receive(:url_for).and_return('/atom-path')
160
- expect(tag).to match /title="Atom for results"/
161
- expect(tag).to match /rel="alternate"/
162
- expect(tag).to match %r{type="application/atom\+xml"}
160
+ expect(tag).to include('title="Atom for results"')
161
+ expect(tag).to include('rel="alternate"')
162
+ expect(tag).to include('type="application/atom+xml"')
163
163
  end
164
164
  end
165
165
  end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'generators/blacklight/user_generator'
5
+
6
+ RSpec.describe Blacklight::UserGenerator do
7
+ describe "#validate_authentication_options" do
8
+ it "rejects multiple authentication providers" do
9
+ generator = described_class.new(["user"], devise: true, authentication: true)
10
+
11
+ expect { generator.validate_authentication_options }.to raise_error(Thor::Error, /either --devise or --authentication/)
12
+ end
13
+ end
14
+
15
+ describe "#blacklight_user_display_key_configuration" do
16
+ it "uses Rails authentication's email_address field when requested" do
17
+ generator = described_class.new(["user"], authentication: true)
18
+
19
+ expect(generator.send(:blacklight_user_display_key_configuration)).to eq "self.string_display_key = :email_address"
20
+ end
21
+
22
+ it "keeps the email configuration commented by default" do
23
+ generator = described_class.new(["user"])
24
+
25
+ expect(generator.send(:blacklight_user_display_key_configuration)).to eq "# self.string_display_key = :email"
26
+ end
27
+ end
28
+
29
+ describe "#inject_rails_authentication_guest_transfer" do
30
+ let(:destination) { Dir.mktmpdir }
31
+ let(:generator) { described_class.new(["user"], authentication: true) }
32
+ let(:sessions_path) { File.join(destination, "app/controllers/sessions_controller.rb") }
33
+
34
+ before { generator.destination_root = destination }
35
+
36
+ after { FileUtils.rm_rf(destination) }
37
+
38
+ it "injects the guest transfer call after starting a session" do
39
+ FileUtils.mkdir_p(File.dirname(sessions_path))
40
+ File.write(sessions_path, <<~RUBY)
41
+ class SessionsController < ApplicationController
42
+ def create
43
+ if user = User.authenticate_by(params.permit(:email_address, :password))
44
+ start_new_session_for user
45
+ redirect_to after_authentication_url
46
+ end
47
+ end
48
+ end
49
+ RUBY
50
+
51
+ generator.send(:inject_rails_authentication_guest_transfer)
52
+
53
+ expect(File.read(sessions_path)).to include("start_new_session_for user\n transfer_guest_to_user\n")
54
+ end
55
+
56
+ it "is a no-op when there is no sessions controller" do
57
+ expect { generator.send(:inject_rails_authentication_guest_transfer) }.not_to raise_error
58
+ end
59
+ end
60
+ end
@@ -73,7 +73,7 @@ RSpec.describe Blacklight::SearchState::PivotFilterField do
73
73
  new_state = filter.remove(value_class.new(fq: { some_other_field: '3' }, value: '1'))
74
74
 
75
75
  expect(new_state.params[:f]).not_to include :some_other_field
76
- expect(new_state.filter('pivot_field').values&.map(&:fq)).to eql([some_other_field: nil])
76
+ expect(new_state.filter('pivot_field').values&.map(&:fq)).to eql([{ some_other_field: nil }])
77
77
  end
78
78
 
79
79
  it 'removes the filter parameter entirely if there are no filters left' do
@@ -22,7 +22,7 @@ RSpec.describe "Blacklight::Configurable", :api do
22
22
  end
23
23
 
24
24
  it "inherited version should be a deep copy, not original" do
25
- expect(TestCaseInheritence::Child.blacklight_config).not_to be(TestCaseInheritence::Parent.blacklight_config)
25
+ expect(TestCaseInheritence::Child.blacklight_config).not_to be(TestCaseInheritence::Parent.blacklight_config)
26
26
 
27
27
  TestCaseInheritence::Child.blacklight_config.list << "child_only"
28
28
 
@@ -670,25 +670,6 @@ RSpec.describe Blacklight::Configuration, :api do
670
670
  expect(config.view_config(action_name: :show)).to have_attributes config.show.to_h
671
671
  end
672
672
 
673
- it 'includes the default action mapping configuration' do
674
- config.action_mapping.default.whatever = :some_value
675
-
676
- expect(config.view_config(action_name: :show)).to have_attributes whatever: :some_value
677
- end
678
-
679
- it 'includes the action-specific mappings' do
680
- config.action_mapping.foo.document_presenter_class = Blacklight::DocumentPresenter
681
-
682
- expect(config.view_config(action_name: :foo)).to have_attributes config.action_mapping.foo.to_h
683
- end
684
-
685
- it 'allows the action mapping to specific a parent configuration with some more defaults' do
686
- config.action_mapping.foo.parent_config = :bar
687
- config.action_mapping.bar.whatever = :bar_value
688
-
689
- expect(config.view_config(action_name: :foo)).to have_attributes whatever: :bar_value
690
- end
691
-
692
673
  context 'with the :citation action' do
693
674
  it 'also includes the show config' do
694
675
  expect(config.view_config(action_name: :citation)).to have_attributes config.show.to_h
@@ -25,8 +25,8 @@ RSpec.describe "Blacklight::Document::DublinCore" do
25
25
  it "includes 'dc:'-prefixed semantic fields" do
26
26
  data = { 'id' => '123456', 'title_tsim' => ['654321'] }
27
27
  document = @mock_class.new(data)
28
- expect(document.export_as_oai_dc_xml).to match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
29
- expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
28
+ expect(document.export_as_oai_dc_xml).to match 'xmlns:dc="http://purl.org/dc/elements/1.1/"'
29
+ expect(document.export_as_oai_dc_xml).to match '<dc:title>654321</dc:title>'
30
30
  end
31
31
 
32
32
  it "works with multi-value fields" do
@@ -171,6 +171,6 @@ RSpec.describe Blacklight::FacetPaginator, :api do
171
171
  # this method is just for API compatability with kaminari 0.16.1
172
172
  subject { described_class.new([book], offset: 0, limit: nil).total_pages }
173
173
 
174
- it { is_expected.to eq -1 }
174
+ it { is_expected.to eq(-1) }
175
175
  end
176
176
  end