blacklight 4.9.0 → 5.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +22 -12
- data/Gemfile +3 -40
- data/LICENSE +1 -2
- data/README.md +1 -2
- data/Rakefile +0 -4
- data/VERSION +1 -1
- data/app/assets/images/blacklight/logo.png +0 -0
- data/app/assets/javascripts/blacklight/ajax_modal.js +190 -0
- data/app/assets/javascripts/blacklight/blacklight.js +7 -17
- data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.scss → _blacklight_base.css.scss} +0 -21
- data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +192 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +141 -0
- data/app/assets/stylesheets/blacklight/{_group.scss → _group.css.scss} +1 -1
- data/app/assets/stylesheets/blacklight/_header.css.scss +44 -0
- data/app/assets/stylesheets/blacklight/_layout.css.scss +5 -0
- data/app/assets/stylesheets/blacklight/{_modal.scss → _modal.css.scss} +7 -7
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +20 -0
- data/app/assets/stylesheets/blacklight/{blacklight.scss → blacklight.css.scss} +0 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +14 -0
- data/app/controllers/bookmarks_controller.rb +0 -4
- data/app/controllers/feedback_controller.rb +0 -4
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +45 -155
- data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -41
- data/app/helpers/blacklight/facets_helper_behavior.rb +20 -43
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -9
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -14
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +6 -6
- data/app/views/_flash_msg.html.erb +9 -2
- data/app/views/_user_util_links.html.erb +29 -15
- data/app/views/bookmarks/_tools.html.erb +4 -7
- data/app/views/bookmarks/index.html.erb +3 -2
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -1
- data/app/views/catalog/_constraints_element.html.erb +12 -8
- data/app/views/catalog/_did_you_mean.html.erb +2 -2
- data/app/views/catalog/_document_header.html.erb +3 -3
- data/app/views/catalog/_email_form.html.erb +10 -10
- data/app/views/catalog/_facet_layout.html.erb +11 -3
- data/app/views/catalog/_facet_limit.html.erb +7 -7
- data/app/views/catalog/_facet_pagination.html.erb +8 -7
- data/app/views/catalog/_facet_pivot.html.erb +3 -1
- data/app/views/catalog/_facets.html.erb +12 -9
- data/app/views/catalog/_paginate_compact.html.erb +1 -7
- data/app/views/catalog/_per_page_widget.html.erb +5 -8
- data/app/views/catalog/_previous_next_doc.html.erb +11 -9
- data/app/views/catalog/_refworks_form.html.erb +3 -4
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +16 -14
- data/app/views/catalog/_show_sidebar.html.erb +7 -9
- data/app/views/catalog/_show_tools.html.erb +13 -7
- data/app/views/catalog/_sms_form.html.erb +8 -8
- data/app/views/catalog/_sort_and_per_page.html.erb +4 -6
- data/app/views/catalog/_sort_widget.html.erb +5 -6
- data/app/views/catalog/email.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +2 -8
- data/app/views/catalog/index.html.erb +11 -6
- data/app/views/catalog/show.html.erb +5 -5
- data/app/views/catalog/sms.html.erb +1 -1
- data/app/views/catalog/sms_sent.html.erb +1 -1
- data/app/views/feedback/complete.html.erb +2 -2
- data/app/views/feedback/show.html.erb +1 -1
- data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +25 -5
- data/app/views/layouts/blacklight.html.erb +23 -23
- data/app/views/saved_searches/index.html.erb +2 -2
- data/app/views/search_history/index.html.erb +5 -7
- data/app/views/shared/_header_navbar.html.erb +23 -23
- data/blacklight.gemspec +10 -13
- data/config/locales/blacklight.en.yml +1 -12
- data/config/locales/blacklight.fr.yml +1 -12
- data/gemfiles/rails3.gemfile +21 -0
- data/gemfiles/rails4.gemfile +20 -0
- data/lib/blacklight.rb +0 -8
- data/lib/blacklight/base.rb +0 -2
- data/lib/blacklight/catalog.rb +6 -32
- data/lib/blacklight/catalog/search_context.rb +8 -48
- data/lib/blacklight/configurable.rb +2 -1
- data/lib/blacklight/configuration.rb +1 -2
- data/lib/blacklight/configuration/facet_field.rb +0 -2
- data/lib/blacklight/engine.rb +3 -3
- data/lib/blacklight/legacy_controller_methods.rb +1 -64
- data/lib/blacklight/rails/routes.rb +17 -0
- data/lib/blacklight/routes.rb +46 -40
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +21 -42
- data/lib/blacklight/solr/facet_paginator.rb +30 -54
- data/lib/blacklight/solr/request.rb +45 -0
- data/lib/blacklight/solr_helper.rb +16 -53
- data/lib/blacklight/solr_response.rb +0 -6
- data/lib/blacklight/user.rb +2 -7
- data/lib/blacklight/utils.rb +1 -9
- data/lib/generators/blacklight/assets_generator.rb +0 -14
- data/lib/generators/blacklight/blacklight_generator.rb +17 -14
- data/lib/generators/blacklight/templates/blacklight.css.scss +3 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +4 -1
- data/lib/railties/blacklight.rake +3 -1
- data/solr/sample_solr_documents.yml +641 -0
- data/spec/controllers/application_controller_spec.rb +5 -21
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +122 -119
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +5 -5
- data/spec/features/facets_spec.rb +9 -0
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +97 -41
- data/spec/features/search_results_spec.rb +14 -17
- data/spec/features/search_sort_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +170 -285
- data/spec/helpers/catalog_helper_spec.rb +57 -96
- data/spec/helpers/facets_helper_spec.rb +130 -152
- data/spec/helpers/hash_as_hidden_fields_spec.rb +9 -15
- data/spec/helpers/render_constraints_helper_spec.rb +5 -5
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/routes_spec.rb +25 -0
- data/spec/lib/blacklight/solr/request_spec.rb +37 -0
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +43 -48
- data/spec/lib/blacklight_spec.rb +6 -14
- data/spec/lib/blacklight_user_spec.rb +5 -9
- data/spec/lib/facet_paginator_spec.rb +59 -51
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +258 -304
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/utils_spec.rb +16 -46
- data/spec/models/bookmark_spec.rb +6 -7
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +6 -77
- data/spec/routing/catalog_routing_spec.rb +16 -10
- data/spec/spec_helper.rb +7 -7
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +0 -11
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +10 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -18
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -14
- data/spec/views/catalog/_index_default.erb_spec.rb +21 -21
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +21 -21
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +7 -7
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +29 -29
- data/spec/views/catalog/index.html.erb_spec.rb +6 -7
- data/tasks/blacklight.rake +8 -2
- metadata +84 -180
- data/app/assets/javascripts/blacklight/css_dropdowns.js +0 -10
- data/app/assets/javascripts/blacklight/facet_expand_contract.js +0 -41
- data/app/assets/javascripts/blacklight/lightbox_dialog.js +0 -70
- data/app/assets/javascripts/blacklight/select_submit.js +0 -27
- data/app/assets/javascripts/blacklight/zebra_stripe.js +0 -13
- data/app/assets/javascripts/improved-modal/bootstrap-modal.js +0 -355
- data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +0 -370
- data/app/assets/stylesheets/blacklight/_bookmark.scss +0 -33
- data/app/assets/stylesheets/blacklight/_catalog.scss +0 -255
- data/app/assets/stylesheets/blacklight/_dropdown.scss +0 -57
- data/app/assets/stylesheets/blacklight/_facets.scss +0 -197
- data/app/assets/stylesheets/blacklight/_footer.scss +0 -0
- data/app/assets/stylesheets/blacklight/_header.scss +0 -53
- data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
- data/app/assets/stylesheets/blacklight/_mixins.scss +0 -0
- data/app/assets/stylesheets/blacklight/_print.scss +0 -0
- data/app/assets/stylesheets/blacklight/_responsive.scss +0 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -42
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -49
- data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.scss +0 -5
- data/app/assets/stylesheets/blacklight/responsive_partials/_facets.scss +0 -37
- data/app/assets/stylesheets/blacklight/responsive_partials/_header.scss +0 -30
- data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +0 -217
- data/app/helpers/blacklight/html_head_helper_behavior.rb +0 -118
- data/app/helpers/html_head_helper.rb +0 -3
- data/app/views/catalog/_bookmark_form.html.erb +0 -7
- data/app/views/catalog/_marc_view.html.erb +0 -32
- data/app/views/catalog/librarian_view.html.erb +0 -10
- data/config/routes.rb +0 -17
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +0 -107
- data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
- data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
- data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
- data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
- data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
- data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -80
- data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
- data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +0 -135
- data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +0 -17
- data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +0 -25
- data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +0 -21
- data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +0 -41
- data/doc/Blacklight-Add-ons.md +0 -28
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -135
- data/doc/Code4Lib-2014.md +0 -48
- data/doc/Community-principles.md +0 -44
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -25
- data/doc/Examples.md +0 -94
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/FAQs.md +0 -1
- data/doc/Home.md +0 -80
- data/doc/How-to-release-a-version.md +0 -29
- data/doc/Indexing-your-data-into-solr.md +0 -32
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -17
- data/doc/Pagination.md +0 -51
- data/doc/Providing-your-own-view-templates.md +0 -109
- data/doc/Quickstart.md +0 -115
- data/doc/README_SOLR.md +0 -245
- data/doc/Release-Notes-And-Upgrade-Guides.md +0 -20
- data/doc/Roadmap.md +0 -43
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Theming.md +0 -64
- data/doc/User-Authentication.md +0 -60
- data/doc/testing.md +0 -57
- data/lib/SolrMarc.jar +0 -0
- data/lib/blacklight/mash.rb +0 -19
- data/lib/blacklight/solr/document/marc.rb +0 -71
- data/lib/blacklight/solr/document/marc_export.rb +0 -590
- data/lib/generators/blacklight/marc_generator.rb +0 -66
- data/lib/generators/blacklight/templates/blacklight.scss +0 -4
- data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +0 -37
- data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +0 -37
- data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +0 -97
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +0 -47
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +0 -126
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +0 -1
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +0 -407
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +0 -56
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +0 -379
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +0 -50
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +0 -101
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +0 -490
- data/lib/railties/solr_marc.rake +0 -162
- data/spec/data/test_data.utf8.mrc +0 -1
- data/spec/features/librarian_view_spec.rb +0 -13
- data/spec/helpers/html_head_helper_spec.rb +0 -164
- data/spec/lib/blacklight_solr_document_marc_spec.rb +0 -89
- data/spec/lib/marc_export_spec.rb +0 -746
- data/spec/lib/tasks/solr_marc_task_spec.rb +0 -60
- data/spec/requests/alternate_controller_spec.rb +0 -16
- data/spec/routing/routes_spec.rb +0 -20
- data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -49
- data/test_support/data/test_data.utf8.mrc +0 -1
@@ -15,26 +15,26 @@ describe SearchHistoryController do
|
|
15
15
|
session[:history] = [@one.id, @three.id]
|
16
16
|
get :index
|
17
17
|
@searches = assigns(:searches)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
@searches.length.should == 2
|
19
|
+
@searches.should include(@one)
|
20
|
+
@searches.should include(@three)
|
21
|
+
@searches.should_not include(@two)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should tolerate bad ids in session" do
|
25
25
|
session[:history] = [@one.id, @three.id, "NOT_IN_DB"]
|
26
26
|
get :index
|
27
27
|
@searches = assigns(:searches)
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
@searches.length.should == 2
|
29
|
+
@searches.should include(@one)
|
30
|
+
@searches.should include(@three)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should not fetch any searches if there is no history" do
|
34
34
|
session[:history] = []
|
35
35
|
get :index
|
36
36
|
@searches = assigns(:searches)
|
37
|
-
|
37
|
+
@searches.length.should == 0
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -3,19 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe "Alternate Controller Behaviors" do
|
4
4
|
it "should have the correct per-page form" do
|
5
5
|
visit alternate_index_path
|
6
|
-
|
6
|
+
page.should have_selector("form[action='#{alternate_index_path}']")
|
7
7
|
fill_in "q", :with=>"history"
|
8
8
|
click_button 'search'
|
9
9
|
expect(current_path).to match /#{alternate_index_path}/
|
10
|
-
within
|
11
|
-
|
10
|
+
within "#per_page-dropdown .dropdown-menu" do
|
11
|
+
click_on '10 per page'
|
12
12
|
end
|
13
13
|
expect(current_path).to match /#{alternate_index_path}/
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should have the correct search field form" do
|
17
17
|
visit alternate_index_path
|
18
|
-
|
18
|
+
page.should have_selector("form[action='#{alternate_index_path}']")
|
19
19
|
fill_in "q", :with=>"history"
|
20
20
|
click_button 'search'
|
21
21
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -25,7 +25,7 @@ describe "Alternate Controller Behaviors" do
|
|
25
25
|
|
26
26
|
it "should display document thumbnails" do
|
27
27
|
visit alternate_index_path
|
28
|
-
|
28
|
+
page.should have_selector("form[action='#{alternate_index_path}']")
|
29
29
|
fill_in "q", :with=>"history"
|
30
30
|
click_button 'search'
|
31
31
|
expect(page).to have_selector ".document-thumbnail"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Facets" do
|
4
|
+
it "should show a single facet's values" do
|
5
|
+
visit catalog_facet_path("language_facet")
|
6
|
+
expect(page).to have_selector(".modal-title", :text => "Language")
|
7
|
+
expect(page).to have_selector(".facet_select", :text => "Tibetan")
|
8
|
+
end
|
9
|
+
end
|
@@ -34,7 +34,7 @@ describe "Record View" do
|
|
34
34
|
end
|
35
35
|
it "should not display 404" do
|
36
36
|
visit catalog_path('this_id_does_not_exist')
|
37
|
-
|
37
|
+
page.driver.status_code.should == 404
|
38
38
|
expect(page).to have_content "Sorry, you have requested a record that doesn't exist."
|
39
39
|
end
|
40
40
|
end
|
@@ -3,25 +3,32 @@ require 'spec_helper'
|
|
3
3
|
describe "Facets" do
|
4
4
|
it "should work without a search term" do
|
5
5
|
visit root_path
|
6
|
-
within '
|
6
|
+
within '#facet-language' do
|
7
7
|
click_link "Tibetan"
|
8
8
|
end
|
9
9
|
within "#sortAndPerPage" do
|
10
10
|
expect(page).to have_content "1 - 6 of 6"
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
expect(page).to have_selector(".blacklight-language_facet")
|
14
|
+
expect(page).to have_selector(".blacklight-language_facet.facet_limit-active")
|
15
|
+
|
16
|
+
within "#facet-language" do
|
17
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
18
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "6")
|
14
19
|
end
|
15
20
|
|
16
21
|
click_link "India"
|
17
22
|
within ("#sortAndPerPage") do
|
18
23
|
expect(page).to have_content "1 - 2 of 2"
|
19
24
|
end
|
20
|
-
within
|
21
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
25
|
+
within "#facet-language" do
|
26
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
27
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
22
28
|
end
|
23
|
-
within
|
24
|
-
expect(page).to have_selector("span.selected", :text => "India
|
29
|
+
within "#facet-region" do
|
30
|
+
expect(page).to have_selector("span.selected", :text => "India")
|
31
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
25
32
|
end
|
26
33
|
end
|
27
34
|
|
@@ -33,14 +40,15 @@ describe "Facets" do
|
|
33
40
|
expect(page).to have_content "1 - 9 of 9"
|
34
41
|
end
|
35
42
|
|
36
|
-
within "
|
43
|
+
within "#facet-language" do
|
37
44
|
click_link "Tibetan"
|
38
45
|
end
|
39
46
|
within ("#sortAndPerPage") do
|
40
47
|
expect(page).to have_content "1 - 2 of 2"
|
41
48
|
end
|
42
|
-
within
|
43
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
49
|
+
within "#facet-language" do
|
50
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
51
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
44
52
|
end
|
45
53
|
within "#appliedParams" do
|
46
54
|
expect(page).to have_content "You searched for:"
|
@@ -52,23 +60,26 @@ describe "Facets" do
|
|
52
60
|
within ("#sortAndPerPage") do
|
53
61
|
expect(page).to have_content "1 entry found"
|
54
62
|
end
|
55
|
-
within
|
56
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
63
|
+
within "#facet-language" do
|
64
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
65
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
57
66
|
end
|
58
|
-
within(".blacklight-pub_date") do
|
59
|
-
expect(page).to have_selector("span.selected", :text => "2004
|
67
|
+
within(".blacklight-pub_date") do
|
68
|
+
expect(page).to have_selector("span.selected", :text => "2004")
|
69
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
63
73
|
it "should allow removing filters" do
|
64
74
|
visit root_path
|
65
|
-
within "
|
75
|
+
within "#facet-language" do
|
66
76
|
click_link "Tibetan"
|
67
77
|
end
|
68
|
-
within
|
69
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
78
|
+
within "#facet-language" do
|
79
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
80
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "6")
|
70
81
|
end
|
71
|
-
within
|
82
|
+
within "#facet-language" do
|
72
83
|
click_link 'remove'
|
73
84
|
end
|
74
85
|
expect(page).to_not have_link 'remove'
|
@@ -79,29 +90,34 @@ describe "Facets" do
|
|
79
90
|
visit root_path
|
80
91
|
fill_in "q", with: 'history'
|
81
92
|
click_button 'search'
|
82
|
-
within "
|
83
|
-
click_link
|
93
|
+
within "#facet-language" do
|
94
|
+
click_link 'Tibetan'
|
84
95
|
end
|
85
|
-
within
|
86
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
96
|
+
within "#facet-language" do
|
97
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
98
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
87
99
|
end
|
88
100
|
|
89
101
|
click_link '2004'
|
90
102
|
|
91
|
-
within
|
92
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
103
|
+
within "#facet-language" do
|
104
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
105
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
93
106
|
end
|
94
|
-
within(".blacklight-pub_date") do
|
95
|
-
expect(page).to have_selector("span.selected", :text => "2004
|
107
|
+
within(".blacklight-pub_date") do
|
108
|
+
expect(page).to have_selector("span.selected", :text => "2004")
|
109
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
96
110
|
end
|
97
111
|
fill_in "q", with: 'china'
|
98
112
|
click_button 'search'
|
99
113
|
|
100
|
-
within
|
101
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
114
|
+
within "#facet-language" do
|
115
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
116
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
102
117
|
end
|
103
|
-
within(".blacklight-pub_date") do
|
104
|
-
expect(page).to have_selector("span.selected", :text => "2004
|
118
|
+
within(".blacklight-pub_date") do
|
119
|
+
expect(page).to have_selector("span.selected", :text => "2004")
|
120
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "1")
|
105
121
|
end
|
106
122
|
end
|
107
123
|
|
@@ -109,15 +125,17 @@ describe "Facets" do
|
|
109
125
|
visit root_path
|
110
126
|
fill_in "q", with: 'history'
|
111
127
|
click_button 'search'
|
112
|
-
within
|
128
|
+
within "#facet-language" do
|
113
129
|
click_link 'Tibetan'
|
114
130
|
end
|
115
|
-
within
|
116
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
131
|
+
within "#facet-language" do
|
132
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
133
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
117
134
|
end
|
118
135
|
click_link 'title'
|
119
|
-
within
|
120
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
136
|
+
within "#facet-language" do
|
137
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
138
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
121
139
|
end
|
122
140
|
within "#appliedParams" do
|
123
141
|
expect(page).to have_content "You searched for:"
|
@@ -129,22 +147,60 @@ describe "Facets" do
|
|
129
147
|
visit root_path
|
130
148
|
fill_in "q", with: 'history'
|
131
149
|
click_button 'search'
|
132
|
-
|
133
|
-
within("div.blacklight-language_facet") do
|
150
|
+
within "#facet-language" do
|
134
151
|
click_link 'Tibetan'
|
135
152
|
end
|
136
|
-
within
|
137
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
153
|
+
within "#facet-language" do
|
154
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
155
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
138
156
|
end
|
139
157
|
within '#per_page-dropdown' do
|
140
158
|
click_link '20'
|
141
159
|
end
|
142
|
-
within
|
143
|
-
expect(page).to have_selector("span.selected", :text => "Tibetan
|
160
|
+
within "#facet-language" do
|
161
|
+
expect(page).to have_selector("span.selected", :text => "Tibetan")
|
162
|
+
expect(page).to have_selector("span.facet-count.selected", :text => "2")
|
144
163
|
end
|
145
164
|
within "#appliedParams" do
|
146
165
|
expect(page).to have_content "You searched for:"
|
147
166
|
expect(page).to have_content "history"
|
148
167
|
end
|
149
168
|
end
|
169
|
+
it "should be collapsed when not selected", :js => true do
|
170
|
+
pending("Test passes locally but not on Travis.")
|
171
|
+
visit root_path
|
172
|
+
within(".blacklight-subject_topic_facet") do
|
173
|
+
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
it "should expand when the heading is clicked", :js => true do
|
177
|
+
pending("Test passes locally but not on Travis.")
|
178
|
+
visit root_path
|
179
|
+
within(".blacklight-subject_topic_facet") do
|
180
|
+
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
181
|
+
find(".panel-heading").click
|
182
|
+
expect(page).to have_selector(".panel-collapse", :visible => true)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
it "should expand when the anchor is clicked", :js => true do
|
186
|
+
pending("Test passes locally but not on Travis.")
|
187
|
+
visit root_path
|
188
|
+
within(".blacklight-subject_topic_facet") do
|
189
|
+
expect(page).not_to have_selector(".panel-collapse", :visible => true)
|
190
|
+
click_link "Topic"
|
191
|
+
expect(page).to have_selector(".panel-collapse", :visible => true)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
it "should keep selected facets expanded on page load", :js => true do
|
195
|
+
pending("Test passes locally but not on Travis.")
|
196
|
+
visit root_path
|
197
|
+
within(".blacklight-subject_topic_facet") do
|
198
|
+
click_link "Topic"
|
199
|
+
expect(page).to have_selector(".panel-collapse", :visible => true)
|
200
|
+
click_link "Japanese drama"
|
201
|
+
end
|
202
|
+
within(".blacklight-subject_topic_facet") do
|
203
|
+
expect(page).to have_selector(".panel-collapse", :visible => true)
|
204
|
+
end
|
205
|
+
end
|
150
206
|
end
|
@@ -4,34 +4,34 @@ require 'spec_helper'
|
|
4
4
|
describe "Search Results" do
|
5
5
|
it "should have for an empty query" do
|
6
6
|
search_for ''
|
7
|
-
|
8
|
-
|
7
|
+
number_of_results_from_page(page).should == 30
|
8
|
+
page.should have_xpath("//a[contains(@href, #{2007020969})]")
|
9
9
|
search_for 'korea'
|
10
|
-
|
10
|
+
number_of_results_from_page(page).should == 4
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should find same result set with or without diacritcs" do
|
14
14
|
search_for 'inmul'
|
15
|
-
|
16
|
-
|
15
|
+
number_of_results_from_page(page).should == 1
|
16
|
+
page.should have_xpath("//a[contains(@href, #{77826928})]")
|
17
17
|
|
18
18
|
search_for 'inmül'
|
19
|
-
|
19
|
+
number_of_results_from_page(page).should == 1
|
20
20
|
end
|
21
21
|
it "should find same result set for a case-insensitive query " do
|
22
22
|
search_for 'inmul'
|
23
|
-
|
24
|
-
|
23
|
+
number_of_results_from_page(page).should == 1
|
24
|
+
page.should have_xpath("//a[contains(@href, #{77826928})]")
|
25
25
|
|
26
26
|
search_for 'INMUL'
|
27
|
-
|
27
|
+
number_of_results_from_page(page).should == 1
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should order by relevancy" do
|
31
31
|
search_for "Korea"
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
position_in_result_page(page, '77826928').should == 1
|
33
|
+
position_in_result_page(page, '94120425').should == 2
|
34
|
+
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should have an opensearch description document" do
|
@@ -49,10 +49,7 @@ describe "Search Results" do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should pass the current search id through", :js => true do
|
52
|
-
|
53
|
-
visit root_path
|
54
|
-
fill_in "q", with: ''
|
55
|
-
click_button 'search'
|
52
|
+
search_for ''
|
56
53
|
search_id = Search.last.id.to_s
|
57
54
|
click_on 'Pluvial nectar of blessings'
|
58
55
|
expect(page).to have_content "« Previous | 10 of 30 | Next »"
|
@@ -83,7 +80,7 @@ def position_in_result_page(page, id)
|
|
83
80
|
end
|
84
81
|
i.to_i
|
85
82
|
end
|
86
|
-
|
83
|
+
|
87
84
|
def number_of_results_for_query(query)
|
88
85
|
visit root_path
|
89
86
|
fill_in "q", :with => query
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "Search Sort" do
|
4
4
|
it "should sort on facet results with no search terms" do
|
5
5
|
visit root_path
|
6
|
-
within
|
6
|
+
within "#facet-language" do
|
7
7
|
click_link 'English'
|
8
8
|
end
|
9
9
|
expect(page).to have_content 'Sort by relevance'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#ste -*- encoding : utf-8 -*-
|
2
1
|
# -*- coding: UTF-8 -*-
|
3
2
|
require 'spec_helper'
|
4
3
|
|
@@ -82,7 +81,7 @@ describe BlacklightHelper do
|
|
82
81
|
end
|
83
82
|
|
84
83
|
before(:each) do
|
85
|
-
|
84
|
+
helper.stub(:search_action_url) do |*args|
|
86
85
|
catalog_index_url *args
|
87
86
|
end
|
88
87
|
end
|
@@ -91,221 +90,157 @@ describe BlacklightHelper do
|
|
91
90
|
|
92
91
|
end
|
93
92
|
|
94
|
-
describe "deprecated methods" do
|
95
|
-
describe "#index_field_names" do
|
96
|
-
it "should warn" do
|
97
|
-
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
98
|
-
allow(helper).to receive_messages(:index_fields => {})
|
99
|
-
helper.index_field_names
|
100
|
-
end
|
101
|
-
end
|
102
|
-
describe "#index_field_labels" do
|
103
|
-
it "should warn" do
|
104
|
-
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
105
|
-
allow(helper).to receive_messages(:index_fields => {})
|
106
|
-
helper.index_field_labels
|
107
|
-
end
|
108
|
-
end
|
109
|
-
describe "#document_show_field_labels" do
|
110
|
-
it "should warn" do
|
111
|
-
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
112
|
-
allow(helper).to receive_messages(:document_show_fields => {})
|
113
|
-
helper.document_show_field_labels
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "#render_document_list_partial" do
|
118
|
-
it "should warn" do
|
119
|
-
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
|
120
|
-
allow(helper).to receive(:render)
|
121
|
-
helper.render_document_list_partial
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
93
|
describe "#application_name", :test => true do
|
127
94
|
it "should use the Rails application config application_name if available" do
|
128
|
-
|
129
|
-
|
130
|
-
|
95
|
+
Rails.application.config.stub(:application_name => 'asdf')
|
96
|
+
Rails.application.config.should_receive(:respond_to?).with(:application_name).and_return(true)
|
97
|
+
application_name.should == 'asdf'
|
131
98
|
end
|
132
99
|
it "should default to 'Blacklight'" do
|
133
|
-
|
100
|
+
application_name.should == "Blacklight"
|
134
101
|
end
|
135
102
|
end
|
136
103
|
|
137
104
|
describe "link_back_to_catalog" do
|
138
|
-
|
139
|
-
|
140
|
-
@bookmarks_query_params = { :page => "2", :controller=>'bookmarks'}
|
141
|
-
end
|
105
|
+
let(:query_params) {{:q => "query", :f => "facets", :per_page => "10", :page => "2", :controller=>'catalog'}}
|
106
|
+
let(:bookmarks_query_params) {{ :page => "2", :controller=>'bookmarks'}}
|
142
107
|
|
143
108
|
it "should build a link tag to catalog using session[:search] for query params" do
|
144
|
-
|
109
|
+
helper.stub(:current_search_session).and_return double(:query_params => query_params)
|
145
110
|
tag = helper.link_back_to_catalog
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
111
|
+
tag.should =~ /q=query/
|
112
|
+
tag.should =~ /f=facets/
|
113
|
+
tag.should =~ /per_page=10/
|
114
|
+
tag.should =~ /page=2/
|
150
115
|
end
|
151
116
|
|
152
117
|
it "should build a link tag to bookmarks using session[:search] for query params" do
|
153
|
-
|
118
|
+
helper.stub(:current_search_session).and_return double(:query_params => bookmarks_query_params)
|
154
119
|
tag = helper.link_back_to_catalog
|
155
|
-
|
156
|
-
|
157
|
-
|
120
|
+
tag.should =~ /Back to Bookmarks/
|
121
|
+
tag.should =~ /\/bookmarks/
|
122
|
+
tag.should =~ /page=2/
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "when an alternate scope is passed in" do
|
126
|
+
let(:my_engine) { double("Engine") }
|
127
|
+
|
128
|
+
it "should call url_for on the engine scope" do
|
129
|
+
helper.stub(:current_search_session).and_return double(:query_params => query_params)
|
130
|
+
expect(my_engine).to receive(:url_for).and_return(url_for(query_params))
|
131
|
+
tag = helper.link_back_to_catalog(route_set: my_engine)
|
132
|
+
tag.should =~ /Back to Search/
|
133
|
+
tag.should =~ /q=query/
|
134
|
+
tag.should =~ /f=facets/
|
135
|
+
tag.should =~ /per_page=10/
|
136
|
+
tag.should =~ /page=2/
|
137
|
+
end
|
158
138
|
end
|
159
139
|
end
|
160
140
|
|
161
141
|
describe "link_to_query" do
|
162
142
|
it "should build a link tag to catalog using query string (no other params)" do
|
163
143
|
query = "brilliant"
|
164
|
-
|
144
|
+
self.should_receive(:params).and_return({})
|
165
145
|
tag = link_to_query(query)
|
166
|
-
|
167
|
-
|
146
|
+
tag.should =~ /q=#{query}/
|
147
|
+
tag.should =~ />#{query}<\/a>/
|
168
148
|
end
|
169
149
|
it "should build a link tag to catalog using query string and other existing params" do
|
170
150
|
query = "wonderful"
|
171
|
-
|
151
|
+
self.should_receive(:params).and_return({:qt => "title_search", :per_page => "50"})
|
172
152
|
tag = link_to_query(query)
|
173
|
-
|
174
|
-
|
153
|
+
tag.should =~ /qt=title_search/
|
154
|
+
tag.should =~ /per_page=50/
|
175
155
|
end
|
176
156
|
it "should ignore existing :page param" do
|
177
157
|
query = "yes"
|
178
|
-
|
158
|
+
self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
|
179
159
|
tag = link_to_query(query)
|
180
|
-
|
181
|
-
|
160
|
+
tag.should =~ /qt=author_search/
|
161
|
+
tag.should_not =~ /page/
|
182
162
|
end
|
183
163
|
it "should be html_safe" do
|
184
164
|
query = "brilliant"
|
185
|
-
|
165
|
+
self.should_receive(:params).and_return({:page => "2", :qt => "author_search"})
|
186
166
|
tag = link_to_query(query)
|
187
|
-
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe "sanitize_search_params" do
|
192
|
-
it "should strip nil values" do
|
193
|
-
result = sanitize_search_params(:a => nil, :b => 1)
|
194
|
-
expect(result).to_not have_key(:a)
|
195
|
-
expect(result[:b]).to eq 1
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should remove blacklisted keys" do
|
199
|
-
result = sanitize_search_params(:action => true, :controller => true, :id => true, :commit => true, :utf8 => true)
|
200
|
-
expect(result).to be_empty
|
167
|
+
tag.html_safe?.should == true
|
201
168
|
end
|
202
169
|
end
|
203
170
|
|
204
171
|
describe "params_for_search" do
|
205
|
-
around(:each) do |example|
|
206
|
-
Deprecation.silence(Blacklight::BlacklightHelperBehavior) { example.run }
|
207
|
-
end
|
208
|
-
|
209
172
|
def params
|
210
173
|
{ 'default' => 'params'}
|
211
174
|
end
|
212
175
|
|
213
176
|
it "should default to using the controller's params" do
|
214
177
|
result = params_for_search
|
215
|
-
|
216
|
-
|
178
|
+
result.should == params
|
179
|
+
params.object_id.should_not == result.object_id
|
217
180
|
end
|
218
181
|
|
219
182
|
it "should let you pass in params to use" do
|
220
|
-
source_params = { :q => 'query'}
|
221
|
-
result = params_for_search(source_params, {})
|
222
|
-
expect(source_params).to eq(result)
|
223
|
-
expect(source_params.object_id).not_to eq(result.object_id)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should let you pass in params to use (the deprecated way)" do
|
227
183
|
source_params = { :q => 'query'}
|
228
184
|
result = params_for_search(:params => source_params )
|
229
|
-
|
230
|
-
|
231
|
-
end
|
232
|
-
|
233
|
-
|
234
|
-
it "should let you pass in params to merge into the controller's params" do
|
235
|
-
source_params = { :q => 'query'}
|
236
|
-
result = params_for_search( source_params )
|
237
|
-
expect(result).to include(:q => 'query', 'default' => 'params')
|
185
|
+
source_params.should == result
|
186
|
+
source_params.object_id.should_not == result.object_id
|
238
187
|
end
|
239
188
|
|
240
189
|
it "should not return blacklisted elements" do
|
241
190
|
source_params = { :action => 'action', :controller => 'controller', :id => "id", :commit => 'commit'}
|
242
|
-
result = params_for_search(source_params
|
243
|
-
|
191
|
+
result = params_for_search(:params => source_params )
|
192
|
+
result.keys.should_not include(:action, :controller, :commit, :id)
|
244
193
|
|
245
194
|
end
|
246
195
|
|
247
196
|
it "should adjust the current page if the per_page changes" do
|
248
197
|
source_params = { :per_page => 20, :page => 5}
|
249
|
-
result = params_for_search(source_params, :per_page => 100)
|
250
|
-
|
198
|
+
result = params_for_search(:params => source_params, :per_page => 100)
|
199
|
+
result[:page].should == 1
|
251
200
|
end
|
252
201
|
|
253
202
|
it "should not adjust the current page if the per_page is the same as it always was" do
|
254
203
|
source_params = { :per_page => 20, :page => 5}
|
255
|
-
result = params_for_search(source_params, :per_page => 20)
|
256
|
-
|
204
|
+
result = params_for_search(:params => source_params, :per_page => 20)
|
205
|
+
result[:page].should == 5
|
257
206
|
end
|
258
207
|
|
259
208
|
it "should adjust the current page if the sort changes" do
|
260
209
|
source_params = { :sort => 'field_a', :page => 5}
|
261
|
-
result = params_for_search(source_params, :sort => 'field_b')
|
262
|
-
|
210
|
+
result = params_for_search(:params => source_params, :sort => 'field_b')
|
211
|
+
result[:page].should == 1
|
263
212
|
end
|
264
213
|
|
265
214
|
it "should not adjust the current page if the sort is the same as it always was" do
|
266
215
|
source_params = { :sort => 'field_a', :page => 5}
|
267
|
-
result = params_for_search(source_params, :sort => 'field_a')
|
268
|
-
|
216
|
+
result = params_for_search(:params => source_params, :sort => 'field_a')
|
217
|
+
result[:page].should == 5
|
269
218
|
end
|
270
219
|
|
271
220
|
describe "omit keys parameter" do
|
272
221
|
it "should omit keys by key name" do
|
273
222
|
source_params = { :a => 1, :b => 2, :c => 3}
|
274
|
-
result = params_for_search(source_params, :omit_keys => [:a, :b] )
|
223
|
+
result = params_for_search(:params => source_params, :omit_keys => [:a, :b] )
|
275
224
|
|
276
|
-
|
277
|
-
|
225
|
+
result.keys.should_not include(:a, :b)
|
226
|
+
result[:c].should == 3
|
278
227
|
end
|
279
228
|
|
280
229
|
it "should remove keys if a key/value pair was passed and no values are left for that key" do
|
281
230
|
source_params = { :f => ['a']}
|
282
|
-
result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
|
283
|
-
|
231
|
+
result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
|
232
|
+
result.keys.should_not include(:f)
|
284
233
|
end
|
285
234
|
|
286
235
|
it "should only remove keys when a key/value pair is based that are in that pair" do
|
287
236
|
|
288
237
|
source_params = { :f => ['a', 'b']}
|
289
|
-
result = params_for_search(source_params, :omit_keys => [{:f => 'a' }])
|
290
|
-
|
291
|
-
|
238
|
+
result = params_for_search(:params => source_params, :omit_keys => [{:f => 'a' }])
|
239
|
+
result[:f].should_not include('a')
|
240
|
+
result[:f].should include('b')
|
292
241
|
end
|
293
242
|
end
|
294
243
|
|
295
|
-
describe "params_for_search with a block" do
|
296
|
-
it "should evalute the block and allow it to add or remove keys" do
|
297
|
-
result = params_for_search({:a => 1, :b => 2}, :c => 3) do |params|
|
298
|
-
params.except! :a, :b
|
299
|
-
params[:d] = 'd'
|
300
|
-
end
|
301
|
-
|
302
|
-
expect(result.keys).not_to include(:a, :b)
|
303
|
-
expect(result[:c]).to eq 3
|
304
|
-
expect(result[:d]).to eq 'd'
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
|
309
244
|
end
|
310
245
|
|
311
246
|
describe "search_as_hidden_fields" do
|
@@ -314,9 +249,7 @@ describe BlacklightHelper do
|
|
314
249
|
end
|
315
250
|
describe "for default arguments" do
|
316
251
|
it "should default to omitting :page" do
|
317
|
-
|
318
|
-
expect(search_as_hidden_fields).not_to have_selector("input[name='page']")
|
319
|
-
end
|
252
|
+
search_as_hidden_fields.should_not have_selector("input[name='page']")
|
320
253
|
end
|
321
254
|
end
|
322
255
|
end
|
@@ -325,18 +258,18 @@ describe BlacklightHelper do
|
|
325
258
|
describe "render body class" do
|
326
259
|
it "should include a serialization of the current controller name" do
|
327
260
|
@controller = double("controller")
|
328
|
-
|
329
|
-
|
261
|
+
@controller.stub(:controller_name).and_return("123456")
|
262
|
+
@controller.stub(:action_name).and_return("abcdef")
|
330
263
|
|
331
|
-
|
264
|
+
render_body_class.split(' ').should include('blacklight-123456')
|
332
265
|
end
|
333
266
|
|
334
267
|
it "should include a serialization of the current action name" do
|
335
268
|
@controller = double("controller")
|
336
|
-
|
337
|
-
|
269
|
+
@controller.stub(:controller_name).and_return("123456")
|
270
|
+
@controller.stub(:action_name).and_return("abcdef")
|
338
271
|
|
339
|
-
|
272
|
+
render_body_class.split(' ').should include('blacklight-123456-abcdef')
|
340
273
|
end
|
341
274
|
end
|
342
275
|
|
@@ -345,12 +278,12 @@ describe BlacklightHelper do
|
|
345
278
|
it "should consist of the show heading field when available" do
|
346
279
|
@document = SolrDocument.new('title_display' => "A Fake Document")
|
347
280
|
|
348
|
-
|
281
|
+
document_heading.should == "A Fake Document"
|
349
282
|
end
|
350
283
|
|
351
284
|
it "should fallback on the document id if no title is available" do
|
352
285
|
@document = SolrDocument.new(:id => '123456')
|
353
|
-
|
286
|
+
document_heading.should == '123456'
|
354
287
|
end
|
355
288
|
end
|
356
289
|
|
@@ -358,97 +291,77 @@ describe BlacklightHelper do
|
|
358
291
|
it "should consist of #document_heading wrapped in a <h1>" do
|
359
292
|
@document = SolrDocument.new('title_display' => "A Fake Document")
|
360
293
|
|
361
|
-
|
362
|
-
|
294
|
+
render_document_heading.should have_selector("h4", :text => "A Fake Document", :count => 1)
|
295
|
+
render_document_heading.html_safe?.should == true
|
363
296
|
end
|
364
297
|
it "should join the values if it is an array" do
|
365
298
|
@document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
|
366
299
|
|
367
|
-
|
368
|
-
|
300
|
+
render_document_heading.should have_selector("h4", :text => "A Fake Document, Something Else", :count => 1)
|
301
|
+
render_document_heading.html_safe?.should == true
|
369
302
|
end
|
370
303
|
end
|
371
304
|
|
372
305
|
describe "document_show_html_title" do
|
373
306
|
it "should join the values if it is an array" do
|
374
307
|
@document = SolrDocument.new('title_display' => ["A Fake Document", 'Something Else'])
|
375
|
-
|
308
|
+
document_show_html_title.should == "A Fake Document, Something Else"
|
376
309
|
end
|
377
310
|
end
|
378
311
|
|
379
312
|
describe "document_index_view_type" do
|
380
313
|
it "should default to 'list'" do
|
381
|
-
|
314
|
+
document_index_view_type.should == 'list'
|
382
315
|
end
|
383
316
|
|
384
317
|
it "should pluck values out of params" do
|
385
|
-
|
318
|
+
blacklight_config.stub(:document_index_view_types) { ['list', 'asdf'] }
|
386
319
|
params[:view] = 'asdf'
|
387
|
-
|
320
|
+
document_index_view_type.should == 'asdf'
|
388
321
|
|
389
322
|
params[:view] = 'not_in_list'
|
390
|
-
|
391
|
-
end
|
392
|
-
|
393
|
-
it "should pluck values from supplied params" do
|
394
|
-
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'asdf'] }
|
395
|
-
params[:view] = 'asdf'
|
396
|
-
expect(document_index_view_type(:view => 'list')).to eq 'list'
|
323
|
+
document_index_view_type.should == 'list'
|
397
324
|
end
|
398
325
|
end
|
399
326
|
|
400
|
-
describe "start_over_path" do
|
401
|
-
it 'should be the catalog path with the current view type' do
|
402
|
-
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
|
403
|
-
allow(helper).to receive_messages(:blacklight_config => blacklight_config)
|
404
|
-
expect(helper.start_over_path(:view => 'abc')).to eq catalog_index_url(:view => 'abc')
|
405
|
-
end
|
406
|
-
|
407
|
-
it 'should not include the current view type if it is the default' do
|
408
|
-
allow(blacklight_config).to receive(:document_index_view_types) { ['list', 'abc'] }
|
409
|
-
allow(helper).to receive_messages(:blacklight_config => blacklight_config)
|
410
|
-
expect(helper.start_over_path(:view => 'list')).to eq catalog_index_url
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
327
|
describe "render_document_index" do
|
415
328
|
it "should render the document_list" do
|
416
329
|
@document_list = ['a', 'b']
|
417
|
-
|
330
|
+
self.should_receive(:render).with(hash_including(:partial => 'document_gallery'))
|
418
331
|
render_document_index_with_view 'gallery', @document_list
|
419
332
|
end
|
420
333
|
|
421
334
|
it "should fall back on more specific templates" do
|
422
335
|
ex = ActionView::MissingTemplate.new [], '', '', '',''
|
423
|
-
|
424
|
-
|
425
|
-
|
336
|
+
self.should_receive(:render).with(hash_including(:partial => 'document_gallery')).and_raise(ex)
|
337
|
+
self.should_receive(:render).with(hash_including(:partial => 'catalog/document_gallery')).and_raise(ex)
|
338
|
+
self.should_receive(:render).with(hash_including(:partial => 'catalog/document_list'))
|
426
339
|
render_document_index_with_view 'gallery', @document_list
|
427
340
|
end
|
428
341
|
end
|
429
342
|
|
430
343
|
describe "document_partial_name" do
|
431
344
|
it "should default to 'default' when a format blank" do
|
432
|
-
|
345
|
+
document_partial_name({}).should == "default"
|
433
346
|
end
|
434
347
|
it "should handle normal formats correctly" do
|
435
|
-
|
348
|
+
document_partial_name({"format" => "myformat"}).should == "myformat"
|
436
349
|
end
|
437
350
|
it "should handle spaces correctly" do
|
438
|
-
|
351
|
+
document_partial_name({"format" => "my format"}).should == "my_format"
|
439
352
|
end
|
440
353
|
it "should handle capitalization correctly" do
|
441
|
-
|
354
|
+
document_partial_name({"format" => "MyFormat"}).should == "myformat"
|
442
355
|
end
|
443
356
|
it "should handle puncuation correctly" do
|
444
|
-
|
357
|
+
document_partial_name({"format" => "My.Format"}).should == "my_format"
|
445
358
|
end
|
446
359
|
it "should handle multi-valued fields correctly" do
|
447
|
-
|
360
|
+
document_partial_name({"format" => ["My Format", "My OtherFormat"]}).should == "my_format_my_otherformat"
|
448
361
|
end
|
449
362
|
it "should remove - characters because they will throw errors" do
|
450
|
-
|
451
|
-
|
363
|
+
document_partial_name({"format" => "My-Format"}).should == "my_format"
|
364
|
+
document_partial_name({"format" => ["My-Format",["My Other-Format"]]}).should == "my_format_my_other_format"
|
452
365
|
end
|
453
366
|
end
|
454
367
|
|
@@ -456,45 +369,45 @@ describe BlacklightHelper do
|
|
456
369
|
it "should consist of the document title wrapped in a <a>" do
|
457
370
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
458
371
|
@document = SolrDocument.new(data)
|
459
|
-
|
372
|
+
link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '654321', :count => 1)
|
460
373
|
end
|
461
374
|
it "should accept and return a string label" do
|
462
375
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
463
376
|
@document = SolrDocument.new(data)
|
464
|
-
|
377
|
+
link_to_document(@document, { :label => "title_display" }).should have_selector("a", :text => 'title_display', :count => 1)
|
465
378
|
end
|
466
379
|
|
467
380
|
it "should accept and return a Proc" do
|
468
381
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
469
382
|
@document = SolrDocument.new(data)
|
470
|
-
|
383
|
+
link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } }).should have_selector("a", :text => '123456: 654321', :count => 1)
|
471
384
|
end
|
472
385
|
it "should return id when label is missing" do
|
473
386
|
data = {'id'=>'123456'}
|
474
387
|
@document = SolrDocument.new(data)
|
475
|
-
|
388
|
+
link_to_document(@document, { :label => :title_display }).should have_selector("a", :text => '123456', :count => 1)
|
476
389
|
end
|
477
390
|
|
478
391
|
it "should be html safe" do
|
479
392
|
data = {'id'=>'123456'}
|
480
393
|
@document = SolrDocument.new(data)
|
481
|
-
|
394
|
+
link_to_document(@document, { :label => :title_display }).html_safe?.should == true
|
482
395
|
end
|
483
396
|
|
484
397
|
it "should convert the counter parameter into a data- attribute" do
|
485
398
|
data = {'id'=>'123456','title_display'=>['654321']}
|
486
399
|
@document = SolrDocument.new(data)
|
487
|
-
|
400
|
+
link_to_document(@document, { :label => :title_display, :counter => 5 }).should =~ /data-counter="5"/
|
488
401
|
end
|
489
402
|
|
490
403
|
it "passes on the title attribute to the link_to_with_data method" do
|
491
404
|
@document = SolrDocument.new('id'=>'123456')
|
492
|
-
|
405
|
+
link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label").should match(/title=\"Some crazy longer label\"/)
|
493
406
|
end
|
494
407
|
|
495
408
|
it "doesn't add an erroneous title attribute if one isn't provided" do
|
496
409
|
@document = SolrDocument.new('id'=>'123456')
|
497
|
-
|
410
|
+
link_to_document(@document,:label=>"Some crazy long label...").should_not match(/title=/)
|
498
411
|
end
|
499
412
|
end
|
500
413
|
|
@@ -521,7 +434,7 @@ describe BlacklightHelper do
|
|
521
434
|
@doc_id = "MOCK_ID1"
|
522
435
|
@document = MockDocumentAppHelper.new(:id => @doc_id)
|
523
436
|
render_params = {:controller => "controller", :action => "action"}
|
524
|
-
|
437
|
+
helper.stub(:params).and_return(render_params)
|
525
438
|
end
|
526
439
|
it "generates <link rel=alternate> tags" do
|
527
440
|
|
@@ -530,12 +443,12 @@ describe BlacklightHelper do
|
|
530
443
|
tmp_value = Capybara.ignore_hidden_elements
|
531
444
|
Capybara.ignore_hidden_elements = false
|
532
445
|
@document.export_formats.each_pair do |format, spec|
|
533
|
-
|
534
|
-
|
446
|
+
response.should have_selector("link[href$='.#{ format }']") do |matches|
|
447
|
+
matches.length.should == 1
|
535
448
|
tag = matches[0]
|
536
|
-
|
537
|
-
|
538
|
-
|
449
|
+
tag.attributes["rel"].value.should == "alternate"
|
450
|
+
tag.attributes["title"].value.should == format.to_s
|
451
|
+
tag.attributes["href"].value.should === mock_document_app_helper_url(@document, :format =>format)
|
539
452
|
end
|
540
453
|
end
|
541
454
|
Capybara.ignore_hidden_elements = tmp_value
|
@@ -558,7 +471,7 @@ describe BlacklightHelper do
|
|
558
471
|
|
559
472
|
it "should be html safe" do
|
560
473
|
response = render_link_rel_alternates(@document)
|
561
|
-
|
474
|
+
response.html_safe?.should == true
|
562
475
|
end
|
563
476
|
end
|
564
477
|
|
@@ -574,20 +487,20 @@ describe BlacklightHelper do
|
|
574
487
|
end
|
575
488
|
|
576
489
|
@document = SolrDocument.new('title_display' => "A Fake Document", 'id'=>'8')
|
577
|
-
|
578
|
-
|
579
|
-
|
490
|
+
helper.stub(:blacklight_config).and_return(@config)
|
491
|
+
helper.stub(:has_user_authentication_provider?).and_return(true)
|
492
|
+
helper.stub(:current_or_guest_user).and_return(User.new)
|
580
493
|
end
|
581
494
|
describe "render_index_doc_actions" do
|
582
495
|
it "should render partials" do
|
583
496
|
response = helper.render_index_doc_actions(@document)
|
584
|
-
|
497
|
+
response.should have_selector(".bookmark_toggle")
|
585
498
|
end
|
586
499
|
end
|
587
500
|
describe "render_show_doc_actions" do
|
588
501
|
it "should render partials" do
|
589
502
|
response = helper.render_show_doc_actions(@document)
|
590
|
-
|
503
|
+
response.should have_selector(".bookmark_toggle")
|
591
504
|
end
|
592
505
|
end
|
593
506
|
end
|
@@ -601,67 +514,67 @@ describe BlacklightHelper do
|
|
601
514
|
config.add_index_field 'link_to_search_named', :link_to_search => :some_field
|
602
515
|
config.add_index_field 'highlight', :highlight => true
|
603
516
|
end
|
604
|
-
|
517
|
+
helper.stub(:blacklight_config).and_return(@config)
|
605
518
|
end
|
606
519
|
|
607
520
|
it "should check for an explicit value" do
|
608
521
|
doc = double()
|
609
|
-
|
522
|
+
doc.should_not_receive(:get).with('asdf', :sep => nil)
|
610
523
|
value = helper.render_index_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
611
|
-
|
524
|
+
value.should == 'asdf'
|
612
525
|
end
|
613
526
|
|
614
527
|
it "should check for a helper method to call" do
|
615
528
|
doc = double()
|
616
|
-
|
617
|
-
|
529
|
+
doc.should_not_receive(:get).with('asdf', :sep => nil)
|
530
|
+
helper.stub(:render_asdf_index_field).and_return('custom asdf value')
|
618
531
|
value = helper.render_index_field_value :document => doc, :field => 'asdf'
|
619
|
-
|
532
|
+
value.should == 'custom asdf value'
|
620
533
|
end
|
621
534
|
|
622
535
|
it "should check for a link_to_search" do
|
623
536
|
doc = double()
|
624
|
-
|
537
|
+
doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
625
538
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
|
626
|
-
|
539
|
+
value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
|
627
540
|
end
|
628
541
|
|
629
542
|
it "should check for a link_to_search with a field name" do
|
630
543
|
doc = double()
|
631
|
-
|
544
|
+
doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
632
545
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
|
633
|
-
|
546
|
+
value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
|
634
547
|
end
|
635
548
|
|
636
549
|
it "should gracefully handle when no highlight field is available" do
|
637
550
|
doc = double()
|
638
|
-
|
639
|
-
|
551
|
+
doc.should_not_receive(:get)
|
552
|
+
doc.should_receive(:has_highlight_field?).and_return(false)
|
640
553
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
641
|
-
|
554
|
+
value.should be_blank
|
642
555
|
end
|
643
556
|
|
644
557
|
it "should check for a highlighted field" do
|
645
558
|
doc = double()
|
646
|
-
|
647
|
-
|
648
|
-
|
559
|
+
doc.should_not_receive(:get)
|
560
|
+
doc.should_receive(:has_highlight_field?).and_return(true)
|
561
|
+
doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
649
562
|
value = helper.render_index_field_value :document => doc, :field => 'highlight'
|
650
|
-
|
563
|
+
value.should == '<em>highlight</em>'
|
651
564
|
end
|
652
565
|
|
653
566
|
it "should check the document field value" do
|
654
567
|
doc = double()
|
655
|
-
|
568
|
+
doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
656
569
|
value = helper.render_index_field_value :document => doc, :field => 'qwer'
|
657
|
-
|
570
|
+
value.should == 'document qwer value'
|
658
571
|
end
|
659
572
|
|
660
573
|
it "should work with index fields that aren't explicitly defined" do
|
661
574
|
doc = double()
|
662
|
-
|
575
|
+
doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
663
576
|
value = helper.render_index_field_value :document => doc, :field => 'mnbv'
|
664
|
-
|
577
|
+
value.should == 'document mnbv value'
|
665
578
|
end
|
666
579
|
end
|
667
580
|
|
@@ -675,86 +588,86 @@ describe BlacklightHelper do
|
|
675
588
|
config.add_show_field 'link_to_search_named', :link_to_search => :some_field
|
676
589
|
config.add_show_field 'highlight', :highlight => true
|
677
590
|
end
|
678
|
-
|
591
|
+
helper.stub(:blacklight_config).and_return(@config)
|
679
592
|
end
|
680
593
|
|
681
594
|
it "should check for an explicit value" do
|
682
595
|
doc = double()
|
683
|
-
|
684
|
-
|
596
|
+
doc.should_not_receive(:get).with('asdf', :sep => nil)
|
597
|
+
helper.should_not_receive(:render_asdf_document_show_field)
|
685
598
|
value = helper.render_document_show_field_value :value => 'asdf', :document => doc, :field => 'asdf'
|
686
|
-
|
599
|
+
value.should == 'asdf'
|
687
600
|
end
|
688
601
|
|
689
602
|
it "should check for a helper method to call" do
|
690
603
|
doc = double()
|
691
|
-
|
692
|
-
|
604
|
+
doc.should_not_receive(:get).with('asdf', :sep => nil)
|
605
|
+
helper.stub(:render_asdf_document_show_field).and_return('custom asdf value')
|
693
606
|
value = helper.render_document_show_field_value :document => doc, :field => 'asdf'
|
694
|
-
|
607
|
+
value.should == 'custom asdf value'
|
695
608
|
end
|
696
609
|
|
697
610
|
it "should check for a link_to_search" do
|
698
611
|
doc = double()
|
699
|
-
|
612
|
+
doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
700
613
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
|
701
|
-
|
614
|
+
value.should == helper.link_to("x", helper.search_action_url(:f => { :link_to_search_true => ['x'] }))
|
702
615
|
end
|
703
616
|
|
704
617
|
it "should check for a link_to_search with a field name" do
|
705
618
|
doc = double()
|
706
|
-
|
619
|
+
doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
707
620
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
|
708
|
-
|
621
|
+
value.should == helper.link_to("x", helper.search_action_url(:f => { :some_field => ['x'] }))
|
709
622
|
end
|
710
623
|
|
711
624
|
it "should gracefully handle when no highlight field is available" do
|
712
625
|
doc = double()
|
713
|
-
|
714
|
-
|
626
|
+
doc.should_not_receive(:get)
|
627
|
+
doc.should_receive(:has_highlight_field?).and_return(false)
|
715
628
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
716
|
-
|
629
|
+
value.should be_blank
|
717
630
|
end
|
718
631
|
|
719
632
|
it "should check for a highlighted field" do
|
720
633
|
doc = double()
|
721
|
-
|
722
|
-
|
723
|
-
|
634
|
+
doc.should_not_receive(:get)
|
635
|
+
doc.should_receive(:has_highlight_field?).and_return(true)
|
636
|
+
doc.should_receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe])
|
724
637
|
value = helper.render_document_show_field_value :document => doc, :field => 'highlight'
|
725
|
-
|
638
|
+
value.should == '<em>highlight</em>'
|
726
639
|
end
|
727
640
|
|
728
641
|
|
729
642
|
it "should check the document field value" do
|
730
643
|
doc = double()
|
731
|
-
|
644
|
+
doc.should_receive(:get).with('qwer', :sep => nil).and_return('document qwer value')
|
732
645
|
value = helper.render_document_show_field_value :document => doc, :field => 'qwer'
|
733
|
-
|
646
|
+
value.should == 'document qwer value'
|
734
647
|
end
|
735
648
|
|
736
649
|
it "should work with show fields that aren't explicitly defined" do
|
737
650
|
doc = double()
|
738
|
-
|
651
|
+
doc.should_receive(:get).with('mnbv', :sep => nil).and_return('document mnbv value')
|
739
652
|
value = helper.render_document_show_field_value :document => doc, :field => 'mnbv'
|
740
|
-
|
653
|
+
value.should == 'document mnbv value'
|
741
654
|
end
|
742
655
|
end
|
743
656
|
|
744
657
|
describe "#should_render_index_field?" do
|
745
658
|
it "should if the document has the field value" do
|
746
659
|
doc = double()
|
747
|
-
|
660
|
+
doc.stub(:has?).with('asdf').and_return(true)
|
748
661
|
field_config = double(:field => 'asdf')
|
749
|
-
|
662
|
+
helper.should_render_index_field?(doc, field_config).should == true
|
750
663
|
end
|
751
664
|
|
752
665
|
it "should if the document has a highlight field value" do
|
753
666
|
doc = double()
|
754
|
-
|
755
|
-
|
667
|
+
doc.stub(:has?).with('asdf').and_return(false)
|
668
|
+
doc.stub(:has_highlight_field?).with('asdf').and_return(true)
|
756
669
|
field_config = double(:field => 'asdf', :highlight => true)
|
757
|
-
|
670
|
+
helper.should_render_index_field?(doc, field_config).should == true
|
758
671
|
end
|
759
672
|
end
|
760
673
|
|
@@ -762,17 +675,17 @@ describe BlacklightHelper do
|
|
762
675
|
describe "#should_render_show_field?" do
|
763
676
|
it "should if the document has the field value" do
|
764
677
|
doc = double()
|
765
|
-
|
678
|
+
doc.stub(:has?).with('asdf').and_return(true)
|
766
679
|
field_config = double(:field => 'asdf')
|
767
|
-
|
680
|
+
helper.should_render_show_field?(doc, field_config).should == true
|
768
681
|
end
|
769
682
|
|
770
683
|
it "should if the document has a highlight field value" do
|
771
684
|
doc = double()
|
772
|
-
|
773
|
-
|
685
|
+
doc.stub(:has?).with('asdf').and_return(false)
|
686
|
+
doc.stub(:has_highlight_field?).with('asdf').and_return(true)
|
774
687
|
field_config = double(:field => 'asdf', :highlight => true)
|
775
|
-
|
688
|
+
helper.should_render_show_field?(doc, field_config).should == true
|
776
689
|
end
|
777
690
|
end
|
778
691
|
|
@@ -780,13 +693,13 @@ describe BlacklightHelper do
|
|
780
693
|
describe "render_grouped_response?" do
|
781
694
|
it "should check if the response ivar contains grouped data" do
|
782
695
|
assign(:response, double("SolrResponse", :grouped? => true))
|
783
|
-
expect(helper.render_grouped_response?).to
|
696
|
+
expect(helper.render_grouped_response?).to be_true
|
784
697
|
end
|
785
698
|
|
786
699
|
|
787
700
|
it "should check if the response param contains grouped data" do
|
788
701
|
response = double("SolrResponse", :grouped? => true)
|
789
|
-
expect(helper.render_grouped_response?(response)).to
|
702
|
+
expect(helper.render_grouped_response?(response)).to be_true
|
790
703
|
end
|
791
704
|
end
|
792
705
|
|
@@ -800,7 +713,7 @@ describe BlacklightHelper do
|
|
800
713
|
end
|
801
714
|
|
802
715
|
it "should join values using the field_value_separator" do
|
803
|
-
|
716
|
+
helper.stub(:field_value_separator).and_return(" -- ")
|
804
717
|
expect(helper.render_field_value(['a', 'b'])).to eq "a -- b"
|
805
718
|
end
|
806
719
|
|
@@ -808,32 +721,4 @@ describe BlacklightHelper do
|
|
808
721
|
expect(helper.render_field_value(['c', 'd'], double(:separator => '; '))).to eq "c; d"
|
809
722
|
end
|
810
723
|
end
|
811
|
-
|
812
|
-
describe "link_to_previous_search" do
|
813
|
-
it "should link to the given search parameters" do
|
814
|
-
params = {}
|
815
|
-
expect(helper).to receive(:render_search_to_s).with(params).and_return "link text"
|
816
|
-
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", catalog_index_path)
|
817
|
-
end
|
818
|
-
end
|
819
|
-
|
820
|
-
describe "should_show_spellcheck_suggestions?" do
|
821
|
-
before :each do
|
822
|
-
allow(helper).to receive_messages spell_check_max: 5
|
823
|
-
end
|
824
|
-
it "should not show suggestions if there are enough results" do
|
825
|
-
response = double(total: 10)
|
826
|
-
expect(helper.should_show_spellcheck_suggestions? response).to eq false
|
827
|
-
end
|
828
|
-
|
829
|
-
it "should only show suggestions if there are very few results" do
|
830
|
-
response = double(total: 4, spelling: double(words: [1]))
|
831
|
-
expect(helper.should_show_spellcheck_suggestions? response).to eq true
|
832
|
-
end
|
833
|
-
|
834
|
-
it "should show suggestions only if there are spelling suggestions available" do
|
835
|
-
response = double(total: 4, spelling: double(words: []))
|
836
|
-
expect(helper.should_show_spellcheck_suggestions? response).to eq false
|
837
|
-
end
|
838
|
-
end
|
839
724
|
end
|