blacklight 5.2.0 → 5.3.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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/ajax_modal.js +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +21 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +15 -3
- data/app/views/layouts/blacklight.html.erb +3 -15
- data/app/views/shared/_ajax_modal.html.erb +6 -0
- data/app/views/shared/_flash_messages.html.erb +7 -0
- data/gemfiles/rails4.1.gemfile +2 -0
- data/gemfiles/rails4.gemfile +3 -0
- data/lib/blacklight/catalog.rb +2 -0
- data/lib/blacklight/configuration.rb +9 -1
- data/lib/railties/blacklight.rake +94 -1
- data/spec/controllers/catalog_controller_spec.rb +5 -0
- data/spec/features/search_context_spec.rb +46 -0
- data/spec/features/search_results_spec.rb +0 -22
- data/spec/helpers/blacklight_helper_spec.rb +39 -0
- data/spec/helpers/url_helper_spec.rb +40 -11
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +2 -1
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -4
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +2 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d93877de36068052dea5532f02351756789a2bd
|
4
|
+
data.tar.gz: 9103ab9e7d7a91c17de2233aed70f0f3e7df5c4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eec942d25ae5133dff56c7dbe1b3d169b01510bfdb86adfb99ba533e230e04287c988f86b58e9104e62a6617f3c93bc1bca009085ed6be98bdbb03ccedc5c5e
|
7
|
+
data.tar.gz: dd0767408947a969b6bb130b65d38e243e664d2efce6667d9d23d29b6c8bff5847a3909104f4da4d53782e890e82c23c984f2e8b370e46e398a5d78872179806
|
data/.travis.yml
CHANGED
@@ -3,11 +3,17 @@ notifications:
|
|
3
3
|
|
4
4
|
rvm:
|
5
5
|
- 2.1.1
|
6
|
-
- 2.1.0
|
7
6
|
- 2.0.0
|
8
|
-
- 1.9.3
|
9
|
-
- jruby
|
10
7
|
|
8
|
+
matrix:
|
9
|
+
include:
|
10
|
+
- rvm: 2.1.0
|
11
|
+
gemfile: gemfiles/rails4.gemfile
|
12
|
+
- rvm: 1.9.3
|
13
|
+
gemfile: gemfiles/rails4.gemfile
|
14
|
+
- rvm: jruby
|
15
|
+
gemfile: gemfiles/rails4.gemfile
|
16
|
+
|
11
17
|
before_install:
|
12
18
|
- gem install bundler
|
13
19
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.3.0
|
@@ -96,7 +96,7 @@ Blacklight.ajaxModal.triggerFormSelector = "form[data-ajax-modal~=trigger], for
|
|
96
96
|
// be preserved. MUST be manually prefixed with the modal selector,
|
97
97
|
// so they only apply to things inside a modal.
|
98
98
|
Blacklight.ajaxModal.preserveLinkSelector = Blacklight.ajaxModal.modalSelector + ' a[data-ajax-modal~=preserve]';
|
99
|
-
Blacklight.ajaxModal.preserveFormSelector = Blacklight.ajaxModal.modalSelector + 'form[data-ajax-modal~=preserve]'
|
99
|
+
Blacklight.ajaxModal.preserveFormSelector = Blacklight.ajaxModal.modalSelector + ' form[data-ajax-modal~=preserve]'
|
100
100
|
|
101
101
|
Blacklight.ajaxModal.containerSelector = "[data-ajax-modal~=container]";
|
102
102
|
|
@@ -443,7 +443,21 @@ module Blacklight::BlacklightHelperBehavior
|
|
443
443
|
|
444
444
|
display_type ||= 'default'
|
445
445
|
|
446
|
-
|
446
|
+
type_field_to_partial_name(document, display_type)
|
447
|
+
end
|
448
|
+
|
449
|
+
##
|
450
|
+
# Return a partial name for rendering a document
|
451
|
+
# this method can be overridden in order to transform the value
|
452
|
+
# (e.g. 'PdfBook' => 'pdf_book')
|
453
|
+
#
|
454
|
+
# @param [SolrDocument] document
|
455
|
+
# @param [String, Array] display_type a value suggestive of a partial
|
456
|
+
# @return [String] the name of the partial to render
|
457
|
+
# @example
|
458
|
+
# type_field_to_partial_name(['a book-article'])
|
459
|
+
# => 'a_book_article'
|
460
|
+
def type_field_to_partial_name(document, display_type)
|
447
461
|
# using "_" as sep. to more closely follow the views file naming conventions
|
448
462
|
# parameterize uses "-" as the default sep. which throws errors
|
449
463
|
Array(display_type).join(" ").gsub("-","_").parameterize("_")
|
@@ -561,4 +575,10 @@ module Blacklight::BlacklightHelperBehavior
|
|
561
575
|
def presenter_class
|
562
576
|
Blacklight::DocumentPresenter
|
563
577
|
end
|
578
|
+
|
579
|
+
##
|
580
|
+
# Open Search discovery tag for HTML <head> links
|
581
|
+
def opensearch_description_tag title, href
|
582
|
+
tag :link, href: href, title: title, type: "application/opensearchdescription+xml", rel: "search"
|
583
|
+
end
|
564
584
|
end
|
@@ -8,9 +8,12 @@ module Blacklight::UrlHelperBehavior
|
|
8
8
|
# to provide more interesting routing to
|
9
9
|
# documents
|
10
10
|
def url_for_document doc
|
11
|
-
if
|
11
|
+
if respond_to?(:blacklight_config) and
|
12
|
+
blacklight_config.show.route and
|
12
13
|
(!doc.respond_to?(:to_model) or doc.to_model.is_a? SolrDocument)
|
13
|
-
|
14
|
+
route = blacklight_config.show.route.merge(action: :show, id: doc)
|
15
|
+
route[:controller] = controller_name if route[:controller] == :current
|
16
|
+
route
|
14
17
|
else
|
15
18
|
doc
|
16
19
|
end
|
@@ -68,7 +71,7 @@ module Blacklight::UrlHelperBehavior
|
|
68
71
|
return {}
|
69
72
|
end
|
70
73
|
|
71
|
-
{ :data => {:'context-href' => track_solr_document_path(document, counter: counter, search_id: current_search_session.try(:id))}}
|
74
|
+
{ :data => {:'context-href' => track_solr_document_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
|
72
75
|
end
|
73
76
|
protected :session_tracking_params
|
74
77
|
|
@@ -103,6 +106,15 @@ module Blacklight::UrlHelperBehavior
|
|
103
106
|
def link_back_to_catalog(opts={:label=>nil})
|
104
107
|
scope = opts.delete(:route_set) || self
|
105
108
|
query_params = current_search_session.try(:query_params) || {}
|
109
|
+
|
110
|
+
if search_session['counter']
|
111
|
+
per_page = (search_session['per_page'] || default_per_page).to_i
|
112
|
+
counter = search_session['counter'].to_i
|
113
|
+
|
114
|
+
query_params[:per_page] = per_page unless search_session['per_page'].to_i == default_per_page
|
115
|
+
query_params[:page] = ((counter - 1)/ per_page) + 1
|
116
|
+
end
|
117
|
+
|
106
118
|
link_url = scope.url_for(query_params)
|
107
119
|
label = opts.delete(:label)
|
108
120
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<![endif]-->
|
15
15
|
|
16
16
|
<title><%= render_page_title %></title>
|
17
|
-
|
17
|
+
<%= opensearch_description_tag application_name, opensearch_catalog_path(:format => 'xml', :only_path => false) %>
|
18
18
|
<%= favicon_link_tag asset_path('favicon.ico') %>
|
19
19
|
<%= stylesheet_link_tag "application" %>
|
20
20
|
<%= javascript_include_tag "application" %>
|
@@ -30,22 +30,10 @@
|
|
30
30
|
<body class="<%= render_body_class %>">
|
31
31
|
<%= render :partial => 'shared/header_navbar' %>
|
32
32
|
|
33
|
-
|
34
|
-
<div class="modal-dialog">
|
35
|
-
<div class="modal-content">
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
</div>
|
33
|
+
<%= render partial: 'shared/ajax_modal' %>
|
39
34
|
|
40
|
-
<!-- /container -->
|
41
35
|
<div id="main-container" class="container">
|
42
|
-
|
43
|
-
<div class="col-md-12">
|
44
|
-
<div id="main-flashes">
|
45
|
-
<%= render :partial=>'/flash_msg' %>
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
</div>
|
36
|
+
<%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %>
|
49
37
|
|
50
38
|
<div class="row">
|
51
39
|
<%= yield %>
|
data/gemfiles/rails4.1.gemfile
CHANGED
data/gemfiles/rails4.gemfile
CHANGED
data/lib/blacklight/catalog.rb
CHANGED
@@ -59,6 +59,8 @@ module Blacklight::Catalog
|
|
59
59
|
# updates the search counter (allows the show view to paginate)
|
60
60
|
def track
|
61
61
|
search_session['counter'] = params[:counter]
|
62
|
+
search_session['per_page'] = params[:per_page]
|
63
|
+
|
62
64
|
path = if params[:redirect] and (params[:redirect].starts_with?("/") or params[:redirect] =~ URI::regexp)
|
63
65
|
URI.parse(params[:redirect]).path
|
64
66
|
else
|
@@ -61,7 +61,15 @@ module Blacklight
|
|
61
61
|
:respond_to => OpenStructWithHashAccess.new()
|
62
62
|
),
|
63
63
|
# Additional configuration when displaying a single document
|
64
|
-
:show => ViewConfig::Show.new(
|
64
|
+
:show => ViewConfig::Show.new(
|
65
|
+
# default route parameters for 'show' requests
|
66
|
+
# set this to a hash with additional arguments to merge into
|
67
|
+
# the route, or set `controller: :current` to route to the
|
68
|
+
# current controller.
|
69
|
+
route: nil,
|
70
|
+
# partials to render for each document(see #render_document_partials)
|
71
|
+
partials: [:show_header, :show]
|
72
|
+
),
|
65
73
|
# Configurations for specific types of index views
|
66
74
|
:view => NestedOpenStructWithHashAccess.new(ViewConfig, 'list'),
|
67
75
|
# Maxiumum number of spelling suggestions to offer
|
@@ -19,6 +19,99 @@ namespace :blacklight do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
namespace :check do
|
23
|
+
desc "Check the Solr connection and controller configuration"
|
24
|
+
task :solr, [:controller_name] => [:environment] do |_, args|
|
25
|
+
errors = 0
|
26
|
+
verbose = ENV.fetch('VERBOSE', false).present?
|
27
|
+
|
28
|
+
puts "[#{Blacklight.solr.uri}]"
|
29
|
+
|
30
|
+
print " - admin/ping: "
|
31
|
+
begin
|
32
|
+
response = Blacklight.solr.send_and_receive 'admin/ping', {}
|
33
|
+
puts response['status']
|
34
|
+
errors += 1 unless response['status'] == "OK"
|
35
|
+
rescue Exception => e
|
36
|
+
errors += 1
|
37
|
+
puts e.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
exit 1 if errors > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
task :controller, [:controller_name] => [:environment] do |_, args|
|
44
|
+
errors = 0
|
45
|
+
verbose = ENV.fetch('VERBOSE', false).present?
|
46
|
+
controller = args[:controller_name].constantize.new if args[:controller_name]
|
47
|
+
controller ||= CatalogController.new
|
48
|
+
|
49
|
+
puts "[#{controller.class.to_s}]"
|
50
|
+
|
51
|
+
print " - find: "
|
52
|
+
|
53
|
+
begin
|
54
|
+
response = controller.find q: '{!lucene}*:*'
|
55
|
+
if response.header['status'] == 0
|
56
|
+
puts "OK"
|
57
|
+
else
|
58
|
+
errors += 1
|
59
|
+
end
|
60
|
+
|
61
|
+
if verbose
|
62
|
+
puts "\tstatus: #{response.header['status']}"
|
63
|
+
puts "\tnumFound: #{response.response['numFound']}"
|
64
|
+
puts "\tdoc count: #{response.docs.length}"
|
65
|
+
puts "\tfacet fields: #{response.facets.length}"
|
66
|
+
end
|
67
|
+
rescue Exception => e
|
68
|
+
errors += 1
|
69
|
+
puts e.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
print " - get_search_results: "
|
23
73
|
|
74
|
+
begin
|
75
|
+
response, docs = controller.get_search_results({}, q: '{!lucene}*:*')
|
76
|
+
|
77
|
+
if response.header['status'] == 0 and docs.length > 0
|
78
|
+
puts "OK"
|
79
|
+
else
|
80
|
+
errors += 1
|
81
|
+
end
|
82
|
+
|
83
|
+
if verbose
|
84
|
+
puts "\tstatus: #{response.header['status']}"
|
85
|
+
puts "\tnumFound: #{response.response['numFound']}"
|
86
|
+
puts "\tdoc count: #{docs.length}"
|
87
|
+
puts "\tfacet fields: #{response.facets.length}"
|
88
|
+
end
|
89
|
+
rescue Exception => e
|
90
|
+
errors += 1
|
91
|
+
puts e.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
print " - get_solr_response_for_doc_id: "
|
95
|
+
|
96
|
+
begin
|
97
|
+
doc_id = response.docs.first[SolrDocument.unique_key]
|
98
|
+
response, doc = controller.get_solr_response_for_doc_id doc_id
|
24
99
|
|
100
|
+
if response.header['status'] == 0 and doc
|
101
|
+
puts "OK"
|
102
|
+
else
|
103
|
+
errors += 1
|
104
|
+
end
|
105
|
+
|
106
|
+
if verbose
|
107
|
+
puts "\tstatus: #{response.header['status']}"
|
108
|
+
end
|
109
|
+
rescue Exception => e
|
110
|
+
errors += 1
|
111
|
+
puts e.to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
exit 1 if errors > 0
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -202,6 +202,11 @@ describe CatalogController do
|
|
202
202
|
put :track, :id => doc_id, :counter => 3
|
203
203
|
expect(session[:search]['counter']).to eq "3"
|
204
204
|
end
|
205
|
+
|
206
|
+
it "should record the current per_page setting" do
|
207
|
+
put :track, :id => doc_id, :counter => 3, :per_page => 15
|
208
|
+
expect(session[:search]['per_page']).to eq "15"
|
209
|
+
end
|
205
210
|
|
206
211
|
it "should redirect to show action for doc id" do
|
207
212
|
put :track, :id => doc_id, :counter => 3
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Search Results context", js: true do
|
6
|
+
it "should pass the current search id through" do
|
7
|
+
search_for ''
|
8
|
+
search_id = Search.last.id.to_s
|
9
|
+
click_on 'Pluvial nectar of blessings'
|
10
|
+
expect(page).to have_content "« Previous | 10 of 30 | Next »"
|
11
|
+
prev = page.find("#previousNextDocument .previous")
|
12
|
+
expect(prev['data-context-href']).to eq "/catalog/2003546302/track?counter=9&search_id=#{search_id}"
|
13
|
+
|
14
|
+
click_on "« Previous"
|
15
|
+
|
16
|
+
prev = page.find("#previousNextDocument .previous")
|
17
|
+
expect(prev['data-context-href']).to eq "/catalog/2004310986/track?counter=8&search_id=#{search_id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should redirect context urls to the original url" do
|
21
|
+
search_for ''
|
22
|
+
first('.index_title a').click
|
23
|
+
expect(page).to have_content "« Previous | 1 of 30 | Next »"
|
24
|
+
expect(page.current_url).to_not have_content "/track"
|
25
|
+
end
|
26
|
+
|
27
|
+
context "navigating between search results using context pagination" do
|
28
|
+
it "should update the back to search link with the current search pagination context" do
|
29
|
+
search_for ''
|
30
|
+
first('.index_title a').click
|
31
|
+
10.times do
|
32
|
+
click_on "Next »"
|
33
|
+
end
|
34
|
+
|
35
|
+
click_on "Back to Search"
|
36
|
+
expect(page).to have_content "11 - 20"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def search_for q
|
43
|
+
visit root_path
|
44
|
+
fill_in "q", with: q
|
45
|
+
click_button 'search'
|
46
|
+
end
|
@@ -48,28 +48,6 @@ describe "Search Results" do
|
|
48
48
|
search_for 'asdfghj'
|
49
49
|
expect(page).to have_content "No results found for your search"
|
50
50
|
end
|
51
|
-
|
52
|
-
it "should pass the current search id through", :js => true do
|
53
|
-
search_for ''
|
54
|
-
search_id = Search.last.id.to_s
|
55
|
-
click_on 'Pluvial nectar of blessings'
|
56
|
-
expect(page).to have_content "« Previous | 10 of 30 | Next »"
|
57
|
-
prev = page.find("#previousNextDocument .previous")
|
58
|
-
expect(prev['data-context-href']).to eq "/catalog/2003546302/track?counter=9&search_id=#{search_id}"
|
59
|
-
|
60
|
-
click_on "« Previous"
|
61
|
-
|
62
|
-
prev = page.find("#previousNextDocument .previous")
|
63
|
-
expect(prev['data-context-href']).to eq "/catalog/2004310986/track?counter=8&search_id=#{search_id}"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should redirect context urls to the original url", :js => true do
|
67
|
-
search_for ''
|
68
|
-
first('.index_title a').click
|
69
|
-
expect(page).to have_content "« Previous | 1 of 30 | Next »"
|
70
|
-
expect(page.current_url).to_not have_content "/track"
|
71
|
-
end
|
72
|
-
|
73
51
|
end
|
74
52
|
|
75
53
|
|
@@ -513,4 +513,43 @@ describe BlacklightHelper do
|
|
513
513
|
|
514
514
|
end
|
515
515
|
end
|
516
|
+
describe "#type_field_to_partial_name" do
|
517
|
+
let(:document) { double }
|
518
|
+
context "with default value" do
|
519
|
+
subject { helper.type_field_to_partial_name(document, 'default') }
|
520
|
+
it { should eq 'default' }
|
521
|
+
end
|
522
|
+
context "with spaces" do
|
523
|
+
subject { helper.type_field_to_partial_name(document, 'one two three') }
|
524
|
+
it { should eq 'one_two_three' }
|
525
|
+
end
|
526
|
+
context "with hyphens" do
|
527
|
+
subject { helper.type_field_to_partial_name(document, 'one-two-three') }
|
528
|
+
it { should eq 'one_two_three' }
|
529
|
+
end
|
530
|
+
context "an array" do
|
531
|
+
subject { helper.type_field_to_partial_name(document, ['one', 'two', 'three']) }
|
532
|
+
it { should eq 'one_two_three' }
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
536
|
+
describe "#opensearch_description_tag" do
|
537
|
+
subject { helper.opensearch_description_tag 'title', 'href' }
|
538
|
+
|
539
|
+
it "should have a search rel" do
|
540
|
+
expect(subject).to have_selector "link[rel='search']", visible: false
|
541
|
+
end
|
542
|
+
|
543
|
+
it "should have the correct mime type" do
|
544
|
+
expect(subject).to have_selector "link[type='application/opensearchdescription+xml']", visible: false
|
545
|
+
end
|
546
|
+
|
547
|
+
it "should have a title attribute" do
|
548
|
+
expect(subject).to have_selector "link[title='title']", visible: false
|
549
|
+
end
|
550
|
+
|
551
|
+
it "should have an href attribute" do
|
552
|
+
expect(subject).to have_selector "link[href='href']", visible: false
|
553
|
+
end
|
554
|
+
end
|
516
555
|
end
|
@@ -16,6 +16,7 @@ describe BlacklightUrlHelper do
|
|
16
16
|
|
17
17
|
helper.stub(blacklight_config: blacklight_config)
|
18
18
|
helper.stub(current_search_session: nil)
|
19
|
+
helper.stub(:search_session).and_return({})
|
19
20
|
end
|
20
21
|
|
21
22
|
describe "url_for_document" do
|
@@ -27,19 +28,31 @@ describe BlacklightUrlHelper do
|
|
27
28
|
end
|
28
29
|
|
29
30
|
it "should be a polymorphic routing-ready object" do
|
30
|
-
doc =
|
31
|
+
doc = SolrDocument.new
|
31
32
|
expect(helper.url_for_document(doc)).to eq doc
|
32
33
|
end
|
33
34
|
|
34
|
-
it "should
|
35
|
+
it "should allow for custom show routes" do
|
35
36
|
doc = SolrDocument.new
|
37
|
+
helper.blacklight_config.show.route = { controller: 'catalog' }
|
36
38
|
expect(helper.url_for_document(doc)).to eq({controller: 'catalog', action: :show, id: doc})
|
37
39
|
end
|
38
40
|
|
41
|
+
context "within bookmarks" do
|
42
|
+
let(:controller_class) { ::BookmarksController.new }
|
43
|
+
|
44
|
+
it "should use polymorphic routing" do
|
45
|
+
doc = SolrDocument.new
|
46
|
+
expect(helper.url_for_document(doc)).to eq doc
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
39
50
|
context "within an alternative catalog controller" do
|
40
51
|
let(:controller_class) { ::AlternateController.new }
|
41
|
-
|
42
|
-
|
52
|
+
before do
|
53
|
+
helper.blacklight_config.show.route = { controller: :current }
|
54
|
+
end
|
55
|
+
it "should support the :current controller configuration" do
|
43
56
|
doc = SolrDocument.new
|
44
57
|
expect(helper.url_for_document(doc)).to eq({controller: 'alternate', action: :show, id: doc})
|
45
58
|
end
|
@@ -54,16 +67,16 @@ describe BlacklightUrlHelper do
|
|
54
67
|
end
|
55
68
|
|
56
69
|
describe "link_back_to_catalog" do
|
57
|
-
let(:query_params) {{:q => "query", :f => "facets", :
|
58
|
-
let(:bookmarks_query_params) {{ :
|
70
|
+
let(:query_params) {{:q => "query", :f => "facets", :controller=>'catalog'}}
|
71
|
+
let(:bookmarks_query_params) {{ :controller=>'bookmarks'}}
|
59
72
|
|
60
73
|
it "should build a link tag to catalog using session[:search] for query params" do
|
61
74
|
helper.stub(:current_search_session).and_return double(:query_params => query_params)
|
62
75
|
tag = helper.link_back_to_catalog
|
63
76
|
expect(tag).to match /q=query/
|
64
77
|
expect(tag).to match /f=facets/
|
65
|
-
expect(tag).
|
66
|
-
expect(tag).
|
78
|
+
expect(tag).to_not match /page=/
|
79
|
+
expect(tag).to_not match /per_page=/
|
67
80
|
end
|
68
81
|
|
69
82
|
it "should build a link tag to bookmarks using session[:search] for query params" do
|
@@ -71,7 +84,25 @@ describe BlacklightUrlHelper do
|
|
71
84
|
tag = helper.link_back_to_catalog
|
72
85
|
expect(tag).to match /Back to Bookmarks/
|
73
86
|
expect(tag).to match /\/bookmarks/
|
74
|
-
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with a search context" do
|
90
|
+
|
91
|
+
it "should use the current search session counter and per page information to construct the appropriate pagination context" do
|
92
|
+
helper.stub(current_search_session: double(query_params: query_params))
|
93
|
+
helper.stub(search_session: { 'per_page' => 15, 'counter' => 31 })
|
94
|
+
tag = helper.link_back_to_catalog
|
95
|
+
expect(tag).to match /page=3/
|
96
|
+
expect(tag).to match /per_page=15/
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should omit per_page if the value is the same as the default" do
|
100
|
+
helper.stub(current_search_session: double(query_params: query_params))
|
101
|
+
helper.stub(search_session: { 'per_page' => 10, 'counter' => 31 })
|
102
|
+
tag = helper.link_back_to_catalog
|
103
|
+
expect(tag).to match /page=4/
|
104
|
+
expect(tag).to_not match /per_page=/
|
105
|
+
end
|
75
106
|
end
|
76
107
|
|
77
108
|
describe "when an alternate scope is passed in" do
|
@@ -84,8 +115,6 @@ describe BlacklightUrlHelper do
|
|
84
115
|
expect(tag).to match /Back to Search/
|
85
116
|
expect(tag).to match /q=query/
|
86
117
|
expect(tag).to match /f=facets/
|
87
|
-
expect(tag).to match /per_page=10/
|
88
|
-
expect(tag).to match /page=2/
|
89
118
|
end
|
90
119
|
end
|
91
120
|
end
|
@@ -12,6 +12,7 @@ describe "catalog/_index_header_default" do
|
|
12
12
|
it "should render the document header" do
|
13
13
|
assign :response, double(:params => {})
|
14
14
|
view.stub(:current_search_session).and_return nil
|
15
|
+
view.stub(:search_session).and_return({})
|
15
16
|
view.stub(:render_grouped_response?).and_return false
|
16
17
|
view.stub(:blacklight_config).and_return(blacklight_config)
|
17
18
|
view.stub(:render_bookmarks_control?).and_return false
|
@@ -19,4 +20,4 @@ describe "catalog/_index_header_default" do
|
|
19
20
|
expect(rendered).to have_selector('.document-counter', text: "2")
|
20
21
|
end
|
21
22
|
|
22
|
-
end
|
23
|
+
end
|
@@ -3,16 +3,13 @@ require 'spec_helper'
|
|
3
3
|
# spec for sidebar partial in catalog show view
|
4
4
|
|
5
5
|
describe "/catalog/_show_sidebar.html.erb" do
|
6
|
-
|
7
|
-
include BlacklightHelper
|
8
|
-
include CatalogHelper
|
9
|
-
|
10
6
|
|
11
7
|
before(:each) do
|
12
8
|
|
13
9
|
view.stub(:blacklight_config).and_return(CatalogController.blacklight_config)
|
14
10
|
view.stub(:has_user_authentication_provider?).and_return(false)
|
15
11
|
view.stub(:current_search_session).and_return nil
|
12
|
+
view.stub(:search_session).and_return({})
|
16
13
|
end
|
17
14
|
|
18
15
|
it "should show more-like-this titles in the sidebar" do
|
@@ -21,6 +21,7 @@ describe "catalog/_thumbnail_default" do
|
|
21
21
|
view.stub(:render_grouped_response?).and_return false
|
22
22
|
view.stub(:blacklight_config).and_return(blacklight_config)
|
23
23
|
view.stub(:current_search_session).and_return nil
|
24
|
+
view.stub(:search_session).and_return({})
|
24
25
|
end
|
25
26
|
|
26
27
|
it "should render the thumbnail if the document has one" do
|
@@ -33,4 +34,4 @@ describe "catalog/_thumbnail_default" do
|
|
33
34
|
render :partial => "catalog/thumbnail_default", :locals => {:document => document_without_thumbnail_field, :document_counter => 1}
|
34
35
|
expect(rendered).to eq ""
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -17,7 +17,7 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
|
-
date: 2014-03-
|
20
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -348,6 +348,8 @@ files:
|
|
348
348
|
- app/views/record_mailer/sms_record.text.erb
|
349
349
|
- app/views/saved_searches/index.html.erb
|
350
350
|
- app/views/search_history/index.html.erb
|
351
|
+
- app/views/shared/_ajax_modal.html.erb
|
352
|
+
- app/views/shared/_flash_messages.html.erb
|
351
353
|
- app/views/shared/_footer.html.erb
|
352
354
|
- app/views/shared/_header_navbar.html.erb
|
353
355
|
- blacklight.gemspec
|
@@ -428,6 +430,7 @@ files:
|
|
428
430
|
- spec/features/facets_spec.rb
|
429
431
|
- spec/features/record_view_spec.rb
|
430
432
|
- spec/features/saved_searches_spec.rb
|
433
|
+
- spec/features/search_context_spec.rb
|
431
434
|
- spec/features/search_filters_spec.rb
|
432
435
|
- spec/features/search_history_spec.rb
|
433
436
|
- spec/features/search_pagination_spec.rb
|
@@ -535,6 +538,7 @@ test_files:
|
|
535
538
|
- spec/features/facets_spec.rb
|
536
539
|
- spec/features/record_view_spec.rb
|
537
540
|
- spec/features/saved_searches_spec.rb
|
541
|
+
- spec/features/search_context_spec.rb
|
538
542
|
- spec/features/search_filters_spec.rb
|
539
543
|
- spec/features/search_history_spec.rb
|
540
544
|
- spec/features/search_pagination_spec.rb
|