blacklight 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.solr_wrapper +5 -0
- data/.travis.yml +3 -5
- data/Gemfile +3 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/core.js +19 -5
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +48 -20
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -1
- data/app/presenters/blacklight/document_presenter.rb +58 -150
- data/app/presenters/blacklight/field_presenter.rb +31 -0
- data/app/presenters/blacklight/index_presenter.rb +69 -0
- data/app/presenters/blacklight/link_alternate_presenter.rb +29 -0
- data/app/presenters/blacklight/rendering/abstract_step.rb +24 -0
- data/app/presenters/blacklight/rendering/helper_method.rb +23 -0
- data/app/presenters/blacklight/rendering/join.rb +16 -0
- data/app/presenters/blacklight/rendering/link_to_facet.rb +35 -0
- data/app/presenters/blacklight/rendering/microdata.rb +17 -0
- data/app/presenters/blacklight/rendering/pipeline.rb +32 -0
- data/app/presenters/blacklight/rendering/terminator.rb +9 -0
- data/app/presenters/blacklight/show_presenter.rb +93 -0
- data/app/services/blacklight/field_retriever.rb +58 -0
- data/app/views/catalog/_document_default.atom.builder +2 -3
- data/app/views/catalog/_document_default.rss.builder +2 -2
- data/app/views/kaminari/blacklight/_next_page.html.erb +9 -3
- data/app/views/kaminari/blacklight/_prev_page.html.erb +10 -3
- data/lib/blacklight/configuration.rb +15 -3
- data/lib/blacklight/configuration/null_field.rb +13 -0
- data/lib/blacklight/configuration/view_config.rb +6 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -1
- data/lib/generators/blacklight/templates/config/jetty.yml +1 -1
- data/spec/controllers/alternate_controller_spec.rb +2 -2
- data/spec/controllers/application_controller_spec.rb +1 -1
- data/spec/controllers/blacklight/facet_spec.rb +3 -3
- data/spec/controllers/blacklight/search_fields_spec.rb +7 -7
- data/spec/controllers/blacklight/search_helper_spec.rb +44 -44
- data/spec/controllers/blacklight/suggest_search_spec.rb +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +125 -125
- data/spec/controllers/saved_searches_controller_spec.rb +4 -9
- data/spec/controllers/search_history_controller_spec.rb +3 -6
- data/spec/controllers/suggest_controller_spec.rb +2 -2
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/bookmarks_spec.rb +6 -6
- data/spec/features/did_you_mean_spec.rb +10 -10
- data/spec/features/facets_spec.rb +4 -4
- data/spec/features/record_view_spec.rb +4 -4
- data/spec/features/saved_searches_spec.rb +4 -4
- data/spec/features/search_context_spec.rb +4 -4
- data/spec/features/search_filters_spec.rb +10 -10
- data/spec/features/search_formats_spec.rb +2 -2
- data/spec/features/search_history_spec.rb +5 -5
- data/spec/features/search_pagination_spec.rb +4 -4
- data/spec/features/search_results_spec.rb +7 -7
- data/spec/features/search_sort_spec.rb +2 -2
- data/spec/features/search_spec.rb +6 -6
- data/spec/helpers/blacklight_helper_spec.rb +105 -65
- data/spec/helpers/catalog_helper_spec.rb +36 -36
- data/spec/helpers/configuration_helper_spec.rb +28 -28
- data/spec/helpers/facets_helper_spec.rb +39 -39
- data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
- data/spec/helpers/render_constraints_helper_spec.rb +1 -1
- data/spec/helpers/search_history_constraints_helper_spec.rb +7 -7
- data/spec/helpers/url_helper_spec.rb +20 -17
- data/spec/lib/blacklight/search_state_spec.rb +2 -2
- data/spec/lib/blacklight/utils_spec.rb +15 -15
- data/spec/lib/blacklight_spec.rb +1 -1
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/models/blacklight/configurable_spec.rb +3 -3
- data/spec/models/blacklight/configuration_spec.rb +52 -52
- data/spec/models/blacklight/document_spec.rb +10 -10
- data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
- data/spec/models/blacklight/search_builder_spec.rb +34 -34
- data/spec/models/blacklight/user_spec.rb +4 -4
- data/spec/models/bookmark_spec.rb +5 -5
- data/spec/models/record_mailer_spec.rb +11 -11
- data/spec/models/search_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +4 -4
- data/spec/presenters/document_presenter_spec.rb +94 -50
- data/spec/presenters/index_presenter_spec.rb +147 -0
- data/spec/presenters/pipeline_spec.rb +28 -0
- data/spec/presenters/show_presenter_spec.rb +287 -0
- data/spec/routing/catalog_routing_spec.rb +11 -11
- data/spec/spec_helper.rb +10 -1
- data/spec/support/backport_test.rb +38 -0
- data/spec/test_app_templates/Gemfile.extra +2 -10
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_document.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facets.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_index_default.erb_spec.rb +5 -4
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +4 -3
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +6 -5
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -2
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
- data/spec/views/catalog/facet.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +15 -14
- data/spec/views/catalog/index.html.erb_spec.rb +3 -3
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
- data/spec/views/catalog/show.html.erb_spec.rb +5 -4
- data/tasks/blacklight.rake +1 -1
- metadata +25 -4
- data/config/jetty.yml +0 -13
@@ -8,14 +8,14 @@ describe "Search Formats" do
|
|
8
8
|
CatalogController.blacklight_config.default_solr_params[:fl] = '*'
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "has an RSS XML response" do
|
12
12
|
visit "/catalog.rss?q="
|
13
13
|
expect(page).to have_content "Blacklight Search Results"
|
14
14
|
doc = Nokogiri::XML(page.body)
|
15
15
|
expect(doc.xpath("//item")).to have(10).items
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
18
|
+
it "has an ATOM XML response" do
|
19
19
|
visit "/catalog.atom?q="
|
20
20
|
expect(page).to have_content "Blacklight Search Results"
|
21
21
|
doc = Nokogiri::XML(page.body)
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe "Search History Page" do
|
5
5
|
describe "navigating from the homepage" do
|
6
|
-
it "
|
6
|
+
it "has a link to the history page" do
|
7
7
|
visit root_path
|
8
8
|
click_link 'History'
|
9
9
|
expect(page).to have_content 'Search History'
|
@@ -18,7 +18,7 @@ describe "Search History Page" do
|
|
18
18
|
click_button 'search'
|
19
19
|
click_link 'History'
|
20
20
|
end
|
21
|
-
it "
|
21
|
+
it "shows searches" do
|
22
22
|
expect(page).to have_content 'Your recent searches'
|
23
23
|
expect(page).to have_content 'book'
|
24
24
|
expect(page).to_not have_content 'dang'
|
@@ -40,7 +40,7 @@ describe "Search History Page" do
|
|
40
40
|
click_button 'search'
|
41
41
|
click_link 'History'
|
42
42
|
end
|
43
|
-
it "
|
43
|
+
it "is able to clear the history" do
|
44
44
|
click_link "Clear Search History"
|
45
45
|
expect(page).to have_content 'Cleared your search history.'
|
46
46
|
expect(page).to have_content 'You have no search history'
|
@@ -57,7 +57,7 @@ describe "Search History Page" do
|
|
57
57
|
click_link 'History'
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "saves and forget the search" do
|
61
61
|
click_button 'save'
|
62
62
|
expect(page).to have_content 'Successfully saved your search.'
|
63
63
|
click_button 'forget'
|
@@ -65,7 +65,7 @@ describe "Search History Page" do
|
|
65
65
|
expect(page).to have_button 'save'
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "does not show results after logging out" do
|
69
69
|
click_button 'save'
|
70
70
|
expect(page).to have_content 'Successfully saved your search.'
|
71
71
|
click_link 'Log Out'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe "Search Pagination" do
|
5
|
-
it "
|
5
|
+
it "has results with pagination" do
|
6
6
|
visit root_path
|
7
7
|
fill_in "q", with: ''
|
8
8
|
click_button 'search'
|
@@ -28,7 +28,7 @@ describe "Search Pagination" do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "is able to change the number of items per page" do
|
32
32
|
visit root_path
|
33
33
|
fill_in "q", with: ''
|
34
34
|
click_button 'search'
|
@@ -55,7 +55,7 @@ describe "Search Pagination" do
|
|
55
55
|
CatalogController.blacklight_config[:per_page] = original_per_page
|
56
56
|
CatalogController.blacklight_config[:default_solr_params][:rows] = original_rows
|
57
57
|
end
|
58
|
-
it "
|
58
|
+
it "uses the configured values" do
|
59
59
|
visit root_path
|
60
60
|
fill_in "q", with: ''
|
61
61
|
click_button 'search'
|
@@ -75,7 +75,7 @@ describe "Search Pagination" do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
78
|
+
it "resets the page offset to 1 when changing per page" do
|
79
79
|
visit root_path
|
80
80
|
fill_in "q", with: ''
|
81
81
|
click_button 'search'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe "Search Results" do
|
5
|
-
it "
|
5
|
+
it "has for an empty query" do
|
6
6
|
search_for ''
|
7
7
|
expect(number_of_results_from_page(page)).to eq 30
|
8
8
|
expect(page).to have_xpath("//a[contains(@href, #{2007020969})]")
|
@@ -10,7 +10,7 @@ describe "Search Results" do
|
|
10
10
|
expect(number_of_results_from_page(page)).to eq 4
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
13
|
+
it "finds same result set with or without diacritcs" do
|
14
14
|
search_for 'inmul'
|
15
15
|
expect(number_of_results_from_page(page)).to eq 1
|
16
16
|
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
@@ -18,7 +18,7 @@ describe "Search Results" do
|
|
18
18
|
search_for 'inmül'
|
19
19
|
expect(number_of_results_from_page(page)).to eq 1
|
20
20
|
end
|
21
|
-
it "
|
21
|
+
it "finds same result set for a case-insensitive query" do
|
22
22
|
search_for 'inmul'
|
23
23
|
expect(number_of_results_from_page(page)).to eq 1
|
24
24
|
expect(page).to have_xpath("//a[contains(@href, #{77826928})]")
|
@@ -27,14 +27,14 @@ describe "Search Results" do
|
|
27
27
|
expect(number_of_results_from_page(page)).to eq 1
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
30
|
+
it "orders by relevancy" do
|
31
31
|
search_for "Korea"
|
32
32
|
expect(position_in_result_page(page, '77826928')).to eq 1
|
33
33
|
expect(position_in_result_page(page, '94120425')).to eq 2
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "has an opensearch description document" do
|
38
38
|
visit root_path
|
39
39
|
tmp_value = Capybara.ignore_hidden_elements
|
40
40
|
Capybara.ignore_hidden_elements = false
|
@@ -43,12 +43,12 @@ describe "Search Results" do
|
|
43
43
|
Capybara.ignore_hidden_elements = tmp_value
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "provides search hints if there are no results" do
|
47
47
|
search_for 'asdfghj'
|
48
48
|
expect(page).to have_content "No results found for your search"
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
51
|
+
it "provides search hints if there are no results" do
|
52
52
|
visit root_path
|
53
53
|
fill_in "q", with: "inmul"
|
54
54
|
select "Author", from: "search_field"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe "Search Sort" do
|
5
|
-
it "
|
5
|
+
it "sorts on facet results with no search terms" do
|
6
6
|
visit root_path
|
7
7
|
within "#facet-language_facet" do
|
8
8
|
click_link 'English'
|
@@ -12,7 +12,7 @@ describe "Search Sort" do
|
|
12
12
|
expect(page).to have_content 'Sort by title'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "sorts on search" do
|
16
16
|
visit root_path
|
17
17
|
fill_in "q", with: 'bod'
|
18
18
|
click_button 'search'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe "Search Page" do
|
5
|
-
it "
|
5
|
+
it "shows welcome" do
|
6
6
|
visit root_path
|
7
7
|
expect(page).to have_selector("input#q")
|
8
8
|
within ("select#search_field") do
|
@@ -21,7 +21,7 @@ describe "Search Page" do
|
|
21
21
|
Capybara.ignore_hidden_elements = tmp_value
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
24
|
+
it "does searches across all fields" do
|
25
25
|
visit root_path
|
26
26
|
fill_in "q", with: 'history'
|
27
27
|
select 'All Fields', from: 'search_field'
|
@@ -62,7 +62,7 @@ describe "Search Page" do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "does searches constrained to a single field" do
|
66
66
|
visit root_path
|
67
67
|
fill_in "q", with: 'inmul'
|
68
68
|
select 'Title', from: 'search_field'
|
@@ -84,7 +84,7 @@ describe "Search Page" do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "shows vernacular (Linked 880) and call number" do
|
88
88
|
visit root_path
|
89
89
|
fill_in "q", with: 'history'
|
90
90
|
click_button 'search'
|
@@ -94,7 +94,7 @@ describe "Search Page" do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
it "
|
97
|
+
it "allows you to clear the search" do
|
98
98
|
visit root_path
|
99
99
|
fill_in "q", with: 'history'
|
100
100
|
click_button 'search'
|
@@ -111,7 +111,7 @@ describe "Search Page" do
|
|
111
111
|
expect(page).to_not have_selector "#q[value='history']"
|
112
112
|
end
|
113
113
|
|
114
|
-
it "
|
114
|
+
it "handles searches with invalid facet parameters" do
|
115
115
|
visit root_path f: { missing_s: [1]}
|
116
116
|
expect(page).to have_content "No results found for your search"
|
117
117
|
end
|
@@ -4,7 +4,6 @@ require 'spec_helper'
|
|
4
4
|
describe BlacklightHelper do
|
5
5
|
include ERB::Util
|
6
6
|
include BlacklightHelper
|
7
|
-
include Devise::TestHelpers
|
8
7
|
def blacklight_config
|
9
8
|
@config ||= Blacklight::Configuration.new.configure do |config|
|
10
9
|
config.index.title_field = 'title_display'
|
@@ -13,6 +12,7 @@ describe BlacklightHelper do
|
|
13
12
|
end
|
14
13
|
|
15
14
|
before(:each) do
|
15
|
+
allow(helper).to receive(:current_or_guest_user).and_return(User.new)
|
16
16
|
allow(helper).to receive(:search_action_path) do |*args|
|
17
17
|
search_catalog_url *args
|
18
18
|
end
|
@@ -23,27 +23,27 @@ describe BlacklightHelper do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#application_name", :test => true do
|
26
|
-
it "
|
26
|
+
it "uses the Rails application config application_name if available" do
|
27
27
|
allow(Rails.application).to receive(:config).and_return(double(application_name: "asdf"))
|
28
28
|
expect(application_name).to eq "asdf"
|
29
29
|
end
|
30
|
-
it "
|
30
|
+
it "defaults to 'Blacklight'" do
|
31
31
|
expect(application_name).to eq "Blacklight"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "#render_page_title" do
|
36
|
-
it "
|
36
|
+
it "looks in content_for(:page_title)" do
|
37
37
|
helper.content_for(:page_title) { "xyz" }
|
38
38
|
expect(helper.render_page_title).to eq "xyz"
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "looks in the @page_title ivar" do
|
42
42
|
assign(:page_title, "xyz")
|
43
43
|
expect(helper.render_page_title).to eq "xyz"
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "defaults to the application name" do
|
47
47
|
expect(helper.render_page_title).to eq helper.application_name
|
48
48
|
end
|
49
49
|
end
|
@@ -94,18 +94,18 @@ describe BlacklightHelper do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "render_index_doc_actions" do
|
97
|
-
it "
|
97
|
+
it "renders partials" do
|
98
98
|
allow(controller).to receive(:render_bookmarks_control?).and_return(true)
|
99
99
|
response = helper.render_index_doc_actions(document)
|
100
100
|
expect(response).to have_selector(".bookmark_toggle")
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
103
|
+
it "is nil if no partials are renderable" do
|
104
104
|
allow(controller).to receive(:render_bookmarks_control?).and_return(false)
|
105
105
|
expect(helper.render_index_doc_actions(document)).to be_blank
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "renders view type specific actions" do
|
109
109
|
allow(helper).to receive(:document_index_view_type).and_return(:custom)
|
110
110
|
config.view.custom.document_actions = []
|
111
111
|
expect(helper.render_index_doc_actions(document)).to be_blank
|
@@ -113,7 +113,7 @@ describe BlacklightHelper do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
describe "render_show_doc_actions" do
|
116
|
-
it "
|
116
|
+
it "renders partials" do
|
117
117
|
response = helper.render_show_doc_actions(document)
|
118
118
|
expect(response).to have_selector(".bookmark_toggle")
|
119
119
|
end
|
@@ -125,17 +125,17 @@ describe BlacklightHelper do
|
|
125
125
|
allow(helper).to receive_messages(should_render_field?: true, document_has_value?: true)
|
126
126
|
end
|
127
127
|
|
128
|
-
it "
|
128
|
+
it "is true" do
|
129
129
|
expect(helper.should_render_index_field?(double, double)).to be true
|
130
130
|
end
|
131
131
|
|
132
|
-
it "
|
132
|
+
it "is false if the document doesn't have a value for the field" do
|
133
133
|
allow(helper).to receive_messages(document_has_value?: false)
|
134
134
|
expect(helper.should_render_index_field?(double, double)).to be false
|
135
135
|
|
136
136
|
end
|
137
137
|
|
138
|
-
it "
|
138
|
+
it "is false if the configuration has the field disabled" do
|
139
139
|
allow(helper).to receive_messages(should_render_field?: false)
|
140
140
|
expect(helper.should_render_index_field?(double, double)).to be false
|
141
141
|
end
|
@@ -146,17 +146,17 @@ describe BlacklightHelper do
|
|
146
146
|
allow(helper).to receive_messages(should_render_field?: true, document_has_value?: true)
|
147
147
|
end
|
148
148
|
|
149
|
-
it "
|
149
|
+
it "is true" do
|
150
150
|
expect(helper.should_render_show_field?(double, double)).to be true
|
151
151
|
end
|
152
152
|
|
153
|
-
it "
|
153
|
+
it "is false if the document doesn't have a value for the field" do
|
154
154
|
allow(helper).to receive_messages(document_has_value?: false)
|
155
155
|
expect(helper.should_render_show_field?(double, double)).to be false
|
156
156
|
|
157
157
|
end
|
158
158
|
|
159
|
-
it "
|
159
|
+
it "is false if the configuration has the field disabled" do
|
160
160
|
allow(helper).to receive_messages(should_render_field?: false)
|
161
161
|
expect(helper.should_render_show_field?(double, double)).to be false
|
162
162
|
end
|
@@ -171,18 +171,18 @@ describe BlacklightHelper do
|
|
171
171
|
let(:doc) { double }
|
172
172
|
let(:field) { "some_field" }
|
173
173
|
|
174
|
-
it "
|
175
|
-
expect(presenter).to receive(:
|
174
|
+
it "passes the document and field through to the presenter" do
|
175
|
+
expect(presenter).to receive(:field_value).with(field, {})
|
176
176
|
helper.render_index_field_value(doc, field)
|
177
177
|
end
|
178
178
|
|
179
|
-
it "
|
180
|
-
expect(presenter).to receive(:
|
179
|
+
it "allows the document and field to be passed as hash arguments" do
|
180
|
+
expect(presenter).to receive(:field_value).with(field, {})
|
181
181
|
helper.render_index_field_value(document: doc, field: field)
|
182
182
|
end
|
183
183
|
|
184
|
-
it "
|
185
|
-
expect(presenter).to receive(:
|
184
|
+
it "allows additional options to be passed to the presenter" do
|
185
|
+
expect(presenter).to receive(:field_value).with(field, x: 1)
|
186
186
|
helper.render_index_field_value(document: doc, field: field, x: 1)
|
187
187
|
end
|
188
188
|
end
|
@@ -196,31 +196,31 @@ describe BlacklightHelper do
|
|
196
196
|
let(:doc) { double }
|
197
197
|
let(:field) { "some_field" }
|
198
198
|
|
199
|
-
it "
|
200
|
-
expect(presenter).to receive(:
|
199
|
+
it "passes the document and field through to the presenter" do
|
200
|
+
expect(presenter).to receive(:field_value).with(field, {})
|
201
201
|
helper.render_document_show_field_value(doc, field)
|
202
202
|
end
|
203
203
|
|
204
|
-
it "
|
205
|
-
expect(presenter).to receive(:
|
204
|
+
it "allows the document and field to be passed as hash arguments" do
|
205
|
+
expect(presenter).to receive(:field_value).with(field, {})
|
206
206
|
helper.render_document_show_field_value(document: doc, field: field)
|
207
207
|
end
|
208
208
|
|
209
|
-
it "
|
210
|
-
expect(presenter).to receive(:
|
209
|
+
it "allows additional options to be passed to the presenter" do
|
210
|
+
expect(presenter).to receive(:field_value).with(field, x: 1)
|
211
211
|
helper.render_document_show_field_value(document: doc, field: field, x: 1)
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
215
|
describe "#document_has_value?" do
|
216
|
-
it "
|
216
|
+
it "ifs the document has the field value" do
|
217
217
|
doc = double()
|
218
218
|
allow(doc).to receive(:has?).with('asdf').and_return(true)
|
219
219
|
field_config = double(:field => 'asdf')
|
220
220
|
expect(helper.document_has_value?(doc, field_config)).to eq true
|
221
221
|
end
|
222
222
|
|
223
|
-
it "
|
223
|
+
it "ifs the document has a highlight field value" do
|
224
224
|
doc = double()
|
225
225
|
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
226
226
|
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
@@ -228,7 +228,7 @@ describe BlacklightHelper do
|
|
228
228
|
expect(helper.document_has_value?(doc, field_config)).to eq true
|
229
229
|
end
|
230
230
|
|
231
|
-
it "
|
231
|
+
it "ifs the field has a model accessor" do
|
232
232
|
doc = double()
|
233
233
|
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
234
234
|
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(false)
|
@@ -238,13 +238,13 @@ describe BlacklightHelper do
|
|
238
238
|
end
|
239
239
|
|
240
240
|
describe "render_grouped_response?" do
|
241
|
-
it "
|
241
|
+
it "checks if the response ivar contains grouped data" do
|
242
242
|
assign(:response, double("Solr::Response", :grouped? => true))
|
243
243
|
expect(helper.render_grouped_response?).to be true
|
244
244
|
end
|
245
245
|
|
246
246
|
|
247
|
-
it "
|
247
|
+
it "checks if the response param contains grouped data" do
|
248
248
|
response = double("Solr::Response", :grouped? => true)
|
249
249
|
expect(helper.render_grouped_response?(response)).to be true
|
250
250
|
end
|
@@ -258,17 +258,17 @@ describe BlacklightHelper do
|
|
258
258
|
before :each do
|
259
259
|
allow(helper).to receive_messages spell_check_max: 5
|
260
260
|
end
|
261
|
-
it "
|
261
|
+
it "does not show suggestions if there are enough results" do
|
262
262
|
response = double(total: 10)
|
263
263
|
expect(helper.should_show_spellcheck_suggestions? response).to be false
|
264
264
|
end
|
265
265
|
|
266
|
-
it "
|
266
|
+
it "onlies show suggestions if there are very few results" do
|
267
267
|
response = double(total: 4, spelling: double(words: [1]))
|
268
268
|
expect(helper.should_show_spellcheck_suggestions? response).to be true
|
269
269
|
end
|
270
270
|
|
271
|
-
it "
|
271
|
+
it "shows suggestions only if there are spelling suggestions available" do
|
272
272
|
response = double(total: 4, spelling: double(words: []))
|
273
273
|
expect(helper.should_show_spellcheck_suggestions? response).to be false
|
274
274
|
end
|
@@ -281,7 +281,7 @@ describe BlacklightHelper do
|
|
281
281
|
allow(helper).to receive_messages(document_index_view_type: 'index_header')
|
282
282
|
end
|
283
283
|
|
284
|
-
it "
|
284
|
+
it "gets the document format from document_partial_name" do
|
285
285
|
allow(helper).to receive(:document_partial_name).with(doc, :xyz)
|
286
286
|
helper.render_document_partial(doc, :xyz)
|
287
287
|
end
|
@@ -296,7 +296,7 @@ describe BlacklightHelper do
|
|
296
296
|
|
297
297
|
context "with a solr document with empty fields" do
|
298
298
|
let(:document) { SolrDocument.new }
|
299
|
-
it "
|
299
|
+
it "is the default value" do
|
300
300
|
expect(helper.document_partial_name(document)).to eq 'default'
|
301
301
|
end
|
302
302
|
end
|
@@ -308,11 +308,11 @@ describe BlacklightHelper do
|
|
308
308
|
blacklight_config.show.display_type_field = 'my_field'
|
309
309
|
end
|
310
310
|
|
311
|
-
it "
|
311
|
+
it "uses the value in the configured display type field" do
|
312
312
|
expect(helper.document_partial_name(document)).to eq 'xyz'
|
313
313
|
end
|
314
314
|
|
315
|
-
it "
|
315
|
+
it "uses the value in the configured display type field if the action-specific field is empty" do
|
316
316
|
expect(helper.document_partial_name(document, :some_action)).to eq 'xyz'
|
317
317
|
end
|
318
318
|
end
|
@@ -326,7 +326,7 @@ describe BlacklightHelper do
|
|
326
326
|
blacklight_config.show.metadata_display_type_field = 'other_field'
|
327
327
|
end
|
328
328
|
|
329
|
-
it "
|
329
|
+
it "uses the value in the action-specific fields" do
|
330
330
|
expect(helper.document_partial_name(document, :media)).to eq 'xyz'
|
331
331
|
expect(helper.document_partial_name(document, :metadata)).to eq 'abc'
|
332
332
|
end
|
@@ -356,25 +356,25 @@ describe BlacklightHelper do
|
|
356
356
|
describe "#opensearch_description_tag" do
|
357
357
|
subject { helper.opensearch_description_tag 'title', 'href' }
|
358
358
|
|
359
|
-
it "
|
359
|
+
it "has a search rel" do
|
360
360
|
expect(subject).to have_selector "link[rel='search']", visible: false
|
361
361
|
end
|
362
362
|
|
363
|
-
it "
|
363
|
+
it "has the correct mime type" do
|
364
364
|
expect(subject).to have_selector "link[type='application/opensearchdescription+xml']", visible: false
|
365
365
|
end
|
366
366
|
|
367
|
-
it "
|
367
|
+
it "has a title attribute" do
|
368
368
|
expect(subject).to have_selector "link[title='title']", visible: false
|
369
369
|
end
|
370
370
|
|
371
|
-
it "
|
371
|
+
it "has an href attribute" do
|
372
372
|
expect(subject).to have_selector "link[href='href']", visible: false
|
373
373
|
end
|
374
374
|
end
|
375
375
|
|
376
376
|
describe "#render_document_index" do
|
377
|
-
it "
|
377
|
+
it "renders the document index with the current view type" do
|
378
378
|
allow(helper).to receive_messages(document_index_view_type: :current_view)
|
379
379
|
allow(helper).to receive(:render_document_index_with_view).with(:current_view, [], a: 1, b: 2)
|
380
380
|
helper.render_document_index [], a: 1, b: 2
|
@@ -391,25 +391,25 @@ describe BlacklightHelper do
|
|
391
391
|
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
392
392
|
end
|
393
393
|
|
394
|
-
it "
|
394
|
+
it "ignores missing templates" do
|
395
395
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
396
396
|
expect(response).to have_selector "div#documents"
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
400
400
|
describe "#document_index_view_type" do
|
401
|
-
it "
|
401
|
+
it "defaults to the default view" do
|
402
402
|
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2)
|
403
403
|
allow(helper).to receive(:default_document_index_view_type).and_return(:xyz)
|
404
404
|
expect(helper.document_index_view_type).to eq :xyz
|
405
405
|
end
|
406
406
|
|
407
|
-
it "
|
407
|
+
it "uses the query parameter" do
|
408
408
|
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2)
|
409
409
|
expect(helper.document_index_view_type(view: :a)).to eq :a
|
410
410
|
end
|
411
411
|
|
412
|
-
it "
|
412
|
+
it "uses the default view if the requested view is not available" do
|
413
413
|
allow(helper).to receive(:default_document_index_view_type).and_return(:xyz)
|
414
414
|
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2)
|
415
415
|
expect(helper.document_index_view_type(view: :c)).to eq :xyz
|
@@ -421,19 +421,19 @@ describe BlacklightHelper do
|
|
421
421
|
end
|
422
422
|
|
423
423
|
context "and no view is specified" do
|
424
|
-
it "
|
424
|
+
it "uses the saved preference" do
|
425
425
|
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2, c: 3)
|
426
426
|
expect(helper.document_index_view_type).to eq :b
|
427
427
|
end
|
428
428
|
|
429
|
-
it "
|
429
|
+
it "uses the default view if the preference is not available" do
|
430
430
|
allow(helper).to receive(:document_index_views).and_return(a: 1)
|
431
431
|
expect(helper.document_index_view_type).to eq :a
|
432
432
|
end
|
433
433
|
end
|
434
434
|
|
435
435
|
context "and a view is specified" do
|
436
|
-
it "
|
436
|
+
it "uses the query parameter" do
|
437
437
|
allow(helper).to receive(:document_index_views).and_return(a: 1, b: 2, c: 3)
|
438
438
|
expect(helper.document_index_view_type(view: :c)).to eq :c
|
439
439
|
end
|
@@ -446,6 +446,23 @@ describe BlacklightHelper do
|
|
446
446
|
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
447
447
|
end
|
448
448
|
|
449
|
+
it "uses the value defined in the blacklight configuration" do
|
450
|
+
expect(Deprecation).to receive(:warn).exactly(4).times
|
451
|
+
blacklight_config.document_presenter_class = presenter_class
|
452
|
+
expect(helper.presenter_class).to eq presenter_class
|
453
|
+
end
|
454
|
+
|
455
|
+
it "defaults to Blacklight::DocumentPresenter" do
|
456
|
+
expect(Deprecation).to receive(:warn)
|
457
|
+
expect(helper.presenter_class).to eq Blacklight::DocumentPresenter
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
describe "#index_presenter_class" do
|
462
|
+
before do
|
463
|
+
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
464
|
+
end
|
465
|
+
|
449
466
|
let :blacklight_config do
|
450
467
|
Blacklight::Configuration.new
|
451
468
|
end
|
@@ -454,38 +471,61 @@ describe BlacklightHelper do
|
|
454
471
|
double
|
455
472
|
end
|
456
473
|
|
457
|
-
it "
|
458
|
-
blacklight_config.document_presenter_class = presenter_class
|
459
|
-
expect(helper.
|
474
|
+
it "uses the value defined in the blacklight configuration" do
|
475
|
+
blacklight_config.index.document_presenter_class = presenter_class
|
476
|
+
expect(helper.index_presenter_class(nil)).to eq presenter_class
|
460
477
|
end
|
461
478
|
|
462
|
-
it "
|
463
|
-
expect(helper.
|
479
|
+
it "defaults to Blacklight::IndexPresenter" do
|
480
|
+
expect(helper.index_presenter_class(nil)).to eq Blacklight::IndexPresenter
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
describe "#show_presenter_class" do
|
485
|
+
before do
|
486
|
+
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
487
|
+
end
|
488
|
+
|
489
|
+
let :blacklight_config do
|
490
|
+
Blacklight::Configuration.new
|
491
|
+
end
|
492
|
+
|
493
|
+
let :presenter_class do
|
494
|
+
double
|
495
|
+
end
|
496
|
+
|
497
|
+
it "uses the value defined in the blacklight configuration" do
|
498
|
+
blacklight_config.show.document_presenter_class = presenter_class
|
499
|
+
expect(helper.show_presenter_class(nil)).to eq presenter_class
|
500
|
+
end
|
501
|
+
|
502
|
+
it "defaults to Blacklight::DocumentPresenter" do
|
503
|
+
expect(helper.show_presenter_class(nil)).to eq Blacklight::ShowPresenter
|
464
504
|
end
|
465
505
|
end
|
466
506
|
|
467
507
|
describe "#render_document_heading" do
|
468
508
|
before do
|
469
|
-
allow(helper).to receive(:presenter).and_return(double(
|
509
|
+
allow(helper).to receive(:presenter).and_return(double(heading: "Heading"))
|
470
510
|
end
|
471
511
|
|
472
512
|
let(:document) { double }
|
473
513
|
|
474
|
-
it "
|
514
|
+
it "accepts no arguments and render the document heading" do
|
475
515
|
expect(helper.render_document_heading).to have_selector "h4", text: "Heading"
|
476
516
|
end
|
477
517
|
|
478
|
-
it "
|
518
|
+
it "accepts the tag name as an option" do
|
479
519
|
expect(helper.render_document_heading tag: "h1").to have_selector "h1", text: "Heading"
|
480
520
|
end
|
481
521
|
|
482
|
-
it "
|
483
|
-
allow(helper).to receive(:presenter).with(document).and_return(double(
|
522
|
+
it "accepts an explicit document argument" do
|
523
|
+
allow(helper).to receive(:presenter).with(document).and_return(double(heading: "Document Heading"))
|
484
524
|
expect(helper.render_document_heading(document)).to have_selector "h4", text: "Document Heading"
|
485
525
|
end
|
486
526
|
|
487
|
-
it "
|
488
|
-
allow(helper).to receive(:presenter).with(document).and_return(double(
|
527
|
+
it "accepts the document with a tag option" do
|
528
|
+
allow(helper).to receive(:presenter).with(document).and_return(double(heading: "Document Heading"))
|
489
529
|
expect(helper.render_document_heading(document, tag: "h3")).to have_selector "h3", text: "Document Heading"
|
490
530
|
end
|
491
531
|
end
|