blacklight 8.2.2 → 8.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/.github/workflows/ruby.yml +56 -62
- data/.rubocop.yml +226 -21
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_mixins.scss +2 -17
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/system/dropdown_component.rb +1 -1
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -5
- data/app/helpers/blacklight/layout_helper_behavior.rb +3 -3
- data/app/views/shared/_flash_messages.html.erb +1 -1
- data/lib/blacklight/configuration.rb +1 -0
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +2 -2
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response/facets.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +1 -1
- data/package.json +1 -1
- data/spec/components/blacklight/advanced_search_form_component_spec.rb +2 -2
- data/spec/components/blacklight/constraint_layout_component_spec.rb +11 -11
- data/spec/components/blacklight/constraints_component_spec.rb +9 -9
- data/spec/components/blacklight/document/group_component_spec.rb +3 -3
- data/spec/components/blacklight/document/sidebar_component_spec.rb +3 -4
- data/spec/components/blacklight/document_component_spec.rb +21 -25
- data/spec/components/blacklight/facet_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_field_list_component_spec.rb +13 -13
- data/spec/components/blacklight/facet_item_component_spec.rb +5 -5
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +6 -6
- data/spec/components/blacklight/header_component_spec.rb +1 -2
- data/spec/components/blacklight/hidden_search_state_component_spec.rb +6 -6
- data/spec/components/blacklight/metadata_field_component_spec.rb +3 -3
- data/spec/components/blacklight/response/pagination_component_spec.rb +4 -4
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +1 -3
- data/spec/components/blacklight/system/flash_message_component_spec.rb +5 -5
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/controllers/blacklight/{catalog/component_configuration_spec.rb → configurable_spec.rb} +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +10 -10
- data/spec/controllers/catalog_controller_spec.rb +24 -26
- data/spec/features/advanced_search_spec.rb +14 -14
- data/spec/features/alternate_controller_spec.rb +9 -9
- data/spec/features/axe_spec.rb +4 -4
- data/spec/features/bookmarks_spec.rb +19 -19
- data/spec/features/citation_spec.rb +1 -1
- data/spec/features/did_you_mean_spec.rb +23 -23
- data/spec/features/facet_missing_spec.rb +9 -9
- data/spec/features/facets_spec.rb +21 -20
- data/spec/features/modal_spec.rb +4 -4
- data/spec/features/record_view_spec.rb +2 -2
- data/spec/features/search_context_spec.rb +6 -6
- data/spec/features/search_crawler_spec.rb +5 -5
- data/spec/features/search_filters_spec.rb +65 -65
- data/spec/features/search_history_spec.rb +12 -12
- data/spec/features/search_pagination_spec.rb +10 -10
- data/spec/features/search_results_spec.rb +1 -1
- data/spec/features/search_sort_spec.rb +4 -4
- data/spec/features/search_spec.rb +25 -25
- data/spec/features/sitelinks_search_box_spec.rb +2 -2
- data/spec/features/sms_spec.rb +1 -1
- data/spec/helpers/blacklight/layout_helper_behavior_spec.rb +20 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +2 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +7 -8
- data/spec/helpers/blacklight_helper_spec.rb +13 -15
- data/spec/helpers/catalog_helper_spec.rb +3 -6
- data/spec/i18n_spec.rb +2 -1
- data/spec/lib/blacklight/search_state_spec.rb +4 -4
- data/spec/lib/tasks/blacklight_task_spec.rb +2 -1
- data/spec/models/blacklight/configurable_spec.rb +1 -1
- data/spec/models/blacklight/configuration/context_spec.rb +1 -1
- data/spec/models/blacklight/configuration_spec.rb +2 -2
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -1
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -1
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/facet_paginator_spec.rb +14 -14
- data/spec/models/blacklight/icon_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +1 -1
- data/spec/models/blacklight/solr/document_spec.rb +1 -1
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -1
- data/spec/models/blacklight/solr/repository_spec.rb +2 -2
- data/spec/models/blacklight/solr/request_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -1
- data/spec/models/blacklight/solr/response_spec.rb +1 -1
- data/spec/models/blacklight/solr/{search_builder_spec.rb → search_builder_behavior_spec.rb} +9 -19
- data/spec/models/blacklight/suggest/response_spec.rb +1 -1
- data/spec/models/blacklight/suggest_search_spec.rb +1 -1
- data/spec/models/blacklight/user_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +1 -1
- data/spec/presenters/blacklight/document_presenter_spec.rb +1 -2
- data/spec/presenters/blacklight/field_presenter_spec.rb +1 -1
- data/spec/presenters/blacklight/index_presenter_spec.rb +2 -3
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -1
- data/spec/presenters/{pipeline_spec.rb → blacklight/rendering/pipeline_spec.rb} +1 -1
- data/spec/presenters/blacklight/show_presenter_spec.rb +5 -6
- data/spec/presenters/{thumbnail_presenter_spec.rb → blacklight/thumbnail_presenter_spec.rb} +5 -3
- data/spec/routing/catalog_routing_spec.rb +1 -1
- data/spec/services/blacklight/field_retriever_spec.rb +1 -1
- data/spec/services/blacklight/search_service_spec.rb +9 -9
- data/spec/spec_helper.rb +2 -2
- data/spec/support/features/search_helpers.rb +2 -2
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -2
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +5 -6
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -7
- data/spec/views/catalog/email_success.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -1
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -19
- data/spec/views/catalog/index.html.erb_spec.rb +2 -4
- data/spec/views/catalog/index.json.jbuilder_spec.rb +5 -8
- data/spec/views/catalog/show.html.erb_spec.rb +3 -5
- data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -2
- data/spec/views/catalog/sms_success.html.erb_spec.rb +1 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +2 -3
- metadata +10 -10
@@ -4,7 +4,7 @@ RSpec.describe "Search Pagination" do
|
|
4
4
|
it "has results with pagination" do
|
5
5
|
visit root_path
|
6
6
|
fill_in "q", with: ''
|
7
|
-
|
7
|
+
click_on 'search'
|
8
8
|
within ("#sortAndPerPage") do
|
9
9
|
expect(page).to have_content "1 - 10 of "
|
10
10
|
within '#per_page-dropdown' do
|
@@ -15,11 +15,11 @@ RSpec.describe "Search Pagination" do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
within '#sortAndPerPage' do
|
18
|
-
|
18
|
+
click_on "Next »"
|
19
19
|
end
|
20
20
|
within "#sortAndPerPage" do
|
21
21
|
expect(page).to have_content "11 - 20 of "
|
22
|
-
|
22
|
+
click_on "« Previous"
|
23
23
|
end
|
24
24
|
within "#sortAndPerPage" do
|
25
25
|
expect(page).to have_content "1 - 10 of "
|
@@ -29,13 +29,13 @@ RSpec.describe "Search Pagination" do
|
|
29
29
|
it "is able to change the number of items per page" do
|
30
30
|
visit root_path
|
31
31
|
fill_in "q", with: ''
|
32
|
-
|
32
|
+
click_on 'search'
|
33
33
|
within ("#sortAndPerPage") do
|
34
34
|
expect(page).to have_content "1 - 10 of "
|
35
35
|
end
|
36
36
|
|
37
37
|
within ("#per_page-dropdown") do
|
38
|
-
|
38
|
+
click_on '20'
|
39
39
|
end
|
40
40
|
within ("#sortAndPerPage") do
|
41
41
|
expect(page).to have_content "1 - 20 of "
|
@@ -59,7 +59,7 @@ RSpec.describe "Search Pagination" do
|
|
59
59
|
it "uses the configured values" do
|
60
60
|
visit root_path
|
61
61
|
fill_in "q", with: ''
|
62
|
-
|
62
|
+
click_on 'search'
|
63
63
|
within ("#sortAndPerPage") do
|
64
64
|
expect(page).to have_content "1 - 15 of "
|
65
65
|
within '#per_page-dropdown' do
|
@@ -68,7 +68,7 @@ RSpec.describe "Search Pagination" do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
within ("#per_page-dropdown") do
|
71
|
-
|
71
|
+
click_on '30'
|
72
72
|
end
|
73
73
|
within ("#sortAndPerPage") do
|
74
74
|
expect(page).to have_content "1 - 30 of "
|
@@ -79,15 +79,15 @@ RSpec.describe "Search Pagination" do
|
|
79
79
|
it "resets the page offset to 1 when changing per page" do
|
80
80
|
visit root_path
|
81
81
|
fill_in "q", with: ''
|
82
|
-
|
82
|
+
click_on 'search'
|
83
83
|
within "#sortAndPerPage" do
|
84
|
-
|
84
|
+
click_on "Next »"
|
85
85
|
end
|
86
86
|
within "#sortAndPerPage" do
|
87
87
|
expect(page).to have_content "11 - 20 of "
|
88
88
|
end
|
89
89
|
within ("#per_page-dropdown") do
|
90
|
-
|
90
|
+
click_on '20'
|
91
91
|
end
|
92
92
|
within "#sortAndPerPage" do
|
93
93
|
expect(page).to have_content "1 - 20 of "
|
@@ -51,7 +51,7 @@ RSpec.describe "Search Results" do
|
|
51
51
|
visit root_path
|
52
52
|
fill_in "q", with: "inmul"
|
53
53
|
select "Author", from: "search_field"
|
54
|
-
|
54
|
+
click_on 'search'
|
55
55
|
expect(page).to have_content "No results found for your search"
|
56
56
|
expect(page).to have_content "you searched by Author"
|
57
57
|
click_on "try searching everything"
|
@@ -4,19 +4,19 @@ RSpec.describe "Search Sort" do
|
|
4
4
|
it "sorts on facet results with no search terms" do
|
5
5
|
visit root_path
|
6
6
|
within "#facet-language_ssim" do
|
7
|
-
|
7
|
+
click_on 'English'
|
8
8
|
end
|
9
9
|
expect(page).to have_content 'Sort by relevance'
|
10
|
-
|
10
|
+
click_on 'title'
|
11
11
|
expect(page).to have_content '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
18
|
expect(page).to have_content 'Sort by relevance'
|
19
|
-
|
19
|
+
click_on 'title'
|
20
20
|
expect(page).to have_content 'Sort by title'
|
21
21
|
end
|
22
22
|
end
|
@@ -3,25 +3,25 @@
|
|
3
3
|
RSpec.describe "Search Page" do
|
4
4
|
it 'declares the page language in the html lang attribute' do
|
5
5
|
visit root_path
|
6
|
-
expect(page).to
|
6
|
+
expect(page).to have_css('html[lang=en]')
|
7
7
|
end
|
8
8
|
|
9
9
|
it "shows welcome" do
|
10
10
|
visit root_path
|
11
|
-
expect(page).to
|
11
|
+
expect(page).to have_field("search for")
|
12
12
|
within ("select#search_field") do
|
13
|
-
expect(page).to
|
14
|
-
expect(page).to
|
15
|
-
expect(page).to
|
16
|
-
expect(page).to
|
13
|
+
expect(page).to have_css('option', text: 'All Fields')
|
14
|
+
expect(page).to have_css('option', text: 'Title')
|
15
|
+
expect(page).to have_css('option', text: 'Author')
|
16
|
+
expect(page).to have_css('option', text: 'Subject')
|
17
17
|
end
|
18
|
-
expect(page).to
|
19
|
-
expect(page).
|
18
|
+
expect(page).to have_css("button[type='submit'] .submit-search-text")
|
19
|
+
expect(page).to have_no_link "Start Over"
|
20
20
|
|
21
21
|
expect(page).to have_content "Welcome!"
|
22
22
|
tmp_value = Capybara.ignore_hidden_elements
|
23
23
|
Capybara.ignore_hidden_elements = false
|
24
|
-
expect(page).to
|
24
|
+
expect(page).to have_css("link[rel=stylesheet]")
|
25
25
|
Capybara.ignore_hidden_elements = tmp_value
|
26
26
|
end
|
27
27
|
|
@@ -29,18 +29,18 @@ RSpec.describe "Search Page" do
|
|
29
29
|
visit root_path
|
30
30
|
fill_in "q", with: 'history'
|
31
31
|
select 'All Fields', from: 'search_field'
|
32
|
-
|
32
|
+
click_on 'search'
|
33
33
|
|
34
34
|
tmp_value = Capybara.ignore_hidden_elements
|
35
35
|
Capybara.ignore_hidden_elements = false
|
36
|
-
expect(page).to
|
37
|
-
expect(page).to
|
38
|
-
expect(page).to
|
36
|
+
expect(page).to have_css("link[rel=alternate][type='application/rss+xml']")
|
37
|
+
expect(page).to have_css("link[rel=alternate][type='application/atom+xml']")
|
38
|
+
expect(page).to have_css("link[rel=alternate][type='application/json']")
|
39
39
|
|
40
40
|
# opensearch
|
41
|
-
expect(page).to
|
42
|
-
expect(page).to
|
43
|
-
expect(page).to
|
41
|
+
expect(page).to have_css("meta[name=totalResults]")
|
42
|
+
expect(page).to have_css("meta[name=startIndex]")
|
43
|
+
expect(page).to have_css("meta[name=itemsPerPage]")
|
44
44
|
Capybara.ignore_hidden_elements = tmp_value
|
45
45
|
|
46
46
|
within "#appliedParams" do
|
@@ -49,7 +49,7 @@ RSpec.describe "Search Page" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
within ("select#search_field") do
|
52
|
-
expect(page).to
|
52
|
+
expect(page).to have_css("option[selected]", text: "All Fields")
|
53
53
|
end
|
54
54
|
|
55
55
|
within ("#sortAndPerPage") do
|
@@ -63,7 +63,7 @@ RSpec.describe "Search Page" do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
within "#documents" do
|
66
|
-
expect(page).to
|
66
|
+
expect(page).to have_css(".document", count: 10)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,7 +71,7 @@ RSpec.describe "Search Page" do
|
|
71
71
|
visit root_path
|
72
72
|
fill_in "q", with: 'inmul'
|
73
73
|
select 'Title', from: 'search_field'
|
74
|
-
|
74
|
+
click_on 'search'
|
75
75
|
|
76
76
|
within "#appliedParams" do
|
77
77
|
expect(page).to have_content "You searched for:"
|
@@ -79,7 +79,7 @@ RSpec.describe "Search Page" do
|
|
79
79
|
expect(page).to have_content "inmul"
|
80
80
|
end
|
81
81
|
within ("select#search_field") do
|
82
|
-
expect(page).to
|
82
|
+
expect(page).to have_css("option[selected]", text: "Title")
|
83
83
|
end
|
84
84
|
within(".index_title") do
|
85
85
|
expect(page).to have_content "1."
|
@@ -92,7 +92,7 @@ RSpec.describe "Search Page" do
|
|
92
92
|
it "shows vernacular (Linked 880) and call number" do
|
93
93
|
visit root_path
|
94
94
|
fill_in "q", with: 'history'
|
95
|
-
|
95
|
+
click_on 'search'
|
96
96
|
within "#documents" do
|
97
97
|
expect(page).to have_content "次按驟變"
|
98
98
|
expect(page).to have_content "DK861.K3 V5"
|
@@ -102,17 +102,17 @@ RSpec.describe "Search Page" do
|
|
102
102
|
it "allows you to clear the search" do
|
103
103
|
visit root_path
|
104
104
|
fill_in "q", with: 'history'
|
105
|
-
|
105
|
+
click_on 'search'
|
106
106
|
within "#appliedParams" do
|
107
107
|
expect(page).to have_content "You searched for:"
|
108
108
|
expect(page).to have_content "history"
|
109
109
|
end
|
110
110
|
|
111
|
-
expect(page).to
|
111
|
+
expect(page).to have_css "#q[value='history']"
|
112
112
|
|
113
|
-
|
113
|
+
click_on "Start Over"
|
114
114
|
|
115
115
|
expect(page).to have_content "Welcome!"
|
116
|
-
expect(page).
|
116
|
+
expect(page).to have_no_css "#q[value='history']"
|
117
117
|
end
|
118
118
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
RSpec.describe 'Sitelinks search box' do
|
4
4
|
it 'is home page' do
|
5
5
|
visit root_path
|
6
|
-
expect(page).to
|
6
|
+
expect(page).to have_css 'script[type="application/ld+json"]', visible: :hidden
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'on search page' do
|
10
10
|
visit search_catalog_path q: 'book'
|
11
|
-
expect(page).
|
11
|
+
expect(page).to have_no_css 'script[type="application/ld+json"]', visible: :hidden
|
12
12
|
end
|
13
13
|
end
|
data/spec/features/sms_spec.rb
CHANGED
@@ -4,7 +4,7 @@ RSpec.describe 'SMS functionality' do
|
|
4
4
|
before { visit solr_document_path('2007020969') }
|
5
5
|
|
6
6
|
it 'displays SMS modal with form' do
|
7
|
-
|
7
|
+
click_on 'SMS'
|
8
8
|
expect(find('div.modal-header')).to have_text 'SMS This'
|
9
9
|
fill_in 'Phone Number:', with: '555-555-5555'
|
10
10
|
select 'Verizon', from: 'Carrier'
|
@@ -30,9 +30,26 @@ RSpec.describe Blacklight::LayoutHelperBehavior do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#container_classes' do
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
before do
|
34
|
+
allow(view).to receive(:blacklight_config).and_return(config)
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when not full-width' do
|
38
|
+
let(:config) { Blacklight::Configuration.new }
|
39
|
+
|
40
|
+
it 'returns a string of classe(s)' do
|
41
|
+
expect(helper.container_classes).to be_an String
|
42
|
+
expect(helper.container_classes).to eq 'container'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when full-width' do
|
47
|
+
let(:config) { Blacklight::Configuration.new(full_width_layout: true) }
|
48
|
+
|
49
|
+
it 'returns a string of classe(s)' do
|
50
|
+
expect(helper.container_classes).to be_an String
|
51
|
+
expect(helper.container_classes).to eq 'container-fluid'
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
38
55
|
|
@@ -40,8 +40,9 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "gets the document format from document_partial_name" do
|
43
|
-
allow(helper).to receive(:document_partial_name)
|
43
|
+
allow(helper).to receive(:document_partial_name)
|
44
44
|
helper.render_document_partial(doc, :xyz)
|
45
|
+
expect(helper).to have_received(:document_partial_name).with(doc, :xyz)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -11,8 +11,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
11
11
|
let(:parameter_class) { ActionController::Parameters }
|
12
12
|
|
13
13
|
before do
|
14
|
-
allow(controller).to
|
15
|
-
allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
|
14
|
+
allow(controller).to receive_messages(controller_name: 'test', search_state_class: Blacklight::SearchState)
|
16
15
|
allow(helper).to receive(:search_action_path) do |*args|
|
17
16
|
search_catalog_url *args
|
18
17
|
end
|
@@ -112,18 +111,18 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
112
111
|
end
|
113
112
|
|
114
113
|
it "consists of the document title wrapped in a <a>" do
|
115
|
-
expect(helper.link_to_document(document)).to
|
114
|
+
expect(helper.link_to_document(document)).to have_css("a", text: '654321', count: 1)
|
116
115
|
end
|
117
116
|
|
118
117
|
it "accepts and returns a string label" do
|
119
|
-
expect(helper.link_to_document(document, 'This is the title')).to
|
118
|
+
expect(helper.link_to_document(document, 'This is the title')).to have_css("a", text: 'This is the title', count: 1)
|
120
119
|
end
|
121
120
|
|
122
121
|
context 'when label is missing' do
|
123
122
|
let(:data) { { 'id' => id } }
|
124
123
|
|
125
124
|
it "returns id" do
|
126
|
-
expect(helper.link_to_document(document)).to
|
125
|
+
expect(helper.link_to_document(document)).to have_css("a", text: '123456', count: 1)
|
127
126
|
end
|
128
127
|
|
129
128
|
it "is html safe" do
|
@@ -142,7 +141,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
142
141
|
let(:id) { 123_456 }
|
143
142
|
|
144
143
|
it "has a link" do
|
145
|
-
expect(helper.link_to_document(document)).to
|
144
|
+
expect(helper.link_to_document(document)).to have_css("a")
|
146
145
|
end
|
147
146
|
end
|
148
147
|
end
|
@@ -154,14 +153,14 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
154
153
|
|
155
154
|
it "includes the data- attributes from the options" do
|
156
155
|
link = helper.link_to_document document, data: { x: 1 }
|
157
|
-
expect(link).to
|
156
|
+
expect(link).to have_css '[data-x]'
|
158
157
|
end
|
159
158
|
|
160
159
|
it 'adds a controller-specific tracking attribute' do
|
161
160
|
expect(helper.main_app).to receive(:track_test_path).and_return('/asdf')
|
162
161
|
link = helper.link_to_document document, data: { x: 1 }
|
163
162
|
|
164
|
-
expect(link).to
|
163
|
+
expect(link).to have_css '[data-context-href="/asdf"]'
|
165
164
|
end
|
166
165
|
end
|
167
166
|
|
@@ -73,8 +73,7 @@ RSpec.describe BlacklightHelper do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
before do
|
76
|
-
allow(helper).to
|
77
|
-
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
76
|
+
allow(helper).to receive_messages(document_presenter: presenter, blacklight_config: blacklight_config)
|
78
77
|
end
|
79
78
|
|
80
79
|
it "generates <link rel=alternate> tags" do
|
@@ -109,8 +108,8 @@ RSpec.describe BlacklightHelper do
|
|
109
108
|
it "renders partials" do
|
110
109
|
buff = String.new
|
111
110
|
helper.render_nav_actions { |_config, item| buff << "<foo>#{item}</foo>" }
|
112
|
-
expect(buff).to
|
113
|
-
expect(buff).to
|
111
|
+
expect(buff).to have_css "foo a#bookmarks_nav[href=\"/bookmarks\"]"
|
112
|
+
expect(buff).to have_css "foo a span[data-role='bookmark-counter']", text: '0'
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
@@ -118,7 +117,7 @@ RSpec.describe BlacklightHelper do
|
|
118
117
|
it "renders partials" do
|
119
118
|
allow(controller).to receive(:render_bookmarks_control?).and_return(true)
|
120
119
|
response = helper.render_index_doc_actions(document)
|
121
|
-
expect(response).to
|
120
|
+
expect(response).to have_css(".bookmark-toggle")
|
122
121
|
end
|
123
122
|
|
124
123
|
it "is nil if no partials are renderable" do
|
@@ -138,27 +137,28 @@ RSpec.describe BlacklightHelper do
|
|
138
137
|
subject { helper.opensearch_description_tag 'title', 'href' }
|
139
138
|
|
140
139
|
it "has a search rel" do
|
141
|
-
expect(subject).to
|
140
|
+
expect(subject).to have_css "link[rel='search']", visible: false
|
142
141
|
end
|
143
142
|
|
144
143
|
it "has the correct mime type" do
|
145
|
-
expect(subject).to
|
144
|
+
expect(subject).to have_css "link[type='application/opensearchdescription+xml']", visible: false
|
146
145
|
end
|
147
146
|
|
148
147
|
it "has a title attribute" do
|
149
|
-
expect(subject).to
|
148
|
+
expect(subject).to have_css "link[title='title']", visible: false
|
150
149
|
end
|
151
150
|
|
152
151
|
it "has an href attribute" do
|
153
|
-
expect(subject).to
|
152
|
+
expect(subject).to have_css "link[href='href']", visible: false
|
154
153
|
end
|
155
154
|
end
|
156
155
|
|
157
156
|
describe "#render_document_index" do
|
158
157
|
it "renders the document index with the current view type" do
|
159
158
|
allow(helper).to receive_messages(document_index_view_type: :current_view)
|
160
|
-
allow(helper).to receive(:render_document_index_with_view)
|
159
|
+
allow(helper).to receive(:render_document_index_with_view)
|
161
160
|
helper.render_document_index [], a: 1, b: 2
|
161
|
+
expect(helper).to have_received(:render_document_index_with_view).with(:current_view, [], { a: 1, b: 2 })
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -167,17 +167,15 @@ RSpec.describe BlacklightHelper do
|
|
167
167
|
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
168
168
|
|
169
169
|
before do
|
170
|
-
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
171
170
|
assign(:response, instance_double(Blacklight::Solr::Response, grouped?: false, start: 0))
|
172
|
-
allow(helper).to
|
173
|
-
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
171
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config, link_to_document: '<a/>', render_index_doc_actions: '<div/>')
|
174
172
|
end
|
175
173
|
|
176
174
|
it "ignores missing templates" do
|
177
175
|
blacklight_config.view.view_type(partials: %w[index_header a b])
|
178
176
|
|
179
177
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
180
|
-
expect(response).to
|
178
|
+
expect(response).to have_css "div#documents"
|
181
179
|
end
|
182
180
|
|
183
181
|
context 'with a template partial provided by the view config' do
|
@@ -191,7 +189,7 @@ RSpec.describe BlacklightHelper do
|
|
191
189
|
# https://github.com/rspec/rspec-rails/commit/4d65bea0619955acb15023b9c3f57a3a53183da8
|
192
190
|
# https://github.com/rspec/rspec-rails/issues/2696
|
193
191
|
replace_hash = { 'my/_partial.html.erb' => 'some content' }
|
194
|
-
if
|
192
|
+
if Rails.version.to_f >= 7.1
|
195
193
|
controller.prepend_view_path(RSpec::Rails::ViewExampleGroup::StubResolverCache.resolver_for(replace_hash))
|
196
194
|
else
|
197
195
|
view.view_paths.unshift(ActionView::FixtureResolver.new(replace_hash))
|
@@ -267,8 +267,7 @@ RSpec.describe CatalogHelper do
|
|
267
267
|
subject { helper.render_search_to_page_title(Blacklight::SearchState.new(params, blacklight_config)) }
|
268
268
|
|
269
269
|
before do
|
270
|
-
allow(helper).to
|
271
|
-
allow(helper).to receive(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(key: 'default_search_field', display_label: 'Default'))
|
270
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config, default_search_field: Blacklight::Configuration::SearchField.new(key: 'default_search_field', display_label: 'Default'))
|
272
271
|
allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
|
273
272
|
end
|
274
273
|
|
@@ -299,8 +298,7 @@ RSpec.describe CatalogHelper do
|
|
299
298
|
|
300
299
|
describe "#document_index_view_type" do
|
301
300
|
it "defaults to the default view" do
|
302
|
-
allow(helper).to
|
303
|
-
allow(helper).to receive(:default_document_index_view_type).and_return(:xyz)
|
301
|
+
allow(helper).to receive_messages(document_index_views: { a: 1, b: 2 }, default_document_index_view_type: :xyz)
|
304
302
|
expect(helper.document_index_view_type).to eq :xyz
|
305
303
|
end
|
306
304
|
|
@@ -310,8 +308,7 @@ RSpec.describe CatalogHelper do
|
|
310
308
|
end
|
311
309
|
|
312
310
|
it "uses the default view if the requested view is not available" do
|
313
|
-
allow(helper).to
|
314
|
-
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2)
|
311
|
+
allow(helper).to receive_messages(default_document_index_view_type: :xyz, document_index_views: { a: 1, b: 2 })
|
315
312
|
expect(helper.document_index_view_type(view: :c)).to eq :xyz
|
316
313
|
end
|
317
314
|
|
data/spec/i18n_spec.rb
CHANGED
@@ -12,7 +12,8 @@ RSpec.describe 'I18n', type: :i18n do
|
|
12
12
|
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
it 'does not have unused keys' do
|
16
|
+
pending 'Many unused keys are detected'
|
16
17
|
expect(unused_keys).to be_empty,
|
17
18
|
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
|
18
19
|
end
|
@@ -37,7 +37,7 @@ RSpec.describe Blacklight::SearchState do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'with HashWithIndifferentAccess' do
|
40
|
-
let(:parameter_class) { HashWithIndifferentAccess }
|
40
|
+
let(:parameter_class) { ActiveSupport::HashWithIndifferentAccess }
|
41
41
|
|
42
42
|
it 'returns the hash data' do
|
43
43
|
expect(search_state.to_h).to eq data.with_indifferent_access
|
@@ -356,7 +356,7 @@ RSpec.describe Blacklight::SearchState do
|
|
356
356
|
end
|
357
357
|
|
358
358
|
describe "#url_for_document" do
|
359
|
-
let(:controller_class) {
|
359
|
+
let(:controller_class) { CatalogController.new }
|
360
360
|
let(:doc) { SolrDocument.new }
|
361
361
|
|
362
362
|
before do
|
@@ -375,7 +375,7 @@ RSpec.describe Blacklight::SearchState do
|
|
375
375
|
end
|
376
376
|
|
377
377
|
context "within bookmarks" do
|
378
|
-
let(:controller_class) {
|
378
|
+
let(:controller_class) { BookmarksController.new }
|
379
379
|
|
380
380
|
it "uses polymorphic routing" do
|
381
381
|
expect(search_state.url_for_document(doc)).to eq doc
|
@@ -383,7 +383,7 @@ RSpec.describe Blacklight::SearchState do
|
|
383
383
|
end
|
384
384
|
|
385
385
|
context "within an alternative catalog controller" do
|
386
|
-
let(:controller_class) {
|
386
|
+
let(:controller_class) { AlternateController.new }
|
387
387
|
|
388
388
|
before do
|
389
389
|
search_state.blacklight_config.show.route = { controller: :current }
|
@@ -13,7 +13,8 @@ RSpec.describe "blacklight:delete_old_searches" do
|
|
13
13
|
|
14
14
|
it "calls Search.delete_old_searches" do
|
15
15
|
days_old = 7
|
16
|
-
allow(Search).to receive(:delete_old_searches)
|
16
|
+
allow(Search).to receive(:delete_old_searches)
|
17
17
|
@rake[@task_name].invoke(days_old)
|
18
|
+
expect(Search).to have_received(:delete_old_searches).with(days_old)
|
18
19
|
end
|
19
20
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe "Blacklight::Configuration", api
|
3
|
+
RSpec.describe "Blacklight::Configuration", :api do
|
4
4
|
let(:config) do
|
5
5
|
Blacklight::Configuration.new
|
6
6
|
end
|
@@ -352,7 +352,7 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
352
352
|
expect(config.index_fields.keys).to eq %w[some_field_display another_field_display]
|
353
353
|
end
|
354
354
|
|
355
|
-
it "queries solr and get live values for match fields", integration
|
355
|
+
it "queries solr and get live values for match fields", :integration do
|
356
356
|
config.add_index_field match: /title.+sim/
|
357
357
|
expect(config.index_fields.keys).to include "subtitle_tsim", "subtitle_vern_ssim", "title_tsim", "title_vern_ssim"
|
358
358
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
RSpec.describe 'Blacklight::Document::ActiveModelShim', api
|
3
|
+
RSpec.describe 'Blacklight::Document::ActiveModelShim', :api do
|
4
4
|
class MockDocument
|
5
5
|
include Blacklight::Document
|
6
6
|
include Blacklight::Document::ActiveModelShim
|