spec/features/basic_spec.rb in blacklight-hierarchy-0.1.0 vs spec/features/basic_spec.rb in blacklight-hierarchy-0.1.1

- old
+ new

@@ -1,44 +1,28 @@ require 'spec_helper' -describe "catalog" do +shared_examples "catalog" do - before do - CatalogController.blacklight_config = Blacklight::Configuration.new - CatalogController.configure_blacklight do |config| -# config.add_facet_field 'rotate_tag_facet', :label => 'Tag', :partial => 'blacklight/hierarchy/facet_hierarchy' - config.add_facet_field 'tag_facet', :label => 'Tag', :partial => 'blacklight/hierarchy/facet_hierarchy' - config.add_facet_field 'my_top_facet', :label => 'Slash Delim', :partial => 'blacklight/hierarchy/facet_hierarchy' - config.facet_display = { - :hierarchy => { -# 'rotate' => [['tag'], ':'], # this would work if config.add_facet_field was called rotate_tag_facet, instead of tag_facet, I think. - 'tag' => [['facet'], ':'], # stupidly, the facet field is expected to have an underscore followed by SOMETHING; in this case it is "facet" - 'my_top' => [['facet'], '/'] - } - } - end - end - context "facet tree without repeated nodes" do before { solr_facet_resp = {'responseHeader'=>{'status'=>0, 'QTime'=>4, 'params'=>{'wt'=>'ruby','rows'=>'0'}}, 'response'=>{'numFound'=>30, 'start'=>0, 'maxScore'=>1.0, 'docs' => []}, 'facet_counts' => { 'facet_queries' => {}, 'facet_fields' => { 'tag_facet' => [ 'a:b:c', 30, - 'a:b:d', 25, - 'a:c:d', 5, - 'p:r:q', 25, - 'x:y', 5, + 'a:b:d', 25, + 'a:c:d', 5, + 'p:r:q', 25, + 'x:y', 5, 'n', 1 ], 'my_top_facet' => [ 'f/g/h', 30, - 'j/k', 5, - 'z', 1 ], - }, + 'j/k', 5, + 'z', 1 ], + }, 'facet_dates' => {}, 'facet_ranges' => {} } } rsolr_client = double("rsolr_client") @@ -78,22 +62,22 @@ expect(page).to have_selector('li.h-node', :text => 'j') expect(page).to have_selector('li.h-node li.h-leaf', :text => 'k 5') expect(page).to have_selector('.facet-hierarchy > li.h-leaf', :text => 'z 1') end end # facet tree without repeated nodes - + context "facet tree with repeated nodes" do before do facet_resp = {'responseHeader'=>{'status'=>0, 'QTime'=>4, 'params'=>{'wt'=>'ruby','rows'=>'0'}}, 'response'=>{'numFound'=>30, 'start'=>0, 'maxScore'=>1.0, 'docs' => []}, 'facet_counts' => { 'facet_queries' => {}, 'facet_fields' => { 'tag_facet' => [ 'm:w:w:t', 15, 'm:w:v:z', 10], - }, + }, 'facet_dates' => {}, 'facet_ranges' => {} } } my_rsolr_client = double("rsolr_client") @@ -109,6 +93,44 @@ expect(page).to have_selector('li.h-node li.h-leaf', :text => 't 15') expect(page).to have_selector('li.h-node li.h-leaf', :text => 'z 10') end end +end + +describe "config_1" do + it_behaves_like "catalog" do + before do + CatalogController.blacklight_config = Blacklight::Configuration.new + CatalogController.configure_blacklight do |config| + # config.add_facet_field 'rotate_tag_facet', :label => 'Tag', :partial => 'blacklight/hierarchy/facet_hierarchy' + config.add_facet_field 'tag_facet', :label => 'Tag', :partial => 'blacklight/hierarchy/facet_hierarchy' + config.add_facet_field 'my_top_facet', :label => 'Slash Delim', :partial => 'blacklight/hierarchy/facet_hierarchy' + config.facet_display = { + :hierarchy => { + # 'rotate' => [['tag' ], ':'], # this would work if config.add_facet_field was called rotate_tag_facet, instead of tag_facet, I think. + 'tag' => [['facet'], ':'], # stupidly, the facet field is expected to have an underscore followed by SOMETHING; in this case it is "facet" + 'my_top' => [['facet'], '/'] + } + } + end + end + end +end + +describe "config_2" do + it_behaves_like "catalog" do + before do + CatalogController.blacklight_config = Blacklight::Configuration.new + CatalogController.configure_blacklight do |config| + config.add_facet_field 'tag_facet', :label => 'Tag', :partial => 'blacklight/hierarchy/facet_hierarchy' + config.add_facet_field 'my_top_facet', :label => 'Slash Delim', :partial => 'blacklight/hierarchy/facet_hierarchy' + config.facet_display = { + :hierarchy => { + 'tag' => [['facet']], # rely on default delim + 'my_top' => [['facet'], '/'] + } + } + end + end + end end