blacklight 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.solr_wrapper +5 -0
  4. data/.travis.yml +3 -5
  5. data/Gemfile +3 -3
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/blacklight/core.js +19 -5
  8. data/app/helpers/blacklight/blacklight_helper_behavior.rb +48 -20
  9. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
  10. data/app/helpers/blacklight/url_helper_behavior.rb +2 -1
  11. data/app/presenters/blacklight/document_presenter.rb +58 -150
  12. data/app/presenters/blacklight/field_presenter.rb +31 -0
  13. data/app/presenters/blacklight/index_presenter.rb +69 -0
  14. data/app/presenters/blacklight/link_alternate_presenter.rb +29 -0
  15. data/app/presenters/blacklight/rendering/abstract_step.rb +24 -0
  16. data/app/presenters/blacklight/rendering/helper_method.rb +23 -0
  17. data/app/presenters/blacklight/rendering/join.rb +16 -0
  18. data/app/presenters/blacklight/rendering/link_to_facet.rb +35 -0
  19. data/app/presenters/blacklight/rendering/microdata.rb +17 -0
  20. data/app/presenters/blacklight/rendering/pipeline.rb +32 -0
  21. data/app/presenters/blacklight/rendering/terminator.rb +9 -0
  22. data/app/presenters/blacklight/show_presenter.rb +93 -0
  23. data/app/services/blacklight/field_retriever.rb +58 -0
  24. data/app/views/catalog/_document_default.atom.builder +2 -3
  25. data/app/views/catalog/_document_default.rss.builder +2 -2
  26. data/app/views/kaminari/blacklight/_next_page.html.erb +9 -3
  27. data/app/views/kaminari/blacklight/_prev_page.html.erb +10 -3
  28. data/lib/blacklight/configuration.rb +15 -3
  29. data/lib/blacklight/configuration/null_field.rb +13 -0
  30. data/lib/blacklight/configuration/view_config.rb +6 -0
  31. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
  32. data/lib/generators/blacklight/templates/config/blacklight.yml +1 -1
  33. data/lib/generators/blacklight/templates/config/jetty.yml +1 -1
  34. data/spec/controllers/alternate_controller_spec.rb +2 -2
  35. data/spec/controllers/application_controller_spec.rb +1 -1
  36. data/spec/controllers/blacklight/facet_spec.rb +3 -3
  37. data/spec/controllers/blacklight/search_fields_spec.rb +7 -7
  38. data/spec/controllers/blacklight/search_helper_spec.rb +44 -44
  39. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -1
  40. data/spec/controllers/bookmarks_controller_spec.rb +6 -6
  41. data/spec/controllers/catalog_controller_spec.rb +125 -125
  42. data/spec/controllers/saved_searches_controller_spec.rb +4 -9
  43. data/spec/controllers/search_history_controller_spec.rb +3 -6
  44. data/spec/controllers/suggest_controller_spec.rb +2 -2
  45. data/spec/features/alternate_controller_spec.rb +3 -3
  46. data/spec/features/bookmarks_spec.rb +6 -6
  47. data/spec/features/did_you_mean_spec.rb +10 -10
  48. data/spec/features/facets_spec.rb +4 -4
  49. data/spec/features/record_view_spec.rb +4 -4
  50. data/spec/features/saved_searches_spec.rb +4 -4
  51. data/spec/features/search_context_spec.rb +4 -4
  52. data/spec/features/search_filters_spec.rb +10 -10
  53. data/spec/features/search_formats_spec.rb +2 -2
  54. data/spec/features/search_history_spec.rb +5 -5
  55. data/spec/features/search_pagination_spec.rb +4 -4
  56. data/spec/features/search_results_spec.rb +7 -7
  57. data/spec/features/search_sort_spec.rb +2 -2
  58. data/spec/features/search_spec.rb +6 -6
  59. data/spec/helpers/blacklight_helper_spec.rb +105 -65
  60. data/spec/helpers/catalog_helper_spec.rb +36 -36
  61. data/spec/helpers/configuration_helper_spec.rb +28 -28
  62. data/spec/helpers/facets_helper_spec.rb +39 -39
  63. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
  64. data/spec/helpers/render_constraints_helper_spec.rb +1 -1
  65. data/spec/helpers/search_history_constraints_helper_spec.rb +7 -7
  66. data/spec/helpers/url_helper_spec.rb +20 -17
  67. data/spec/lib/blacklight/search_state_spec.rb +2 -2
  68. data/spec/lib/blacklight/utils_spec.rb +15 -15
  69. data/spec/lib/blacklight_spec.rb +1 -1
  70. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  71. data/spec/models/blacklight/configurable_spec.rb +3 -3
  72. data/spec/models/blacklight/configuration_spec.rb +52 -52
  73. data/spec/models/blacklight/document_spec.rb +10 -10
  74. data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
  75. data/spec/models/blacklight/search_builder_spec.rb +34 -34
  76. data/spec/models/blacklight/user_spec.rb +4 -4
  77. data/spec/models/bookmark_spec.rb +5 -5
  78. data/spec/models/record_mailer_spec.rb +11 -11
  79. data/spec/models/search_spec.rb +1 -1
  80. data/spec/models/solr_document_spec.rb +4 -4
  81. data/spec/presenters/document_presenter_spec.rb +94 -50
  82. data/spec/presenters/index_presenter_spec.rb +147 -0
  83. data/spec/presenters/pipeline_spec.rb +28 -0
  84. data/spec/presenters/show_presenter_spec.rb +287 -0
  85. data/spec/routing/catalog_routing_spec.rb +11 -11
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/backport_test.rb +38 -0
  88. data/spec/test_app_templates/Gemfile.extra +2 -10
  89. data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
  90. data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -3
  91. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +5 -5
  92. data/spec/views/catalog/_document.html.erb_spec.rb +2 -2
  93. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  94. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +4 -4
  95. data/spec/views/catalog/_facets.html.erb_spec.rb +4 -4
  96. data/spec/views/catalog/_index_default.erb_spec.rb +5 -4
  97. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +4 -3
  98. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
  99. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  100. data/spec/views/catalog/_show_default.erb_spec.rb +6 -5
  101. data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -1
  102. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  103. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  104. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -2
  105. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
  106. data/spec/views/catalog/facet.html.erb_spec.rb +3 -3
  107. data/spec/views/catalog/index.atom.builder_spec.rb +15 -14
  108. data/spec/views/catalog/index.html.erb_spec.rb +3 -3
  109. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
  110. data/spec/views/catalog/show.html.erb_spec.rb +5 -4
  111. data/tasks/blacklight.rake +1 -1
  112. metadata +25 -4
  113. 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 "should have an RSS XML response" do
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 "should have an ATOM XML response" do
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 "should have a link to the history page" do
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 "should show searches" do
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 "should be able to clear the history" do
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 "should save and forget the search" do
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 "should not show results after logging out" do
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 "should have results with pagination" do
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 "should be able to change the number of items per page" do
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 "should use the configured values" do
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 "should reset the page offset to 1 when changing per page" do
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 "should have for an empty query" do
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 "should find same result set with or without diacritcs" do
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 "should find same result set for a case-insensitive query " do
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 "should order by relevancy" do
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 "should have an opensearch description document" do
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 "should provide search hints if there are no results" do
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 "should provide search hints if there are no results" do
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 "should sort on facet results with no search terms" do
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 "should sort on search" do
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 "should show welcome" do
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 "should do searches across all fields" do
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 "should do searches constrained to a single field" do
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 "should show vernacular (Linked 880) and call number" do
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 "should allow you to clear the search" do
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 "should gracefully handle searches with invalid facet parameters" do
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 "should use the Rails application config application_name if available" do
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 "should default to 'Blacklight'" do
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 "should look in content_for(:page_title)" do
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 "should look in the @page_title ivar" do
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 "should default to the application name" do
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 "should render partials" do
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 "should be nil if no partials are renderable" do
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 "should render view type specific actions" do
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 "should render partials" do
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 "should be true" do
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 "should be false if the document doesn't have a value for the field" do
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 "should be false if the configuration has the field disabled" do
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 "should be true" do
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 "should be false if the document doesn't have a value for the field" do
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 "should be false if the configuration has the field disabled" do
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 "should pass the document and field through to the presenter" do
175
- expect(presenter).to receive(:render_index_field_value).with(field, {})
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 "should allow the document and field to be passed as hash arguments" do
180
- expect(presenter).to receive(:render_index_field_value).with(field, {})
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 "should allow additional options to be passed to the presenter" do
185
- expect(presenter).to receive(:render_index_field_value).with(field, x: 1)
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 "should pass the document and field through to the presenter" do
200
- expect(presenter).to receive(:render_document_show_field_value).with(field, {})
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 "should allow the document and field to be passed as hash arguments" do
205
- expect(presenter).to receive(:render_document_show_field_value).with(field, {})
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 "should allow additional options to be passed to the presenter" do
210
- expect(presenter).to receive(:render_document_show_field_value).with(field, x: 1)
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 "should if the document has the field value" do
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 "should if the document has a highlight field value" do
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 "should if the field has a model accessor" do
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 "should check if the response ivar contains grouped data" do
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 "should check if the response param contains grouped data" do
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 "should not show suggestions if there are enough results" do
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 "should only show suggestions if there are very few results" do
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 "should show suggestions only if there are spelling suggestions available" do
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 "should get the document format from document_partial_name" do
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 "should be the default value" do
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 "should use the value in the configured display type field" do
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 "should use the value in the configured display type field if the action-specific field is empty" do
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 "should use the value in the action-specific fields" do
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 "should have a search rel" do
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 "should have the correct mime type" do
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 "should have a title attribute" do
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 "should have an href attribute" do
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 "should render the document index with the current view type" do
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 "should ignore missing templates" do
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 "should default to the default view" do
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 "should use the query parameter" do
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 "should use the default view if the requested view is not available" do
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 "should use the saved preference" do
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 "should use the default view if the preference is not available" do
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 "should use the query parameter" do
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 "should use the value defined in the blacklight configuration" do
458
- blacklight_config.document_presenter_class = presenter_class
459
- expect(helper.presenter_class).to eq presenter_class
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 "should default to Blacklight::DocumentPresenter" do
463
- expect(helper.presenter_class).to eq Blacklight::DocumentPresenter
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(document_heading: "Heading"))
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 "should accept no arguments and render the document heading" do
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 "should accept the tag name as an option" do
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 "should accept an explicit document argument" do
483
- allow(helper).to receive(:presenter).with(document).and_return(double(document_heading: "Document Heading"))
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 "should accept the document with a tag option" do
488
- allow(helper).to receive(:presenter).with(document).and_return(double(document_heading: "Document Heading"))
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