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
@@ -6,25 +6,19 @@ describe HashAsHiddenFieldsHelper do
|
|
6
6
|
before(:each) do
|
7
7
|
@hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}}
|
8
8
|
end
|
9
|
-
around(:each) do |example|
|
10
|
-
tmp_value = Capybara.ignore_hidden_elements
|
11
|
-
Capybara.ignore_hidden_elements = false
|
12
|
-
example.run
|
13
|
-
Capybara.ignore_hidden_elements = tmp_value
|
14
|
-
end
|
15
9
|
|
16
10
|
it "should convert a hash with nested complex data to Rails-style hidden form fields" do
|
17
11
|
|
18
|
-
generated =
|
19
|
-
|
20
|
-
expect(generated).to have_selector("input[type='hidden'][name='q'][value='query']")
|
21
|
-
expect(generated).to have_selector("input[type='hidden'][name='per_page'][value='10']")
|
22
|
-
expect(generated).to have_selector("input[type='hidden'][name='page'][value='5']")
|
23
|
-
expect(generated).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']")
|
24
|
-
expect(generated).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']")
|
25
|
-
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']")
|
26
|
-
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']")
|
12
|
+
generated = hash_as_hidden_fields(@hash)
|
27
13
|
|
14
|
+
generated.should have_selector("input[type='hidden'][name='q'][value='query']")
|
15
|
+
generated.should have_selector("input[type='hidden'][name='per_page'][value='10']")
|
16
|
+
generated.should have_selector("input[type='hidden'][name='page'][value='5']")
|
17
|
+
generated.should have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']")
|
18
|
+
generated.should have_selector("input[type='hidden'][name='f[field2][]'][value='z']")
|
19
|
+
generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='a']")
|
20
|
+
generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='b']")
|
21
|
+
|
28
22
|
end
|
29
23
|
|
30
24
|
end
|
@@ -4,12 +4,12 @@ describe RenderConstraintsHelper do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
# the helper methods below infer paths from the current route
|
7
|
-
controller.request.path_parameters[
|
7
|
+
controller.request.path_parameters["controller"] = 'catalog'
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#render_constraints_query' do
|
11
11
|
it "should have a link relative to the current url" do
|
12
|
-
|
12
|
+
helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'}).should have_selector "a[href='/?f%5Btype%5D=journal']"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -18,12 +18,12 @@ describe RenderConstraintsHelper do
|
|
18
18
|
@config = Blacklight::Configuration.new do |config|
|
19
19
|
config.add_facet_field 'type'
|
20
20
|
end
|
21
|
-
|
21
|
+
helper.stub(:blacklight_config => @config)
|
22
22
|
end
|
23
23
|
it "should have a link relative to the current url" do
|
24
24
|
result = helper.render_filter_element('type', ['journal'], {:q=>'biz'})
|
25
|
-
|
26
|
-
|
25
|
+
# I'm not certain how the ampersand gets in there. It's not important.
|
26
|
+
result.should have_selector "a[href='/?&q=biz']"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -13,41 +13,41 @@ describe SearchHistoryConstraintsHelper do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before(:each) do
|
16
|
-
|
16
|
+
helper.stub(:blacklight_config).and_return(@config)
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "render_search_to_s_*" do
|
20
20
|
describe "render_search_to_s_element" do
|
21
21
|
it "should render basic element" do
|
22
22
|
response = helper.render_search_to_s_element("key", "value")
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
response.should have_selector("span.constraint") do |span|
|
24
|
+
span.should have_selector("span.filterName", :content => "key:")
|
25
|
+
span.should have_selector("span.filterValue", :content => "value")
|
26
26
|
end
|
27
|
-
|
27
|
+
response.html_safe?.should == true
|
28
28
|
end
|
29
29
|
it "should escape them that need escaping" do
|
30
30
|
response = helper.render_search_to_s_element("key>", "value>")
|
31
|
-
|
32
|
-
|
31
|
+
response.should have_selector("span.constraint") do |span|
|
32
|
+
span.should have_selector("span.filterName") do |s2|
|
33
33
|
# Note: nokogiri's gettext will unescape the inner html
|
34
34
|
# which seems to be what rspecs "contains" method calls on
|
35
35
|
# text nodes - thus the to_s inserted below.
|
36
|
-
|
36
|
+
s2.to_s.should match(/key>:/)
|
37
37
|
end
|
38
|
-
|
39
|
-
|
38
|
+
span.should have_selector("span.filterValue") do |s3|
|
39
|
+
s3.to_s.should match(/value>/)
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
response.html_safe?.should == true
|
43
43
|
end
|
44
44
|
it "should not escape with options set thus" do
|
45
45
|
response = helper.render_search_to_s_element("key>", "value>", :escape_key => false, :escape_value => false)
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
response.should have_selector("span.constraint") do |span|
|
47
|
+
span.should have_selector("span.filterName", :content => "key>:")
|
48
|
+
span.should have_selector("span.filterValue", :content => "value>")
|
49
49
|
end
|
50
|
-
|
50
|
+
response.html_safe?.should == true
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -56,15 +56,15 @@ describe SearchHistoryConstraintsHelper do
|
|
56
56
|
@params = {:q => "history", :f => {"some_facet" => ["value1", "value1"], "other_facet" => ["other1"]}}
|
57
57
|
end
|
58
58
|
it "should call lesser methods" do
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
helper.stub(:blacklight_config).and_return(@config)
|
60
|
+
helper.stub(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(:key => 'default_search_field', :display_label => 'Default'))
|
61
|
+
helper.stub(:label_for_search_field).with(nil).and_return('')
|
62
62
|
# API hooks expect this to be so
|
63
63
|
response = helper.render_search_to_s(@params)
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
response.should include( helper.render_search_to_s_q(@params))
|
66
|
+
response.should include( helper.render_search_to_s_filters(@params))
|
67
|
+
response.html_safe?.should == true
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Blacklight::Routes do
|
3
|
+
subject { Blacklight::Routes.new(router, options) }
|
4
|
+
let(:router) { double }
|
5
|
+
|
6
|
+
describe "solr_document" do
|
7
|
+
describe "without constraints" do
|
8
|
+
let(:options) { Hash.new }
|
9
|
+
it "should define the resources" do
|
10
|
+
router.should_receive(:resources).with(:solr_document, {:path=>:records, :controller=>:records, :only=>[:show, :update]})
|
11
|
+
router.should_receive(:resources).with(:records, :only=>[:show, :update])
|
12
|
+
subject.solr_document(:records)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "with constraints" do
|
17
|
+
let(:options) { { :constraints => {id: /[a-z]+/, format: false } } }
|
18
|
+
it "should define the resources" do
|
19
|
+
router.should_receive(:resources).with(:solr_document, {:path=>:records, :controller=>:records, :only=>[:show, :update], :constraints=>{:id=>/[a-z]+/, :format=>false} })
|
20
|
+
router.should_receive(:resources).with(:records, :only=>[:show, :update], :constraints=>{:id=>/[a-z]+/, :format=>false})
|
21
|
+
subject.solr_document(:records)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Blacklight::Solr::Request do
|
4
|
+
before do
|
5
|
+
subject[:qt] = 'hey'
|
6
|
+
subject[:fq] = ["what's up.", "dood"]
|
7
|
+
subject['q'] = "what's"
|
8
|
+
subject[:wt] = "going"
|
9
|
+
subject[:start] = "on"
|
10
|
+
subject[:rows] = "Man"
|
11
|
+
subject['hl'] = "I"
|
12
|
+
subject['hl.fl'] = "wish"
|
13
|
+
subject['group'] = "I"
|
14
|
+
subject['defType'] = "had"
|
15
|
+
subject['spellcheck'] = "a"
|
16
|
+
subject['spellcheck.q'] = "fleece"
|
17
|
+
subject['f.title_facet.facet.limit'] = "vest"
|
18
|
+
subject['facet.field'] = []
|
19
|
+
end
|
20
|
+
it "should accept valid parameters" do
|
21
|
+
expect(subject.to_hash).to eq({"defType" => "had",
|
22
|
+
"f.title_facet.facet.limit" => "vest",
|
23
|
+
"fq" => ["what's up.", "dood"],
|
24
|
+
"group" => "I",
|
25
|
+
"hl" => "I",
|
26
|
+
"hl.fl" => "wish",
|
27
|
+
"q" => "what's",
|
28
|
+
"qt" => "hey",
|
29
|
+
"rows" => "Man",
|
30
|
+
"spellcheck" => "a",
|
31
|
+
"spellcheck.q" => "fleece",
|
32
|
+
"start" => "on",
|
33
|
+
"wt" => "going"
|
34
|
+
})
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -12,9 +12,9 @@ describe Blacklight::SolrResponse::GroupResponse do
|
|
12
12
|
|
13
13
|
describe "groups" do
|
14
14
|
it "should return an array of Groups" do
|
15
|
-
|
15
|
+
response.grouped.should be_a Array
|
16
16
|
|
17
|
-
expect(group.groups
|
17
|
+
expect(group.groups).to have(2).items
|
18
18
|
group.groups.each do |group|
|
19
19
|
expect(group).to be_a Blacklight::SolrResponse::Group
|
20
20
|
end
|
@@ -20,17 +20,17 @@ describe "Blacklight::Configurable" do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
it "should inherit the configuration when subclassed" do
|
23
|
-
|
23
|
+
TestCaseInheritence::Child.blacklight_config.list.should include(1,2,3)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "inherited version should be a deep copy, not original" do
|
27
|
-
|
27
|
+
TestCaseInheritence::Child.blacklight_config.should_not be(TestCaseInheritence::Parent.blacklight_config)
|
28
28
|
|
29
29
|
TestCaseInheritence::Child.blacklight_config.list << "child_only"
|
30
30
|
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
TestCaseInheritence::Child.blacklight_config.list.should include("child_only")
|
33
|
+
TestCaseInheritence::Parent.blacklight_config.list.should_not include("child_only")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -47,7 +47,7 @@ describe "Blacklight::Configurable" do
|
|
47
47
|
a = Class.new
|
48
48
|
a.send(:include, Blacklight::Configurable)
|
49
49
|
|
50
|
-
|
50
|
+
a.blacklight_config.default_solr_params.should be_empty
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should allow the user to provide a default configuration" do
|
@@ -56,7 +56,7 @@ describe "Blacklight::Configurable" do
|
|
56
56
|
Blacklight::Configurable.default_configuration = Blacklight::Configuration.new :a => 1
|
57
57
|
|
58
58
|
a.send(:include, Blacklight::Configurable)
|
59
|
-
|
59
|
+
a.blacklight_config.a.should == 1
|
60
60
|
end
|
61
61
|
|
62
62
|
it "has configure_blacklight convenience method" do
|
@@ -67,7 +67,7 @@ describe "Blacklight::Configurable" do
|
|
67
67
|
config.my_key = 'value'
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
klass.blacklight_config.my_key.should == 'value'
|
71
71
|
end
|
72
72
|
|
73
73
|
it "allows the instance to set a radically different config from the class" do
|
@@ -78,8 +78,8 @@ describe "Blacklight::Configurable" do
|
|
78
78
|
instance = klass.new
|
79
79
|
instance.blacklight_config = Blacklight::Configuration.new
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
instance.blacklight_config.should_not == klass.blacklight_config
|
82
|
+
instance.blacklight_config.foo.should be_nil
|
83
83
|
end
|
84
84
|
|
85
85
|
it "allows instance to set it's own config seperate from class" do
|
@@ -94,11 +94,11 @@ describe "Blacklight::Configurable" do
|
|
94
94
|
|
95
95
|
instance = klass.new
|
96
96
|
instance.blacklight_config.bar << "123"
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
instance.blacklight_config.should_not == klass.blacklight_config
|
98
|
+
klass.blacklight_config.foo.should == "bar"
|
99
|
+
instance.blacklight_config.foo.should == "bar"
|
100
|
+
klass.blacklight_config.bar.should_not include("123")
|
101
|
+
instance.blacklight_config.bar.should include("asd", "123")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "configurable classes should not mutate the default configuration object" do
|
@@ -110,8 +110,8 @@ describe "Blacklight::Configurable" do
|
|
110
110
|
klass2.send(:include, Blacklight::Configurable)
|
111
111
|
klass2.blacklight_config.foo = "asdf"
|
112
112
|
|
113
|
-
|
114
|
-
|
113
|
+
klass.blacklight_config.foo.should == "bar"
|
114
|
+
klass2.blacklight_config.foo.should == "asdf"
|
115
115
|
end
|
116
116
|
|
117
117
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
4
4
|
|
5
5
|
describe "Blacklight::Configuration" do
|
6
|
-
|
6
|
+
|
7
7
|
before(:each) do
|
8
8
|
@config = Blacklight::Configuration.new
|
9
9
|
end
|
@@ -11,60 +11,60 @@ describe "Blacklight::Configuration" do
|
|
11
11
|
it "should support arbitrary configuration values" do
|
12
12
|
@config.a = 1
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
@config.a.should == 1
|
15
|
+
@config[:a].should == 1
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "initialization" do
|
19
19
|
it "should be an OpenStructWithHashAccess" do
|
20
|
-
|
20
|
+
@config.should be_a_kind_of Blacklight::OpenStructWithHashAccess
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should accept a block for configuration" do
|
24
24
|
config = Blacklight::Configuration.new(:a => 1) { |c| c.a = 2 }
|
25
25
|
|
26
|
-
|
26
|
+
config.a.should == 2
|
27
27
|
|
28
28
|
config.configure { |c| c.a = 3 }
|
29
29
|
|
30
|
-
|
30
|
+
config.a.should == 3
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "defaults" do
|
35
35
|
it "should have a hash of default rsolr query parameters" do
|
36
|
-
|
36
|
+
@config.default_solr_params.should be_a_kind_of Hash
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should have openstruct values for show and index parameters" do
|
40
|
-
|
41
|
-
|
40
|
+
@config.show.should be_a_kind_of OpenStruct
|
41
|
+
@config.index.should be_a_kind_of OpenStruct
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should introspect SolrDocument for sensible defaults for show + index" do
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
@config.show.html_title.should == 'id'
|
46
|
+
@config.show.heading.should == 'id'
|
47
|
+
@config.index.show_link.should == 'id'
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should have ordered hashes for field configuration" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
@config.facet_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
52
|
+
@config.index_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
53
|
+
@config.show_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
54
|
+
@config.search_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
55
|
+
@config.show_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
56
|
+
@config.search_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
57
|
+
@config.sort_fields.should be_a_kind_of ActiveSupport::OrderedHash
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "spell_max" do
|
62
62
|
it "should default to 5" do
|
63
|
-
|
63
|
+
Blacklight::Configuration.new.spell_max.should == 5
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
it "should accept config'd value" do
|
67
|
-
|
67
|
+
Blacklight::Configuration.new(:spell_max => 10).spell_max.should == 10
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -76,8 +76,8 @@ describe "Blacklight::Configuration" do
|
|
76
76
|
@mock_facet = Blacklight::Configuration::FacetField.new
|
77
77
|
config_copy.add_facet_field "dummy_field", @mock_facet
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
@config.a.should be_nil
|
80
|
+
@config.facet_fields.should_not include(@mock_facet)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -89,9 +89,9 @@ describe "Blacklight::Configuration" do
|
|
89
89
|
config.add_my_custom_field 'qwerty', :label => "asdf"
|
90
90
|
end
|
91
91
|
|
92
|
+
|
92
93
|
|
93
|
-
|
94
|
-
expect(config.my_custom_fields.keys).to include('qwerty')
|
94
|
+
config.my_custom_fields.keys.should include('qwerty')
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should let you define a field accessor that uses an existing field-type" do
|
@@ -102,37 +102,37 @@ describe "Blacklight::Configuration" do
|
|
102
102
|
config.add_my_custom_facet_field 'qwerty', :label => "asdf"
|
103
103
|
end
|
104
104
|
|
105
|
+
|
105
106
|
|
106
|
-
|
107
|
-
expect(config.my_custom_facet_fields['qwerty']).to be_a_kind_of(Blacklight::Configuration::FacetField)
|
107
|
+
config.my_custom_facet_fields['qwerty'].should be_a_kind_of(Blacklight::Configuration::FacetField)
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
describe "add_facet_field" do
|
113
113
|
it "should accept field name and hash form arg" do
|
114
114
|
@config.add_facet_field('format', :label => "Format", :limit => true)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
|
116
|
+
@config.facet_fields["format"].should_not be_nil
|
117
|
+
@config.facet_fields["format"]["label"].should == "Format"
|
118
|
+
@config.facet_fields["format"]["limit"].should == true
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should accept FacetField obj arg" do
|
122
122
|
@config.add_facet_field("format", Blacklight::Configuration::FacetField.new( :label => "Format"))
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
|
124
|
+
@config.facet_fields["format"].should_not be_nil
|
125
|
+
@config.facet_fields["format"]["label"].should == "Format"
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
it "should accept field name and block form" do
|
129
|
-
@config.add_facet_field("format") do |facet|
|
129
|
+
@config.add_facet_field("format") do |facet|
|
130
130
|
facet.label = "Format"
|
131
131
|
facet.limit = true
|
132
132
|
end
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
|
134
|
+
@config.facet_fields["format"].should_not be_nil
|
135
|
+
@config.facet_fields["format"].limit.should == true
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should accept block form" do
|
@@ -141,208 +141,208 @@ describe "Blacklight::Configuration" do
|
|
141
141
|
facet.label = "Format"
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
@config.facet_fields['format'].should_not be_nil
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should accept a configuration hash" do
|
148
148
|
@config.add_facet_field :field => 'format', :label => 'Format'
|
149
|
-
|
149
|
+
@config.facet_fields['format'].should_not be_nil
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should accept array form" do
|
153
153
|
@config.add_facet_field([{ :field => 'format', :label => 'Format'}, { :field => 'publication_date', :label => 'Publication Date' }])
|
154
154
|
|
155
|
-
|
155
|
+
@config.facet_fields.length.should == 2
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should create default label from titleized solr field" do
|
159
159
|
@config.add_facet_field("publication_date")
|
160
|
-
|
161
|
-
|
160
|
+
|
161
|
+
@config.facet_fields["publication_date"].label.should == "Publication Date"
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should allow you to not show the facet in the facet bar" do
|
165
165
|
@config.add_facet_field("publication_date", :show=>false)
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
@config.facet_fields["publication_date"]['show'].should be_false
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
it "should raise on nil solr field name" do
|
171
|
-
|
171
|
+
lambda { @config.add_facet_field(nil) }.should raise_error ArgumentError
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
end
|
175
|
-
|
175
|
+
|
176
176
|
describe "add_index_field" do
|
177
177
|
it "takes hash form" do
|
178
178
|
@config.add_index_field("title_display", :label => "Title")
|
179
|
-
|
180
|
-
|
181
|
-
|
179
|
+
|
180
|
+
@config.index_fields["title_display"].should_not be_nil
|
181
|
+
@config.index_fields["title_display"].label.should == "Title"
|
182
182
|
end
|
183
183
|
it "takes IndexField param" do
|
184
184
|
@config.add_index_field("title_display", Blacklight::Configuration::IndexField.new(:field => "title_display", :label => "Title"))
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
|
186
|
+
@config.index_fields["title_display"].should_not be_nil
|
187
|
+
@config.index_fields["title_display"].label.should == "Title"
|
188
188
|
end
|
189
189
|
it "takes block form" do
|
190
|
-
@config.add_index_field("title_display") do |field|
|
190
|
+
@config.add_index_field("title_display") do |field|
|
191
191
|
field.label = "Title"
|
192
192
|
end
|
193
|
-
|
194
|
-
|
193
|
+
@config.index_fields["title_display"].should_not be_nil
|
194
|
+
@config.index_fields["title_display"].label.should == "Title"
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
it "creates default label from titleized field" do
|
198
198
|
@config.add_index_field("title_display")
|
199
|
-
|
200
|
-
|
199
|
+
|
200
|
+
@config.index_fields["title_display"].label.should == "Title Display"
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
it "should raise on nil solr field name" do
|
204
|
-
|
204
|
+
lambda { @config.add_index_field(nil) }.should raise_error ArgumentError
|
205
205
|
end
|
206
206
|
|
207
207
|
end
|
208
|
-
|
208
|
+
|
209
209
|
describe "add_show_field" do
|
210
210
|
it "takes hash form" do
|
211
211
|
@config.add_show_field("title_display", :label => "Title")
|
212
|
-
|
213
|
-
|
214
|
-
|
212
|
+
|
213
|
+
@config.show_fields["title_display"].should_not be_nil
|
214
|
+
@config.show_fields["title_display"].label.should == "Title"
|
215
215
|
end
|
216
216
|
it "takes ShowField argument" do
|
217
217
|
@config.add_show_field("title_display", Blacklight::Configuration::ShowField.new(:field => "title_display", :label => "Title"))
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
|
219
|
+
@config.show_fields["title_display"].should_not be_nil
|
220
|
+
@config.show_fields["title_display"].label.should == "Title"
|
221
221
|
end
|
222
222
|
it "takes block form" do
|
223
|
-
@config.add_show_field("title_display") do |f|
|
223
|
+
@config.add_show_field("title_display") do |f|
|
224
224
|
f.label = "Title"
|
225
225
|
end
|
226
|
-
|
227
|
-
|
228
|
-
|
226
|
+
|
227
|
+
@config.show_fields["title_display"].should_not be_nil
|
228
|
+
@config.show_fields["title_display"].label.should == "Title"
|
229
229
|
end
|
230
|
-
|
230
|
+
|
231
231
|
it "creates default label humanized from field" do
|
232
232
|
@config.add_show_field("my_custom_field")
|
233
|
-
|
234
|
-
|
233
|
+
|
234
|
+
@config.show_fields["my_custom_field"].label.should == "My Custom Field"
|
235
235
|
end
|
236
|
-
|
236
|
+
|
237
237
|
it "should raise on nil solr field name" do
|
238
|
-
|
238
|
+
lambda { @config.add_show_field(nil) }.should raise_error ArgumentError
|
239
239
|
end
|
240
|
-
|
240
|
+
|
241
241
|
end
|
242
|
-
|
243
|
-
|
242
|
+
|
243
|
+
|
244
244
|
describe "add_search_field" do
|
245
245
|
it "should accept hash form" do
|
246
246
|
c = Blacklight::Configuration.new
|
247
247
|
c.add_search_field(:key => "my_search_key")
|
248
|
-
|
248
|
+
c.search_fields["my_search_key"].should_not be_nil
|
249
249
|
end
|
250
250
|
|
251
251
|
it "should accept two-arg hash form" do
|
252
252
|
c = Blacklight::Configuration.new
|
253
|
-
|
253
|
+
|
254
254
|
c.add_search_field("my_search_type",
|
255
255
|
:key => "my_search_type",
|
256
|
-
:solr_parameters => { :qf => "my_field_qf^10" },
|
256
|
+
:solr_parameters => { :qf => "my_field_qf^10" },
|
257
257
|
:solr_local_parameters => { :pf=>"$my_field_pf"})
|
258
|
-
|
258
|
+
|
259
259
|
field = c.search_fields["my_search_type"]
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
end
|
269
|
-
|
260
|
+
|
261
|
+
field.should_not be_nil
|
262
|
+
|
263
|
+
|
264
|
+
field.solr_parameters.should_not be_nil
|
265
|
+
field.solr_local_parameters.should_not be_nil
|
266
|
+
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
270
|
it "should accept block form" do
|
271
271
|
c = Blacklight::Configuration.new
|
272
|
-
|
273
|
-
c.add_search_field("some_field") do |field|
|
272
|
+
|
273
|
+
c.add_search_field("some_field") do |field|
|
274
274
|
field.solr_parameters = {:qf => "solr_field^10"}
|
275
275
|
field.solr_local_parameters = {:pf => "$some_field_pf"}
|
276
276
|
end
|
277
|
-
|
277
|
+
|
278
278
|
f = c.search_fields["some_field"]
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
279
|
+
|
280
|
+
f.should_not be_nil
|
281
|
+
f.solr_parameters.should_not be_nil
|
282
|
+
f.solr_local_parameters.should_not be_nil
|
283
283
|
end
|
284
|
-
|
284
|
+
|
285
285
|
it "should accept SearchField object" do
|
286
286
|
c = Blacklight::Configuration.new
|
287
|
-
|
287
|
+
|
288
288
|
f = Blacklight::Configuration::SearchField.new( :foo => "bar")
|
289
|
-
|
289
|
+
|
290
290
|
c.add_search_field("foo", f)
|
291
|
-
|
292
|
-
|
291
|
+
|
292
|
+
c.search_fields["foo"].should_not be_nil
|
293
293
|
end
|
294
|
-
|
294
|
+
|
295
295
|
it "should raise on nil key" do
|
296
|
-
|
296
|
+
lambda {@config.add_search_field(nil, :foo => "bar")}.should raise_error ArgumentError
|
297
297
|
end
|
298
|
-
|
298
|
+
|
299
299
|
it "creates default label from titleized field key" do
|
300
300
|
@config.add_search_field("author_name")
|
301
|
-
|
302
|
-
|
301
|
+
|
302
|
+
@config.search_fields["author_name"].label.should == "Author Name"
|
303
303
|
end
|
304
|
-
|
305
|
-
|
304
|
+
|
305
|
+
|
306
306
|
end
|
307
|
-
|
307
|
+
|
308
308
|
describe "add_sort_field" do
|
309
309
|
it "should take a hash" do
|
310
310
|
c = Blacklight::Configuration.new
|
311
311
|
c.add_sort_field(:key => "my_sort_key", :sort => "score desc")
|
312
|
-
|
312
|
+
c.sort_fields["my_sort_key"].should_not be_nil
|
313
313
|
end
|
314
314
|
|
315
315
|
it "should take a two-arg form with a hash" do
|
316
|
-
@config.add_sort_field("score desc, pub_date_sort desc, title_sort asc", :label => "relevance")
|
317
|
-
|
316
|
+
@config.add_sort_field("score desc, pub_date_sort desc, title_sort asc", :label => "relevance")
|
318
317
|
|
319
|
-
|
318
|
+
|
319
|
+
@config.sort_fields.values.find{|f| f.label == "relevance"}.should_not be_nil
|
320
320
|
end
|
321
|
-
|
321
|
+
|
322
322
|
it "should take a SortField object" do
|
323
323
|
@config.add_sort_field(Blacklight::Configuration::SortField.new(:label => "relevance", :sort => "score desc, pub_date_sort desc, title_sort asc"
|
324
|
-
))
|
325
|
-
|
324
|
+
))
|
325
|
+
@config.sort_fields.values.find{|f| f.label == "relevance"}.should_not be_nil
|
326
326
|
end
|
327
|
-
|
327
|
+
|
328
328
|
it "should take block form" do
|
329
329
|
@config.add_sort_field do |field|
|
330
330
|
field.label = "relevance"
|
331
331
|
field.sort = "score desc, pub_date_sort desc, title_sort asc"
|
332
332
|
end
|
333
|
-
|
334
|
-
|
333
|
+
|
334
|
+
@config.sort_fields.values.find{|f| f.label == "relevance"}.should_not be_nil
|
335
335
|
|
336
336
|
end
|
337
337
|
end
|
338
|
-
|
338
|
+
|
339
339
|
describe "#default_search_field" do
|
340
340
|
it "should use the field with a :default key" do
|
341
341
|
@config.add_search_field('search_field_1')
|
342
342
|
@config.add_search_field('search_field_2', :default => true)
|
343
343
|
|
344
|
-
|
344
|
+
@config.default_search_field.key.should == 'search_field_2'
|
345
345
|
end
|
346
346
|
end
|
347
|
-
|
347
|
+
|
348
348
|
end
|