commonwealth-vlr-engine 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/assets/stylesheets/commonwealth-vlr-engine/advanced_search.scss +1 -1
  4. data/app/assets/stylesheets/commonwealth-vlr-engine/basic_search.scss +6 -1
  5. data/app/assets/stylesheets/commonwealth-vlr-engine/commonwealth-vlr-engine.css +1 -0
  6. data/app/assets/stylesheets/commonwealth-vlr-engine/folders.scss +1 -1
  7. data/app/assets/stylesheets/commonwealth-vlr-engine/header.scss +9 -0
  8. data/app/assets/stylesheets/commonwealth-vlr-engine/home.scss +9 -0
  9. data/app/assets/stylesheets/commonwealth-vlr-engine/twitter_typeahead.scss +9 -0
  10. data/app/controllers/blacklight_advanced_search/advanced_controller.rb +12 -48
  11. data/app/controllers/bookmarks_controller.rb +8 -8
  12. data/app/controllers/collections_controller.rb +10 -26
  13. data/app/controllers/folder_items_actions_controller.rb +2 -2
  14. data/app/controllers/folders_controller.rb +10 -6
  15. data/app/controllers/image_viewer_controller.rb +2 -2
  16. data/app/controllers/institutions_controller.rb +13 -12
  17. data/app/controllers/ocr_search_controller.rb +2 -8
  18. data/app/controllers/saved_searches_controller.rb +8 -0
  19. data/app/controllers/search_history_controller.rb +8 -0
  20. data/app/helpers/commonwealth_vlr_engine/application_helper.rb +37 -37
  21. data/app/helpers/commonwealth_vlr_engine/blacklight_helper.rb +3 -11
  22. data/app/helpers/commonwealth_vlr_engine/blacklight_url_helper.rb +1 -16
  23. data/app/helpers/commonwealth_vlr_engine/catalog_helper.rb +1 -1
  24. data/app/helpers/commonwealth_vlr_engine/collections_helper_behavior.rb +1 -1
  25. data/app/helpers/commonwealth_vlr_engine/institutions_helper_behavior.rb +2 -2
  26. data/app/helpers/commonwealth_vlr_engine/vlr_blacklight_maps_helper_behavior.rb +10 -6
  27. data/app/views/advanced/_advanced_search_fields.html.erb +2 -2
  28. data/app/views/advanced/_advanced_search_form.html.erb +2 -2
  29. data/app/views/advanced/index.html.erb +1 -1
  30. data/app/views/bookmarks/index.html.erb +1 -1
  31. data/app/views/catalog/_basic_search.html.erb +5 -3
  32. data/app/views/catalog/_constraints.html.erb +1 -1
  33. data/app/views/catalog/_facet_limit_series.html.erb +7 -5
  34. data/app/views/catalog/_index_gallery.html.erb +1 -3
  35. data/app/views/catalog/{_index_map_institutions.html.erb → _index_mapview_institutions.html.erb} +0 -0
  36. data/app/views/catalog/_search_form.html.erb +14 -4
  37. data/app/views/catalog/_show_partials/_show_default_metadata.html.erb +9 -0
  38. data/app/views/catalog/_show_partials/_show_flagged_notice.html.erb +1 -1
  39. data/app/views/catalog/_show_tools.html.erb +2 -2
  40. data/app/views/catalog/_zero_results.html.erb +1 -1
  41. data/app/views/collections/_search_form_collection.html.erb +1 -1
  42. data/app/views/collections/show.html.erb +1 -1
  43. data/app/views/feedback/complete.html.erb +1 -1
  44. data/app/views/institutions/_search_form_institution.html.erb +1 -1
  45. data/app/views/layouts/commonwealth-vlr-engine.html.erb +2 -2
  46. data/app/views/ocr_search/_search_form_ocr.html.erb +1 -1
  47. data/app/views/pages/home.html.erb +2 -1
  48. data/app/views/saved_searches/index.html.erb +4 -4
  49. data/app/views/search_history/index.html.erb +5 -5
  50. data/app/views/shared/_folder_item_actions.html.erb +1 -2
  51. data/app/views/shared/_footer.html.erb +1 -1
  52. data/app/views/shared/_header_navbar.html.erb +1 -1
  53. data/app/views/shared/_nav_links.html.erb +2 -2
  54. data/app/views/shared/_search_form_header.html.erb +9 -3
  55. data/app/views/shared/_sitelinks_search_box.html.erb +12 -0
  56. data/app/views/shared/_tools.html.erb +2 -2
  57. data/app/views/shared/_user_util_links.html.erb +2 -2
  58. data/app/views/users/show.html.erb +2 -2
  59. data/commonwealth-vlr-engine.gemspec +4 -4
  60. data/config/initializers/assets.rb +2 -0
  61. data/config/locales/commonwealth-vlr-engine.en.yml +4 -0
  62. data/config/routes.rb +1 -0
  63. data/lib/commonwealth-vlr-engine.rb +6 -16
  64. data/lib/commonwealth-vlr-engine/controller_override.rb +82 -47
  65. data/lib/commonwealth-vlr-engine/engine.rb +6 -4
  66. data/lib/commonwealth-vlr-engine/render_constraints_override.rb +3 -2
  67. data/lib/commonwealth-vlr-engine/search_builder/collections_search_builder.rb +14 -0
  68. data/lib/commonwealth-vlr-engine/{commonwealth_search_builder.rb → search_builder/commonwealth_search_builder_behavior.rb} +9 -2
  69. data/lib/commonwealth-vlr-engine/search_builder/flagged_search_builder.rb +14 -0
  70. data/lib/commonwealth-vlr-engine/search_builder/institutions_search_builder.rb +11 -0
  71. data/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder.rb +15 -0
  72. data/lib/commonwealth-vlr-engine/search_builder/ocr_search_builder.rb +10 -0
  73. data/lib/commonwealth-vlr-engine/version.rb +1 -1
  74. data/lib/generators/commonwealth_vlr_engine/controller_generator.rb +1 -2
  75. data/lib/generators/commonwealth_vlr_engine/localassets_generator.rb +1 -1
  76. data/lib/generators/commonwealth_vlr_engine/model_generator.rb +3 -16
  77. data/lib/generators/commonwealth_vlr_engine/routes_generator.rb +8 -0
  78. data/lib/generators/commonwealth_vlr_engine/templates/commonwealth_search_builder.rb +17 -0
  79. data/lib/generators/commonwealth_vlr_engine/templates/{commonwealth_vlr_engine.css.scss → commonwealth_vlr_engine.scss} +0 -0
  80. data/spec/controllers/catalog_controller_spec.rb +20 -3
  81. data/spec/controllers/collections_controller_spec.rb +2 -2
  82. data/spec/controllers/folder_items_actions_controller_spec.rb +2 -2
  83. data/spec/controllers/institutions_controller_spec.rb +13 -0
  84. data/spec/controllers/ocr_search_controller_spec.rb +4 -0
  85. data/spec/features/more_like_this_search_spec.rb +1 -1
  86. data/spec/features/ocr_search/index_spec.rb +1 -1
  87. data/spec/helpers/institutions_helper_spec.rb +10 -5
  88. data/spec/lib/commonwealth-vlr-engine/search_builder/collections_search_builder_spec.rb +19 -0
  89. data/spec/lib/commonwealth-vlr-engine/search_builder/commonwealth_search_builder_behavior_spec.rb +116 -0
  90. data/spec/lib/commonwealth-vlr-engine/search_builder/flagged_search_builder_spec.rb +19 -0
  91. data/spec/lib/commonwealth-vlr-engine/search_builder/institutions_search_builder_spec.rb +19 -0
  92. data/spec/lib/commonwealth-vlr-engine/search_builder/mlt_search_builder_spec.rb +19 -0
  93. data/spec/lib/commonwealth-vlr-engine/search_builder/ocr_search_builder_spec.rb +19 -0
  94. data/spec/test_app_templates/lib/generators/test_app_generator.rb +2 -0
  95. data/tasks/vlr_engine.rake +1 -1
  96. metadata +38 -23
  97. data/app/views/bookmarks/_tools.html.erb +0 -25
  98. data/app/views/catalog/_index_list_default.html.erb +0 -13
  99. data/lib/commonwealth-vlr-engine/route_sets.rb +0 -49
  100. data/lib/commonwealth-vlr-engine/routes.rb +0 -21
  101. data/spec/lib/commonwealth-vlr-engine/commonwealth_search_builder_spec.rb +0 -101
  102. data/spec/lib/commonwealth-vlr-engine/controller_override_spec.rb +0 -41
@@ -23,10 +23,6 @@ module CommonwealthVlrEngine
23
23
  # for db migrations
24
24
  engine_name 'commonwealth_vlr_engine'
25
25
 
26
- config.to_prepare do
27
- CommonwealthVlrEngine.inject!
28
- end
29
-
30
26
  # This makes our rake tasks visible.
31
27
  rake_tasks do
32
28
  Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))) do
@@ -36,5 +32,11 @@ module CommonwealthVlrEngine
36
32
  end
37
33
  #load "#{config.root}/tasks/dc_public.rake"
38
34
  end
35
+
36
+ # needs to be explicit as of sprockets-rails >=3.*
37
+ initializer 'commonwealth.assets.precompile' do |app|
38
+ app.config.assets.precompile += %w(commonwealth-vlr-engine/*.png commonwealth-vlr-engine/*.gif commonwealth-vlr-engine/openseadragon/*.png)
39
+ end
40
+
39
41
  end
40
42
  end
@@ -32,13 +32,14 @@ module CommonwealthVlrEngine
32
32
  # Render the 'more like this' query constraints
33
33
  def render_mlt_query(localized_params = params)
34
34
  # So simple don't need a view template, we can just do it here.
35
- scope = localized_params.delete(:route_set) || self
36
35
  return ''.html_safe if localized_params[:mlt_id].blank?
37
36
 
38
37
  render_constraint_element(t('blacklight.more_like_this.constraint_label'),
39
38
  localized_params[:mlt_id],
40
39
  :classes => ['mlt'],
41
- :remove => scope.url_for(localized_params.merge(:mlt_id=>nil, :qt=>nil, :action=>'index')))
40
+ :remove => remove_constraint_url(localized_params.merge(:mlt_id=>nil,
41
+ :qt=>nil,
42
+ :action=>'index')))
42
43
  end
43
44
 
44
45
  # include render_search_to_s_mlt() in rendered constraints
@@ -0,0 +1,14 @@
1
+ class CommonwealthCollectionsSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
5
+
6
+ self.default_processor_chain += [
7
+ :exclude_unpublished_items, :collections_filter
8
+ ]
9
+
10
+ unless I18n.t('blacklight.home.browse.institutions.enabled')
11
+ self.default_processor_chain += [:institution_limit]
12
+ end
13
+
14
+ end
@@ -1,5 +1,5 @@
1
1
  module CommonwealthVlrEngine
2
- module CommonwealthSearchBuilder
2
+ module CommonwealthSearchBuilderBehavior
3
3
 
4
4
  # keep file assets from appearing in search results
5
5
  def exclude_unwanted_models(solr_parameters = {})
@@ -30,6 +30,12 @@ module CommonwealthVlrEngine
30
30
  solr_parameters[:fq] << "-#{blacklight_config.flagged_field}:[* TO *]"
31
31
  end
32
32
 
33
+ # limit results to a single institution
34
+ def institution_limit(solr_parameters = {})
35
+ solr_parameters[:fq] ||= []
36
+ solr_parameters[:fq] << '+institution_pid_ssi:"' + CommonwealthVlrEngine.config[:institution][:pid] + '"'
37
+ end
38
+
33
39
  # used by InstitutionsController#index
34
40
  def institutions_filter(solr_parameters = {})
35
41
  solr_parameters[:fq] ||= []
@@ -63,4 +69,5 @@ module CommonwealthVlrEngine
63
69
  end
64
70
 
65
71
  end
66
- end
72
+ end
73
+
@@ -0,0 +1,14 @@
1
+ class CommonwealthFlaggedSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
5
+
6
+ self.default_processor_chain += [
7
+ :exclude_unpublished_items, :flagged_filter
8
+ ]
9
+
10
+ unless I18n.t('blacklight.home.browse.institutions.enabled')
11
+ self.default_processor_chain += [:institution_limit]
12
+ end
13
+
14
+ end
@@ -0,0 +1,11 @@
1
+ class CommonwealthInstitutionsSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include BlacklightMaps::MapsSearchBuilderBehavior
5
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
6
+
7
+ self.default_processor_chain += [
8
+ :exclude_unpublished_items, :institutions_filter
9
+ ]
10
+
11
+ end
@@ -0,0 +1,15 @@
1
+ class CommonwealthMltSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include BlacklightMaps::MapsSearchBuilderBehavior
5
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
6
+
7
+ self.default_processor_chain += [
8
+ :set_solr_id_for_mlt, :exclude_unpublished_items, :exclude_volumes
9
+ ]
10
+
11
+ unless I18n.t('blacklight.home.browse.institutions.enabled')
12
+ self.default_processor_chain += [:institution_limit, :exclude_institutions]
13
+ end
14
+
15
+ end
@@ -0,0 +1,10 @@
1
+ class CommonwealthOcrSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
5
+
6
+ self.default_processor_chain += [
7
+ :exclude_unpublished_items, :ocr_search_params
8
+ ]
9
+
10
+ end
@@ -1,3 +1,3 @@
1
1
  module CommonwealthVlrEngine
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -40,7 +40,6 @@ module CommonwealthVlrEngine
40
40
  %q{
41
41
  # CatalogController-scope behavior and configuration for CommonwealthVlrEngine
42
42
  include CommonwealthVlrEngine::ControllerOverride
43
- CatalogController.search_params_logic += [:institution_limit]
44
43
  }
45
44
  end
46
45
 
@@ -48,7 +47,7 @@ module CommonwealthVlrEngine
48
47
  insert_into_file "app/controllers/#{controller_name}_controller.rb", :after => marker do
49
48
  %q{
50
49
  # SearchBuilder contains logic for adding search params to Solr
51
- config.search_builder_class = SearchBuilder
50
+ config.search_builder_class = CommonwealthSearchBuilder
52
51
 
53
52
  # limit Advanced Search facets to this institution
54
53
  # can't call SearchBuilder.institution_limit because it's an instance method, not a class method
@@ -21,7 +21,7 @@ module CommonwealthVlrEngine
21
21
  end
22
22
  end
23
23
 
24
- copy_file "commonwealth_vlr_engine.css.scss", "app/assets/stylesheets/commonwealth_vlr_engine.css.scss"
24
+ copy_file "commonwealth_vlr_engine.scss", "app/assets/stylesheets/commonwealth_vlr_engine.scss"
25
25
 
26
26
  end
27
27
 
@@ -12,26 +12,13 @@ module CommonwealthVlrEngine
12
12
 
13
13
  desc """
14
14
  This generator makes the following changes to your application:
15
- 1. Injects the institution limiter into search_builder.rb
16
- 2. Adds OpenSeadragon suppoer to solr_document.rb
15
+ 1. Adds commonwealth_search_builder.rb to app/models
16
+ 2. Adds OpenSeadragon support to solr_document.rb
17
17
  Thank you for Installing Commonwealth VLR.
18
18
  """
19
19
 
20
- # Limit the institutions
21
20
  def inject_search_builder_behavior
22
- unless IO.read("app/models/#{search_builder_model}.rb").include?('def institutions_filter')
23
- marker = 'Blacklight::Solr::SearchBuilderBehavior'
24
- insert_into_file "app/models/#{search_builder_model}.rb", :after => marker do
25
- %q{
26
-
27
- # limit to a specific institution
28
- def institution_limit(solr_parameters = {})
29
- solr_parameters[:fq] ||= []
30
- solr_parameters[:fq] << '+institution_pid_ssi:"' + CommonwealthVlrEngine.config[:institution][:pid] + '"'
31
- end
32
- }
33
- end
34
- end
21
+ copy_file "commonwealth_search_builder.rb", "app/models/commonwealth_search_builder.rb"
35
22
  end
36
23
 
37
24
  # OpenSeadragon support?
@@ -26,12 +26,20 @@ module CommonwealthVlrEngine
26
26
 
27
27
  # user authentication
28
28
  devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks", :registrations => "users/registrations", :sessions => "users/sessions"}
29
+
30
+ # bookmarks item actions
31
+ # this has to be in local app for bookmark item actions to work
32
+ put 'bookmarks/item_actions', :to => 'folder_items_actions#folder_item_actions', :as => 'selected_bookmarks_actions'
29
33
  }
30
34
  end
31
35
 
36
+ # remove Blacklight root
32
37
  bl_root_marker = 'root to: "catalog#index"'
33
38
  gsub_file("config/routes.rb", bl_root_marker, "")
34
39
 
40
+ # change '/catalog' to '/search'
41
+ gsub_file("config/routes.rb", /\/catalog/, "/search")
42
+
35
43
  end
36
44
  end
37
45
 
@@ -0,0 +1,17 @@
1
+ class CommonwealthSearchBuilder < Blacklight::SearchBuilder
2
+
3
+ include Blacklight::Solr::SearchBuilderBehavior
4
+ include BlacklightAdvancedSearch::AdvancedSearchBuilder
5
+ include BlacklightMaps::MapsSearchBuilderBehavior
6
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
7
+
8
+ self.default_processor_chain += [
9
+ :exclude_unwanted_models, :exclude_unpublished_items, :exclude_institutions,
10
+ :exclude_volumes, :add_advanced_parse_q_to_solr, :add_advanced_search_to_solr
11
+ ]
12
+
13
+ unless I18n.t('blacklight.home.browse.institutions.enabled')
14
+ self.default_processor_chain += [:institution_limit]
15
+ end
16
+
17
+ end
@@ -1,12 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
- # tests for controller actions added to CatalogController via CommonwealthVlrEngine::ControllerOverride
3
+ # tests for controller actions and configuration added to CatalogController via CommonwealthVlrEngine::ControllerOverride
4
4
  describe CatalogController do
5
5
 
6
6
  render_views
7
7
 
8
8
  #include CommonwealthVlrEngine::Finder
9
9
 
10
+ describe 'search_builder_class' do
11
+
12
+ it 'should use CommonwealthSearchBuilder' do
13
+ expect(CatalogController.blacklight_config.search_builder_class).to eq(CommonwealthSearchBuilder)
14
+ end
15
+
16
+ end
17
+
10
18
  describe 'GET "metadata_view"' do
11
19
 
12
20
  before { get :metadata_view, :id => 'bpl-dev:h702q6403'}
@@ -39,9 +47,9 @@ describe CatalogController do
39
47
 
40
48
  describe 'mlt_search' do
41
49
 
42
- it 'should include :set_solr_id_for_mlt in search_params_logic' do
50
+ it 'should modify the config to use the correct search builder class' do
43
51
  get :index, :mlt_id => 'bpl-dev:df65v790j'
44
- expect(CatalogController.search_params_logic).to include(:set_solr_id_for_mlt)
52
+ expect(controller.blacklight_config.search_builder_class).to eq(CommonwealthMltSearchBuilder)
45
53
  end
46
54
 
47
55
  end
@@ -55,6 +63,15 @@ describe CatalogController do
55
63
 
56
64
  end
57
65
 
66
+ describe 'add_institution_fields' do
67
+
68
+ it 'should add the institution-related facet fields to the config' do
69
+ get :index
70
+ expect(controller.blacklight_config.facet_fields['physical_location_ssim']).to_not be_nil
71
+ end
72
+
73
+ end
74
+
58
75
  describe 'set_nav_context' do
59
76
 
60
77
  it 'should set the nav context' do
@@ -84,9 +84,9 @@ describe CollectionsController do
84
84
  end
85
85
 
86
86
  describe 'collections_limit' do
87
- it 'should add :collections filter to search_params_logic' do
87
+ it 'should set the correct search builder class' do
88
88
  @mock_controller.send(:collections_limit)
89
- expect(@mock_controller.search_params_logic).to include(:collections_filter)
89
+ expect(@mock_controller.blacklight_config.search_builder_class).to eq(CommonwealthCollectionsSearchBuilder)
90
90
  end
91
91
  end
92
92
 
@@ -72,7 +72,7 @@ describe FolderItemsActionsController do
72
72
  :origin => "folders",
73
73
  :id => @folder,
74
74
  :selected => ["bpl-dev:g445cd14k"]
75
- expect(response).to redirect_to(citation_catalog_path(:id => ["bpl-dev:g445cd14k"]))
75
+ expect(response).to redirect_to(citation_solr_document_path(:id => ["bpl-dev:g445cd14k"]))
76
76
  end
77
77
 
78
78
  end
@@ -89,7 +89,7 @@ describe FolderItemsActionsController do
89
89
  :origin => "folders",
90
90
  :id => @folder,
91
91
  :selected => ["bpl-dev:g445cd14k"]
92
- expect(response).to redirect_to(email_catalog_path(:id => ["bpl-dev:g445cd14k"]))
92
+ expect(response).to redirect_to(email_solr_document_path(:id => ["bpl-dev:g445cd14k"]))
93
93
  end
94
94
 
95
95
  end
@@ -61,4 +61,17 @@ describe InstitutionsController do
61
61
 
62
62
  end
63
63
 
64
+ describe 'private methods and before_filters' do
65
+
66
+ describe 'institutions_index_config' do
67
+ it 'should set the appropriate blacklight_config properties' do
68
+ get :index
69
+ expect(controller.blacklight_config.search_builder_class).to eq(CommonwealthInstitutionsSearchBuilder)
70
+ expect(controller.blacklight_config.view.to_s).not_to include('gallery')
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
64
77
  end
@@ -51,6 +51,10 @@ describe OcrSearchController do
51
51
  expect(blacklight_config.add_facet_fields_to_solr_request).to eq(false)
52
52
  end
53
53
 
54
+ it 'should use the correct search builder class' do
55
+ expect(blacklight_config.search_builder_class).to eq(CommonwealthOcrSearchBuilder)
56
+ end
57
+
54
58
  let(:ocr_field) { blacklight_config.index_fields[blacklight_config.ocr_search_field] }
55
59
 
56
60
  it 'should add the ocr_search_field to the index_fields config' do
@@ -16,7 +16,7 @@ describe 'more like this search' do
16
16
  end
17
17
 
18
18
  it 'should show the constraint for a more-like-this search' do
19
- visit catalog_index_path(:mlt_id => 'bpl-dev:df65v790j', :qt => 'mlt')
19
+ visit search_catalog_path(:mlt_id => 'bpl-dev:df65v790j', :qt => 'mlt')
20
20
  expect(page).to have_selector('#appliedParams span.mlt')
21
21
  end
22
22
 
@@ -16,7 +16,7 @@ describe 'OCR search index view' do
16
16
  describe 'with current_search_session params' do
17
17
 
18
18
  before do
19
- visit catalog_index_path(q: 'foo')
19
+ visit search_catalog_path(q: 'foo')
20
20
  end
21
21
 
22
22
  it 'should display the suggestion link' do
@@ -7,7 +7,6 @@ describe InstitutionsHelper do
7
7
  include Blacklight::SearchHelper
8
8
 
9
9
  let(:blacklight_config) { CatalogController.blacklight_config }
10
- let(:search_params_logic) { CatalogController.search_params_logic += [:institutions_filter] }
11
10
 
12
11
  before :each do
13
12
  allow(helper).to receive_messages(blacklight_config: blacklight_config)
@@ -22,7 +21,7 @@ describe InstitutionsHelper do
22
21
 
23
22
  describe 'render_institutions_index' do
24
23
 
25
- before { (@response, @document_list) = search_results({}, search_params_logic) }
24
+ before { (@response, @document_list) = search_results({}) }
26
25
 
27
26
  describe 'with default document_index_view_type' do
28
27
  before { allow(helper).to receive_messages(document_index_view_type: :list) }
@@ -31,16 +30,22 @@ describe InstitutionsHelper do
31
30
  end
32
31
 
33
32
  describe 'with "maps" document_index_view_type' do
34
- before { allow(helper).to receive_messages(document_index_view_type: :maps) }
33
+
34
+ before do
35
+ allow(helper).to receive_messages(blacklight_configuration_context: Blacklight::Configuration::Context.new(CatalogController.new))
36
+ allow(helper).to receive_messages(document_index_view_type: :maps)
37
+ end
38
+
35
39
  subject { helper.render_institutions_index }
36
40
  it { should have_selector 'div#institutions-index-map' }
41
+
37
42
  end
38
43
 
39
44
  # remove the instance variables so they don't mess up other specs
40
- after {
45
+ after do
41
46
  remove_instance_variable(:@response)
42
47
  remove_instance_variable(:@document_list)
43
- }
48
+ end
44
49
 
45
50
  end
46
51
 
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommonwealthCollectionsSearchBuilder do
4
+
5
+ class CommonwealthCollectionsSearchBuilderTestClass < CommonwealthCollectionsSearchBuilder
6
+ end
7
+
8
+ before { @obj = CommonwealthCollectionsSearchBuilderTestClass.new(CatalogController.new) }
9
+
10
+ describe 'processor chain' do
11
+
12
+ it 'should add the right methods to the processor chain' do
13
+ expect(@obj.processor_chain).to include(:collections_filter)
14
+ end
15
+
16
+ end
17
+
18
+
19
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior do
4
+
5
+ let(:blacklight_params) { Hash.new }
6
+ let(:solr_parameters) { Blacklight::Solr::Request.new }
7
+
8
+ let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
9
+ let(:user_params) { Hash.new }
10
+ let(:context) { CatalogController.new }
11
+
12
+ before { allow(context).to receive(:blacklight_config).and_return(blacklight_config) }
13
+
14
+ let(:search_builder_class) do
15
+ Class.new(Blacklight::SearchBuilder) do
16
+ include Blacklight::Solr::SearchBuilderBehavior
17
+ include CommonwealthVlrEngine::CommonwealthSearchBuilderBehavior
18
+ end
19
+ end
20
+
21
+ let(:search_builder) { search_builder_class.new(context) }
22
+
23
+ describe 'exclude_unwanted_models' do
24
+
25
+ it 'should add parameters to exclude unwanted models' do
26
+ expect(search_builder.exclude_unwanted_models(solr_parameters).to_s).to include('afmodel:Bplmodels_File')
27
+ end
28
+
29
+ end
30
+
31
+ describe 'exclude_unpublished_items' do
32
+
33
+ let(:excluded_unpublished) { search_builder.exclude_unpublished_items(solr_parameters).to_s }
34
+
35
+ it 'should add parameters to exclude non-published items' do
36
+ expect(excluded_unpublished).to include('draft')
37
+ expect(excluded_unpublished).to include('needs_review')
38
+ expect(excluded_unpublished).to include('derivatives')
39
+ end
40
+
41
+ end
42
+
43
+ describe 'exclude_institutions' do
44
+
45
+ it 'should add parameters to exclude institutions' do
46
+ expect(search_builder.exclude_institutions(solr_parameters).to_s).to include('-active_fedora_model_suffix_ssi:\"Institution\"')
47
+ end
48
+
49
+ end
50
+
51
+ describe 'flagged_filter' do
52
+
53
+ it 'should add parameters to exclude flagged items' do
54
+ expect(search_builder.flagged_filter(solr_parameters).to_s).to include("-#{blacklight_config.flagged_field}:[* TO *]")
55
+ end
56
+
57
+ end
58
+
59
+ describe 'institutions_filter' do
60
+
61
+ it 'should add parameters to require institutions' do
62
+ expect(search_builder.institutions_filter(solr_parameters).to_s).to include('+active_fedora_model_suffix_ssi:\"Institution\"')
63
+ end
64
+
65
+ end
66
+
67
+ describe 'institutions_limit' do
68
+
69
+ it 'should add parameters to limit to a single institution' do
70
+ expect(search_builder.institution_limit(solr_parameters).to_s).to include('+institution_pid_ssi:\"' + CommonwealthVlrEngine.config[:institution][:pid])
71
+ end
72
+
73
+ end
74
+
75
+ describe 'set_solr_id_for_mlt' do
76
+
77
+ subject { search_builder.with({mlt_id: 'bpl-dev:12345678'}) }
78
+
79
+ it 'should set the id param to the mlt_id value' do
80
+ expect(subject.set_solr_id_for_mlt(solr_parameters)).to eq('bpl-dev:12345678')
81
+ end
82
+
83
+ end
84
+
85
+ describe 'collections_filter' do
86
+
87
+ it 'should add parameters to require institutions' do
88
+ expect(search_builder.collections_filter(solr_parameters).to_s).to include('+active_fedora_model_suffix_ssi:\"Collection\"')
89
+ end
90
+
91
+ end
92
+
93
+ describe 'exclude_volumes' do
94
+
95
+ it 'should add parameters to exclude volume objects' do
96
+ expect(search_builder.exclude_volumes(solr_parameters).to_s).to include('-active_fedora_model_suffix_ssi:\"Volume\"')
97
+ end
98
+
99
+ end
100
+
101
+ describe 'ocr_search_params' do
102
+
103
+ before do
104
+ search_builder.ocr_search_params(solr_parameters)
105
+ end
106
+
107
+ it 'should add parameters for field highlighting' do
108
+ expect(solr_parameters.to_s).to include('"hl"=>true')
109
+ expect(solr_parameters.to_s).to include('hl.fragsize')
110
+ expect(solr_parameters.to_s).to include("\"hl.fl\"=>\"#{blacklight_config.ocr_search_field}\"")
111
+ end
112
+
113
+ end
114
+
115
+
116
+ end