blacklight 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. data/VERSION +1 -1
  2. data/app/helpers/blacklight_helper.rb +2 -215
  3. data/app/helpers/facets_helper.rb +114 -0
  4. data/app/helpers/html_head_helper.rb +103 -0
  5. data/app/views/catalog/_document.html.erb +0 -2
  6. data/app/views/catalog/show.html.erb +0 -1
  7. data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
  8. data/lib/blacklight.rb +1 -0
  9. data/lib/blacklight/catalog.rb +0 -22
  10. data/lib/blacklight/kaminari_relevant_pages_patch.rb +37 -0
  11. data/lib/blacklight/routes.rb +0 -1
  12. data/lib/blacklight/solr/document.rb +3 -3
  13. data/lib/blacklight/solr_helper.rb +2 -2
  14. data/lib/generators/blacklight/assets_generator.rb +1 -1
  15. data/lib/generators/blacklight/templates/config/blacklight_config.rb +7 -13
  16. data/lib/railties/blacklight_rspec.rake +3 -1
  17. data/test_support/bin/run-tests.sh +64 -0
  18. data/test_support/bin/test.sh +12 -4
  19. data/test_support/features/step_definitions/search_steps.rb +0 -4
  20. data/test_support/features/support/paths.rb +0 -9
  21. data/test_support/spec/controllers/catalog_controller_spec.rb +0 -45
  22. data/test_support/spec/helpers/blacklight_helper_spec.rb +2 -174
  23. data/test_support/spec/helpers/facets_helper_spec.rb +100 -0
  24. data/test_support/spec/helpers/html_head_helper_spec.rb +90 -0
  25. data/test_support/spec/helpers/solr_helper_spec.rb +1 -1
  26. metadata +85 -120
  27. data/app/views/catalog/_unapi_microformat.html.erb +0 -1
  28. data/app/views/catalog/unapi.xml.builder +0 -6
  29. data/test_support/features/unapi.feature +0 -30
  30. data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +0 -46
@@ -16,6 +16,4 @@
16
16
  <% # main container for doc partial view -%>
17
17
  <%= render_document_partial document, :index %>
18
18
 
19
- <%= render_document_unapi_microformat document %>
20
-
21
19
  </div>
@@ -25,7 +25,6 @@
25
25
  <div class="document">
26
26
  <%= render_document_partial @document, :show %>
27
27
  </div>
28
- <%= render_document_unapi_microformat @document %>
29
28
  </div>
30
29
  </div>
31
30
 
@@ -11,7 +11,7 @@
11
11
  <%= prev_page_tag %>
12
12
  <%= next_page_tag %>
13
13
  <div class="page_links">
14
- <% each_page do |page| -%>
14
+ <% each_relevant_page do |page| -%>
15
15
  <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
16
16
  <%= page_tag page %>
17
17
  <% elsif !page.was_truncated? -%>
@@ -1,5 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'kaminari'
3
+ require 'blacklight/kaminari_relevant_pages_patch'
3
4
  require 'marc'
4
5
  require 'rsolr'
5
6
  require 'rsolr-ext'
@@ -30,7 +30,6 @@ module Blacklight::Catalog
30
30
 
31
31
  extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
32
32
  extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
33
- extra_head_content << view_context.auto_discovery_link_tag(:unapi, unapi_url, {:type => 'application/xml', :rel => 'unapi-server', :title => 'unAPI' })
34
33
 
35
34
  (@response, @document_list) = get_search_results
36
35
  @filters = params[:f] || []
@@ -45,7 +44,6 @@ module Blacklight::Catalog
45
44
 
46
45
  # get single document from the solr index
47
46
  def show
48
- extra_head_content << view_context.auto_discovery_link_tag(:unapi, unapi_url, {:type => 'application/xml', :rel => 'unapi-server', :title => 'unAPI' })
49
47
  @response, @document = get_solr_response_for_doc_id
50
48
 
51
49
  respond_to do |format|
@@ -62,26 +60,6 @@ module Blacklight::Catalog
62
60
  end
63
61
  end
64
62
 
65
- def unapi
66
- @export_formats = Blacklight.config[:unapi] || {}
67
- @format = params[:format]
68
- if params[:id]
69
- @response, @document = get_solr_response_for_doc_id
70
- @export_formats = @document.export_formats
71
- end
72
-
73
- unless @format
74
- render 'unapi.xml.builder', :layout => false and return
75
- end
76
-
77
- respond_to do |format|
78
- format.all do
79
- send_data @document.export_as(@format), :type => @document.export_formats[@format][:content_type], :disposition => 'inline' if @document.will_export_as @format
80
- end
81
- end
82
- end
83
-
84
-
85
63
  # updates the search counter (allows the show view to paginate)
86
64
  def update
87
65
  adjust_for_results_view
@@ -0,0 +1,37 @@
1
+ module Blacklight
2
+ module KaminariRelevantPagesPatch
3
+ module Windows
4
+ def relevant_pages options
5
+ [left_window(options), inside_window(options), right_window(options)].map(&:to_a).flatten.uniq.sort.reject { |x| x < 1 or x > options[:num_pages] }
6
+ end
7
+
8
+ def all_pages options
9
+ 1.upto(options[:num_pages])
10
+ end
11
+
12
+ protected
13
+ def left_window options
14
+ 1.upto(options[:left] + 1)
15
+ end
16
+
17
+ def right_window options
18
+ (options[:num_pages] - options[:right]).upto(options[:num_pages])
19
+ end
20
+
21
+ def inside_window options
22
+ (options[:current_page] - options[:window]).upto(options[:current_page] + options[:window])
23
+ end
24
+ end
25
+
26
+ include Windows
27
+ def each_relevant_page
28
+ return to_enum(:each_relevant_page) unless block_given?
29
+
30
+ relevant_pages(@window_options.merge(@options)).each do |i|
31
+ yield Kaminari::Helpers::Paginator::PageProxy.new(@window_options.merge(@options), i, @last)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ Kaminari::Helpers::Paginator.send(:include, Blacklight::KaminariRelevantPagesPatch)
@@ -71,7 +71,6 @@ module Blacklight
71
71
  match 'catalog/endnote', :as => "endnote_catalog"
72
72
  match 'catalog/send_email_record', :as => "send_email_record_catalog"
73
73
  match "catalog/facet/:id", :to => 'catalog#facet', :as => 'catalog_facet'
74
- match 'catalog/unapi', :to => "catalog#unapi", :as => 'unapi'
75
74
  resources :catalog, :only => [:index, :show, :update]
76
75
  match 'catalog/:id/librarian_view', :to => "catalog#librarian_view", :as => "librarian_view_catalog"
77
76
  end
@@ -49,7 +49,7 @@ require 'rsolr-ext'
49
49
  # If an extension advertises what export formats it can provide, than those
50
50
  # formats will automatically be delivered by the Blacklight catalog/show
51
51
  # controller, and potentially automatically advertised in various places
52
- # that advertise available formats. (UnAPI; HTML link rel=alternate; Atom
52
+ # that advertise available formats. (HTML link rel=alternate; Atom
53
53
  # link rel=alterate; etc).
54
54
  #
55
55
  # Export formats are 'registered' by calling the #will_export_as method
@@ -129,10 +129,10 @@ module Blacklight::Solr::Document
129
129
  # some 'api' to Mime::Type that may or may not be entirely
130
130
  # public, the fact that a Mime::CONST is registered for every
131
131
  # type. But that's the only way to do the kind of check we need, sorry.
132
- begin
132
+ if defined?(Mime) && Mime.const_defined?(short_name.to_s.upcase)
133
133
  mime_type = "Mime::#{short_name.to_s.upcase}".constantize
134
134
  content_type = mime_type.to_s unless content_type
135
- rescue NameError,LoadError
135
+ else
136
136
  # not registered, we need to register. Use register_alias to be least
137
137
  # likely to interfere with host app.
138
138
  Mime::Type.register_alias(content_type, short_name)
@@ -60,13 +60,13 @@ module Blacklight::SolrHelper
60
60
  # similar design. Since we're a module, we have to add it in here.
61
61
  # There are too many different semantic choices in ruby 'class variables',
62
62
  # we choose this one for now, supplied by Rails.
63
- class_inheritable_accessor :solr_search_params_logic
63
+ class_attribute :solr_search_params_logic
64
64
 
65
65
  # Set defaults. Each symbol identifies a _method_ that must be in
66
66
  # this class, taking two parameters (solr_parameters, user_parameters)
67
67
  # Can be changed in local apps or by plugins, eg:
68
68
  # CatalogController.include ModuleDefiningNewMethod
69
- # CatalogController.solr_search_params_logic << :new_method
69
+ # CatalogController.solr_search_params_logic += [:new_method]
70
70
  # CatalogController.solr_search_params_logic.delete(:we_dont_want)
71
71
  self.solr_search_params_logic = [:default_solr_parameters , :add_query_to_solr, :add_facet_fq_to_solr, :add_facetting_to_solr, :add_sorting_paging_to_solr ]
72
72
  end
@@ -18,7 +18,7 @@ module Blacklight
18
18
 
19
19
  def assets
20
20
  if use_asset_pipeline?
21
- insert_into_file "app/assets/stylesheets/application.css", :after => " *= require_self" do
21
+ insert_into_file "app/assets/stylesheets/application.css", :after => "/*" do
22
22
  %q{
23
23
  *
24
24
  * Required by Blacklight
@@ -24,18 +24,19 @@ Blacklight.configure(:shared) do |config|
24
24
  :per_page => 10
25
25
  }
26
26
 
27
- # solr field values given special treatment in the show (single result) view
27
+ # solr field configuration for search results/index views
28
+ config[:index] = {
29
+ :show_link => "title_display",
30
+ :record_display_type => "format"
31
+ }
32
+
33
+ # solr field configuration for document/show views
28
34
  config[:show] = {
29
35
  :html_title => "title_display",
30
36
  :heading => "title_display",
31
37
  :display_type => "format"
32
38
  }
33
39
 
34
- # solr fld values given special treatment in the index (search results) view
35
- config[:index] = {
36
- :show_link => "title_display",
37
- :record_display_type => "format"
38
- }
39
40
 
40
41
  # solr fields that will be treated as facets by the blacklight application
41
42
  # The ordering of the field names is the order of the display
@@ -235,12 +236,5 @@ Blacklight.configure(:shared) do |config|
235
236
  # mean") suggestion is offered.
236
237
  config[:spell_max] = 5
237
238
 
238
- # Add documents to the list of object formats that are supported for all objects.
239
- # This parameter is a hash, identical to the Blacklight::Solr::Document#export_formats
240
- # output; keys are format short-names that can be exported. Hash includes:
241
- # :content-type => mime-content-type
242
- config[:unapi] = {
243
- 'oai_dc_xml' => { :content_type => 'text/xml' }
244
- }
245
239
  end
246
240
 
@@ -10,7 +10,9 @@
10
10
  begin
11
11
  require 'rspec/core'
12
12
  require 'rspec/core/rake_task'
13
- Rake.application.instance_variable_get('@tasks')['default'].prerequisites.delete('test')
13
+ if default = Rake.application.instance_variable_get('@tasks')['default']
14
+ default.prerequisites.delete('test')
15
+ end
14
16
 
15
17
  spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "db:test:prepare" : :noop
16
18
  task :noop do; end
@@ -0,0 +1,64 @@
1
+ #!/bin/bash
2
+ # test.sh
3
+ # Create a default rails appliaction, install blacklight, and run all the tests.
4
+
5
+ before="$(date +%s)"
6
+ benchmark()
7
+ {
8
+ after="$(date +%s)"
9
+ elapsed_seconds="$(expr $after - $before)"
10
+ echo "Total Time: ${elapsed_seconds} sec"
11
+ # as a bonus, make our script exit with the right error code.
12
+ }
13
+
14
+ check_errs()
15
+ {
16
+ # Function. Parameter 1 is the return code
17
+ # Para. 2 is text to display on failure.
18
+ if [ "${1}" -ne "0" ]; then
19
+ echo "ERROR # ${1} : ${2}"
20
+
21
+ # Attempt to shut down jetty, if set.
22
+ if [ $jetty_pid ]
23
+ then
24
+ kill $jetty_pid
25
+ fi
26
+ benchmark
27
+ exit 1
28
+ fi
29
+ }
30
+
31
+ # Make sure we are in the blacklight directory
32
+ if [ ! -f "blacklight.gemspec" ]
33
+ then
34
+ echo "You must execute test.sh from the root of your blacklight checkout."
35
+ exit 1
36
+ fi
37
+
38
+ # Make certain rvn will work correctly.
39
+ # Load RVM into a shell session *as a function*
40
+ if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
41
+ # First try to load from a user install
42
+ source "$HOME/.rvm/scripts/rvm"
43
+ elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
44
+ # Then try to load from a root install
45
+ source "/usr/local/rvm/scripts/rvm"
46
+ else
47
+ printf "ERROR: An RVM installation was not found.\n"
48
+ exit 1
49
+ fi
50
+
51
+
52
+ rvm use "$@" --create
53
+ check_errs $? "rvm failed. please run 'rvm install $@', and then re-run these tests."
54
+
55
+ cd tmp/test_app
56
+ cd test_jetty
57
+ java -Djetty.port=8888 -Dsolr.solr.home=./solr -jar start.jar &> /dev/null &
58
+ jetty_pid=$!
59
+ cd ..
60
+ bundle exec rake blacklight:spec
61
+ check_errs $? "Rpec Tests failed."
62
+ bundle exec rake blacklight:cucumber
63
+ check_errs $? "Cucumber Tests failed."
64
+ benchmark
@@ -56,9 +56,15 @@ fi
56
56
 
57
57
  rvm use "$@" --create
58
58
  check_errs $? "rvm failed. please run 'rvm install $@', and then re-run these tests."
59
- gem install --no-rdoc --no-ri 'rails'
60
- gem install --no-rdoc --no-ri 'bundler'
61
- gem install --no-rdoc --no-ri 'devise'
59
+
60
+ if ! gem query -n rails -v "~>3.0" --installed > /dev/null; then
61
+ gem install --no-rdoc --no-ri 'rails'
62
+ fi
63
+
64
+ if ! gem query -n bundler -v ">=1.0" --installed > /dev/null; then
65
+ gem install --no-rdoc --no-ri 'bundler'
66
+ fi
67
+
62
68
  rails new test_app
63
69
  cd test_app
64
70
  echo "
@@ -87,6 +93,8 @@ group :development, :test do
87
93
  gem 'webrat'
88
94
  gem 'aruba'
89
95
  end
96
+
97
+ gem 'devise'
90
98
  " > Gemfile
91
99
 
92
100
  bundle install --local &> /dev/null
@@ -119,4 +127,4 @@ bundle exec rake blacklight:spec
119
127
  check_errs $? "Rpec Tests failed."
120
128
  bundle exec rake blacklight:cucumber
121
129
  check_errs $? "Cucumber Tests failed."
122
- benchmark
130
+ benchmark
@@ -83,10 +83,6 @@ Then /^I should see an atom discovery link/ do
83
83
  page.should have_selector("link[rel=alternate][type='application/atom+xml']")
84
84
  end
85
85
 
86
- Then /^I should see an unAPI discovery link/ do
87
- page.should have_selector("link[rel=unapi-server][type='application/xml']")
88
- end
89
-
90
86
  Then /^I should see opensearch response metadata tags/ do
91
87
  page.should have_selector("meta[name=totalResults]")
92
88
  page.should have_selector("meta[name=startIndex]")
@@ -25,15 +25,6 @@ module NavigationHelpers
25
25
  when /the facet page for "([^\"]*)"/
26
26
  catalog_facet_path($1)
27
27
 
28
- when /the unAPI endpoint for "([^\"]+)" with format "([^\"]+)"/
29
- unapi_path(:id => $1, :format => $2)
30
-
31
- when /the unAPI endpoint for "([^\"]+)"/
32
- unapi_path(:id => $1)
33
-
34
- when /the unAPI endpoint/
35
- unapi_path
36
-
37
28
  # Add more mappings here.
38
29
  # Here is an example that pulls values out of the Regexp:
39
30
  #
@@ -302,51 +302,6 @@ describe CatalogController do
302
302
 
303
303
  end # describe show action
304
304
 
305
- describe "unapi" do
306
- doc_id = '2007020969'
307
- module FakeExtension
308
- def self.extended(document)
309
- document.will_export_as(:mock, "application/mock")
310
- document.will_export_as(:mockxml, "text/xml")
311
- end
312
-
313
- def export_as_mock
314
- "mock_export"
315
- end
316
-
317
- def export_as_mockxml
318
- "<a><mock xml='document' /></a>"
319
- end
320
- end
321
- before(:each) do
322
- SolrDocument.registered_extensions = nil
323
- SolrDocument.use_extension(FakeExtension)
324
- end
325
-
326
- it "should return an unapi formats list from config[:unapi]" do
327
- Blacklight.config[:unapi] = { :mock => { :content_type => "application/mock" } }
328
- get :unapi
329
- response.should be_success
330
- assigns[:export_formats][:mock][:content_type].should == "application/mock"
331
- end
332
-
333
-
334
- it "should return an unapi formats list for document" do
335
- get :unapi, :id => doc_id
336
- response.should be_success
337
- assigns[:document].should be_kind_of(SolrDocument)
338
- assigns[:export_formats].should_not be_nil
339
- assigns[:export_formats].should be_kind_of(Hash)
340
- assigns[:export_formats][:mock] == { :content_type => "application/mock" }
341
- assigns[:export_formats][:mockxml] = { :content_type => 'text/xml' }
342
- end
343
-
344
- it "should return an unapi format export for document" do
345
- get :unapi, :id => doc_id, :format => 'mock'
346
- response.should be_success
347
- response.should contain("mock_export")
348
- end
349
- end
350
305
 
351
306
  describe "opensearch" do
352
307
  it "should return an opensearch description" do
@@ -1,4 +1,4 @@
1
- # -*- encoding : utf-8 -*-
1
+ #ste -*- encoding : utf-8 -*-
2
2
  # -*- coding: UTF-8 -*-
3
3
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
4
  require 'marc'
@@ -24,7 +24,7 @@ def exportable_record
24
24
 
25
25
  <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
26
26
  <subfield code=\"a\">Greer, Lowell.</subfield>
27
- </datafield>
27
+ </datafield>
28
28
 
29
29
  <datafield tag=\"700\" ind1=\"1\" ind2=\" \">
30
30
  <subfield code=\"a\">Lubin, Steven.</subfield>
@@ -147,91 +147,8 @@ describe BlacklightHelper do
147
147
  end
148
148
  end
149
149
  end
150
-
151
150
  end
152
151
 
153
- describe "render_stylesheet_links" do
154
- def stylesheet_links
155
- [
156
- ["my_stylesheet", {:plugin => :blacklight}],
157
- ["other_stylesheet"]
158
- ]
159
- end
160
- it "should render stylesheets specified in controller #stylesheet_links" do
161
- html = render_stylesheet_includes
162
- html.should have_selector("link[href='/stylesheets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
163
- html.should have_selector("link[href='/stylesheets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
164
- html.html_safe?.should == true
165
- end
166
- end
167
-
168
- describe "render_js_includes" do
169
- def javascript_includes
170
- [
171
- ["some_js.js", {:plugin => :blacklight}],
172
- ["other_js"]
173
- ]
174
- end
175
- it "should include script tags specified in controller#javascript_includes" do
176
- html = render_js_includes
177
- html.should have_selector("script[src='/javascripts/some_js.js'][type='text/javascript']")
178
- html.should have_selector("script[src='/javascripts/other_js.js'][type='text/javascript']")
179
-
180
- html.html_safe?.should == true
181
- end
182
- end
183
-
184
- describe "render_extra_head_content" do
185
- def extra_head_content
186
- ['<link rel="a">', '<link rel="b">']
187
- end
188
-
189
- it "should include content specified in controller#extra_head_content" do
190
- html = render_extra_head_content
191
-
192
- html.should have_selector("link[rel=a]")
193
- html.should have_selector("link[rel=b]")
194
-
195
- html.html_safe?.should == true
196
- end
197
- end
198
-
199
- describe "render_head_content" do
200
- describe "with no methods defined" do
201
- it "should return empty string without complaint" do
202
- lambda {render_head_content}.should_not raise_error
203
- render_head_content.should be_blank
204
- render_head_content.html_safe?.should == true
205
- end
206
- end
207
- describe "with methods defined" do
208
- def javascript_includes
209
- [["my_js"]]
210
- end
211
- def stylesheet_links
212
- [["my_css"]]
213
- end
214
- def extra_head_content
215
- [
216
- "<madeup_tag></madeup_tag>",
217
- '<link rel="rel" type="type" href="href">'
218
- ]
219
- end
220
- before(:each) do
221
- @output = render_head_content
222
- end
223
- it "should include extra_head_content" do
224
- @output.should have_selector("madeup_tag")
225
- @output.should have_selector("link[rel=rel][type=type][href=href]")
226
- end
227
- it "should include render_javascript_includes" do
228
- @output.index( render_js_includes ).should_not be_nil
229
- end
230
- it "should include render_stylesheet_links" do
231
- @output.index( render_stylesheet_includes ).should_not be_nil
232
- end
233
- end
234
- end
235
152
 
236
153
  describe "render body class" do
237
154
  it "should include a serialization of the current controller name" do
@@ -331,95 +248,6 @@ describe BlacklightHelper do
331
248
  end
332
249
  end
333
250
 
334
- describe "add_facet_params" do
335
- before do
336
- @params_no_existing_facet = {:q => "query", :search_field => "search_field", :per_page => "50"}
337
- @params_existing_facets = {:q => "query", :search_field => "search_field", :per_page => "50", :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]}}
338
- end
339
-
340
- it "should add facet value for no pre-existing facets" do
341
- helper.stub!(:params).and_return(@params_no_existing_facet)
342
-
343
- result_params = helper.add_facet_params("facet_field", "facet_value")
344
- result_params[:f].should be_a_kind_of(Hash)
345
- result_params[:f]["facet_field"].should be_a_kind_of(Array)
346
- result_params[:f]["facet_field"].should == ["facet_value"]
347
- end
348
-
349
- it "should add a facet param to existing facet constraints" do
350
- helper.stub!(:params).and_return(@params_existing_facets)
351
-
352
- result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
353
-
354
- result_params[:f].should be_a_kind_of(Hash)
355
-
356
- @params_existing_facets[:f].each_pair do |facet_field, value_list|
357
- result_params[:f][facet_field].should be_a_kind_of(Array)
358
-
359
- if facet_field == 'facet_field_2'
360
- result_params[:f][facet_field].should == (@params_existing_facets[:f][facet_field] | ["new_facet_value"])
361
- else
362
- result_params[:f][facet_field].should == @params_existing_facets[:f][facet_field]
363
- end
364
- end
365
- end
366
- it "should leave non-facet params alone" do
367
- [@params_existing_facets, @params_no_existing_facet].each do |params|
368
- helper.stub!(:params).and_return(params)
369
-
370
- result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
371
-
372
- params.each_pair do |key, value|
373
- next if key == :f
374
- result_params[key].should == params[key]
375
- end
376
- end
377
- end
378
- end
379
-
380
- describe "add_facet_params_and_redirect" do
381
- before do
382
- catalog_facet_params = {:q => "query",
383
- :search_field => "search_field",
384
- :per_page => "50",
385
- :page => "5",
386
- :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
387
- Blacklight::Solr::FacetPaginator.request_keys[:offset] => "100",
388
- Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
389
- :id => 'facet_field_name'
390
- }
391
- helper.stub!(:params).and_return(catalog_facet_params)
392
- end
393
- it "should redirect to 'index' action" do
394
- params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
395
-
396
- params[:action].should == "index"
397
- end
398
- it "should not include request parameters used by the facet paginator" do
399
- params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
400
-
401
- bad_keys = Blacklight::Solr::FacetPaginator.request_keys.values + [:id]
402
- bad_keys.each do |paginator_key|
403
- params.keys.should_not include(paginator_key)
404
- end
405
- end
406
- it 'should remove :page request key' do
407
- params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
408
-
409
- params.keys.should_not include(:page)
410
- end
411
- it "should otherwise do the same thing as add_facet_params" do
412
- added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
413
- added_facet_params_from_facet_action = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
414
-
415
- added_facet_params_from_facet_action.each_pair do |key, value|
416
- next if key == :action
417
- value.should == added_facet_params[key]
418
- end
419
- end
420
-
421
-
422
- end
423
251
 
424
252
  describe "render_link_rel_alternates" do
425
253
  class MockDocumentAppHelper