blacklight 6.0.0.pre2 → 6.0.0.pre3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d61d1d33a708476cbac51eba384b3ec074e06e0
4
- data.tar.gz: 9d359464738928145735fb316c3a1dbb8b37fe19
3
+ metadata.gz: 0ff860357fb3d2118c70ca7e8f1c4dc36bc496f4
4
+ data.tar.gz: 645e95ebad1081be628cd2c1f24f302b711fc2b1
5
5
  SHA512:
6
- metadata.gz: 4409c43abb35028561d936081809525f8038f34ac8706a8838281e12396df98e4508a141224ea5db103b2a7b6f3f6206c9a5370c89ff987473426ae3ffda90d1
7
- data.tar.gz: 6598923fcb1214614d65716faceb7b9da4fb2a540ab2ae91e22389df0fab211978b8e2e6cd11ffd9786afae93f0b3c6a68ae195640388ef00daf8ca80fbebeea
6
+ metadata.gz: c48d40732144a83f9708e0b12a1f6b29a603e667df94e2f7c79aeef0e86a58444241d2a63c32cd68e3835cad52716d7bf53f0a22a115416c0bb716153b1a4a3c
7
+ data.tar.gz: 0fb793e45aa4bb028cecc280a37f3c8a602b9d54d6fc70ebf52376edb16653bfe1492ec7f11703e4ee141efd9d4445e13dab39d2ec79220089a83cb2dac740f8
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ log/*
11
11
  tmp/*
12
12
  pkg/*
13
13
  .internal_test_app
14
+ .vagrant
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.0.pre2
1
+ 6.0.0.pre3
data/Vagrantfile ADDED
@@ -0,0 +1,79 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+ Vagrant.configure(2) do |config|
9
+
10
+ # The most common configuration options are documented and commented below.
11
+ # For a complete reference, please see the online documentation at
12
+ # https://docs.vagrantup.com.
13
+
14
+ # Every Vagrant development environment requires a box. You can search for
15
+ # boxes at https://atlas.hashicorp.com/search.
16
+ config.vm.box = "bento/centos-7.1"
17
+ config.vm.hostname = "blacklight"
18
+ config.vm.synced_folder ".", "/home/vagrant/sync", type: 'virtualbox'
19
+
20
+
21
+ # Disable automatic box update checking. If you disable this, then
22
+ # boxes will only be checked for updates when the user runs
23
+ # `vagrant box outdated`. This is not recommended.
24
+ # config.vm.box_check_update = false
25
+
26
+ # Create a forwarded port mapping which allows access to a specific port
27
+ # within the machine from a port on the host machine. In the example below,
28
+ # accessing "localhost:8080" will access port 80 on the guest machine.
29
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
30
+ config.vm.network "forwarded_port", guest: 8983, host: 8983, auto_correct: true
31
+ config.vm.network "forwarded_port", guest: 3000, host: 3000, auto_correct: true
32
+
33
+ # Create a private network, which allows host-only access to the machine
34
+ # using a specific IP.
35
+ # config.vm.network "private_network", ip: "192.168.33.10"
36
+
37
+ # Create a public network, which generally matched to bridged network.
38
+ # Bridged networks make the machine appear as another physical device on
39
+ # your network.
40
+ # config.vm.network "public_network"
41
+
42
+ # Share an additional folder to the guest VM. The first argument is
43
+ # the path on the host to the actual folder. The second argument is
44
+ # the path on the guest to mount the folder. And the optional third
45
+ # argument is a set of non-required options.
46
+ # config.vm.synced_folder "../data", "/vagrant_data"
47
+
48
+ # Provider-specific configuration so you can fine-tune various
49
+ # backing providers for Vagrant. These expose provider-specific options.
50
+ # Example for VirtualBox:
51
+ #
52
+ # config.vm.provider "virtualbox" do |vb|
53
+ # # Display the VirtualBox GUI when booting the machine
54
+ # vb.gui = true
55
+ #
56
+ # # Customize the amount of memory on the VM:
57
+ # vb.memory = "1024"
58
+ # end
59
+ #
60
+ # View the documentation for the provider you are using for more
61
+ # information on available options.
62
+
63
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
64
+ # such as FTP and Heroku are also available. See the documentation at
65
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
66
+ # config.push.define "atlas" do |push|
67
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
68
+ # end
69
+
70
+ # Enable provisioning with a shell script. Additional provisioners such as
71
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
72
+ # documentation for more information about their specific syntax and use.
73
+ # config.vm.provision "shell", inline: <<-SHELL
74
+ # sudo apt-get update
75
+ # sudo apt-get install -y apache2
76
+ # SHELL
77
+
78
+ config.vm.provision "shell", path: "provision.sh"
79
+ end
@@ -56,12 +56,12 @@ module Blacklight::Catalog
56
56
  search_session['id'] = params[:search_id]
57
57
  search_session['per_page'] = params[:per_page]
58
58
 
59
- path = if params[:redirect] and (params[:redirect].starts_with?("/") or params[:redirect] =~ URI::regexp)
60
- URI.parse(params[:redirect]).path
59
+ if params[:redirect] and (params[:redirect].starts_with?('/') or params[:redirect] =~ URI::regexp)
60
+ path = URI.parse(params[:redirect]).path
61
+ redirect_to path, status: 303
61
62
  else
62
- { action: 'show' }
63
+ redirect_to blacklight_config.document_model.new(id: params[:id]), status: 303
63
64
  end
64
- redirect_to path, :status => 303
65
65
  end
66
66
 
67
67
  # displays values and pagination links for a single facet field
@@ -0,0 +1,58 @@
1
+ module Blacklight
2
+ module DeprecatedUrlHelperBehavior
3
+ extend Deprecation
4
+ self.deprecation_horizon = 'blacklight 7.x'
5
+
6
+ def params_for_search(*args, &block)
7
+ source_params, params_to_merge = case args.length
8
+ when 0
9
+ search_state.params_for_search
10
+ when 1
11
+ search_state.params_for_search(args.first)
12
+ when 2
13
+ Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).params_for_search instead')
14
+ Blacklight::SearchState.new(args.first, blacklight_config).params_for_search(args.last)
15
+ else
16
+ raise ArgumentError.new "wrong number of arguments (#{args.length} for 0..2)"
17
+ end
18
+ end
19
+ deprecation_deprecate :params_for_search
20
+
21
+ def sanitize_search_params(source_params)
22
+ Blacklight::Parameters.sanitize(source_params)
23
+ end
24
+ deprecation_deprecate :sanitize_search_params
25
+
26
+ def reset_search_params(source_params)
27
+ Blacklight::SearchState.new(source_params, blacklight_config).send(:reset_search_params)
28
+ end
29
+ deprecation_deprecate :reset_search_params
30
+
31
+ def add_facet_params(field, item, source_params = nil)
32
+ if source_params
33
+ Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).add_facet_params instead')
34
+
35
+ Blacklight::SearchState.new(source_params, blacklight_config).add_facet_params(field, item)
36
+ else
37
+ search_state.add_facet_params(field, item)
38
+ end
39
+ end
40
+ deprecation_deprecate :add_facet_params
41
+
42
+ def remove_facet_params(field, item, source_params = nil)
43
+ if source_params
44
+ Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).remove_facet_params instead')
45
+
46
+ Blacklight::SearchState.new(source_params, blacklight_config).remove_facet_params(field, item)
47
+ else
48
+ search_state.remove_facet_params(field, item)
49
+ end
50
+ end
51
+ deprecation_deprecate :remove_facet_params
52
+
53
+ def add_facet_params_and_redirect(field, item)
54
+ search_state.add_facet_params_and_redirect(field, item)
55
+ end
56
+ deprecation_deprecate :add_facet_params_and_redirect
57
+ end
58
+ end
@@ -1,6 +1,8 @@
1
1
  ##
2
2
  # URL helper methods
3
3
  module Blacklight::UrlHelperBehavior
4
+ include Blacklight::DeprecatedUrlHelperBehavior
5
+
4
6
  ##
5
7
  # Extension point for downstream applications
6
8
  # to provide more interesting routing to
@@ -61,26 +63,32 @@ module Blacklight::UrlHelperBehavior
61
63
  # session_tracking_params(SolrDocument.new(id: 123), 7)
62
64
  # => { data: { :'tracker-href' => '/catalog/123/track?counter=7&search_id=999' } }
63
65
  def session_tracking_params document, counter
64
- if document.nil?
66
+ path = session_tracking_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))
67
+
68
+ if path.nil?
65
69
  return {}
66
70
  end
67
-
68
- { :data => {:'context-href' => session_tracking_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
71
+
72
+ { data: {:'context-href' => path } }
69
73
  end
70
74
  protected :session_tracking_params
71
-
75
+
72
76
  ##
73
77
  # Get the URL for tracking search sessions across pages using polymorphic routing
74
78
  def session_tracking_path document, params = {}
75
- controller_tracking_method = "track_#{controller_name}_path"
79
+ return if document.nil?
76
80
 
77
- if respond_to? controller_tracking_method
81
+ if respond_to?(controller_tracking_method)
78
82
  send(controller_tracking_method, params.merge(id: document.id))
79
83
  else
80
- polymorphic_path(document, params)
84
+ blacklight.track_search_context_path(params.merge(id: document.id))
81
85
  end
82
86
  end
83
87
 
88
+ def controller_tracking_method
89
+ "track_#{controller_name}_path"
90
+ end
91
+
84
92
  #
85
93
  # link based helpers ->
86
94
  #
@@ -146,7 +154,7 @@ module Blacklight::UrlHelperBehavior
146
154
  # @param [Blacklight::SolrResponse::Group]
147
155
  # @return [Hash]
148
156
  def add_group_facet_params_and_redirect group
149
- search_state.add_facet_params_and_redirect(group.field, group.key, params)
157
+ search_state.add_facet_params_and_redirect(group.field, group.key)
150
158
  end
151
159
 
152
160
  # A URL to refworks export, with an embedded callback URL to this app.
@@ -106,7 +106,7 @@ module Blacklight
106
106
  options[:last_word_connector] ||= field_config.separator
107
107
  end
108
108
 
109
- values.to_sentence(options)
109
+ values.map { |x| html_escape(x) }.to_sentence(options).html_safe
110
110
  end
111
111
 
112
112
  ##
@@ -220,11 +220,15 @@ module Blacklight
220
220
  end
221
221
 
222
222
  Array(value).map do |v|
223
- @controller.link_to render_field_value(v, field_config), @controller.search_action_path(@controller.add_facet_params(link_field, v, {}))
223
+ @controller.link_to render_field_value(v, field_config), @controller.search_action_path(@controller.search_state.reset.add_facet_params(link_field, v))
224
224
  end if field
225
225
  else
226
226
  value
227
227
  end
228
228
  end
229
+
230
+ def html_escape(*args)
231
+ ERB::Util.html_escape(*args)
232
+ end
229
233
  end
230
234
  end
data/config/routes.rb CHANGED
@@ -6,5 +6,7 @@ Blacklight::Engine.routes.draw do
6
6
  put "saved_searches/save/:id", :to => "saved_searches#save", :as => "save_search"
7
7
  delete "saved_searches/forget/:id", :to => "saved_searches#forget", :as => "forget_search"
8
8
  post "saved_searches/forget/:id", :to => "saved_searches#forget"
9
+ post "/catalog/:id/track", to: 'catalog#track', as: 'track_search_context'
10
+
9
11
  resources :suggest, only: :index, defaults: { format: 'json' }
10
12
  end
@@ -11,6 +11,10 @@ module Blacklight
11
11
  @blacklight_config = blacklight_config
12
12
  end
13
13
 
14
+ def reset
15
+ Blacklight::SearchState.new({}, blacklight_config)
16
+ end
17
+
14
18
  def url_for_document(doc, options = {})
15
19
  if respond_to?(:blacklight_config) and
16
20
  blacklight_config.show.route and
@@ -27,31 +31,14 @@ module Blacklight
27
31
  # Does NOT remove request keys and otherwise ensure that the hash
28
32
  # is suitable for a redirect. See
29
33
  # add_facet_params_and_redirect
30
- def add_facet_params(field, item, source_params=params)
31
-
32
- if item.respond_to? :field
33
- field = item.field
34
- end
34
+ def add_facet_params(field, item)
35
+ p = reset_search_params
35
36
 
36
- facet_config = facet_configuration_for_field(field)
37
-
38
- url_field = facet_config.key
39
-
40
- value = facet_value_for_facet_item(item)
41
-
42
- p = reset_search_params(source_params)
43
- p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
44
- p[:f][url_field] = (p[:f][url_field] || []).dup
45
-
46
- if facet_config.single and not p[:f][url_field].empty?
47
- p[:f][url_field] = []
48
- end
49
-
50
- p[:f][url_field].push(value)
37
+ add_facet_param(p, field, item)
51
38
 
52
39
  if item and item.respond_to?(:fq) and item.fq
53
- Array(item.fq).each do |f,v|
54
- p = add_facet_params(f, v, p)
40
+ Array(item.fq).each do |f, v|
41
+ add_facet_param(p, f, v)
55
42
  end
56
43
  end
57
44
 
@@ -91,7 +78,7 @@ module Blacklight
91
78
 
92
79
  value = facet_value_for_facet_item(item)
93
80
 
94
- p = reset_search_params(params)
81
+ p = reset_search_params
95
82
  # need to dup the facet values too,
96
83
  # if the values aren't dup'd, then the values
97
84
  # from the session will get remove in the show view...
@@ -124,20 +111,41 @@ module Blacklight
124
111
 
125
112
  private
126
113
 
127
- ##
128
- # Reset any search parameters that store search context
129
- # and need to be reset when e.g. constraints change
130
- def reset_search_params source_params
131
- Parameters.sanitize(source_params).except(:page, :counter).with_indifferent_access
114
+ ##
115
+ # Reset any search parameters that store search context
116
+ # and need to be reset when e.g. constraints change
117
+ def reset_search_params
118
+ Parameters.sanitize(params).except(:page, :counter).with_indifferent_access
119
+ end
120
+
121
+ # TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
122
+ def facet_value_for_facet_item item
123
+ if item.respond_to? :value
124
+ item.value
125
+ else
126
+ item
127
+ end
128
+ end
129
+
130
+ def add_facet_param(p, field, item)
131
+ if item.respond_to? :field
132
+ field = item.field
132
133
  end
133
134
 
134
- # TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
135
- def facet_value_for_facet_item item
136
- if item.respond_to? :value
137
- item.value
138
- else
139
- item
140
- end
135
+ facet_config = facet_configuration_for_field(field)
136
+
137
+ url_field = facet_config.key
138
+
139
+ value = facet_value_for_facet_item(item)
140
+
141
+ p[:f] = (p[:f] || {}).dup # the command above is not deep in rails3, !@#$!@#$
142
+ p[:f][url_field] = (p[:f][url_field] || []).dup
143
+
144
+ if facet_config.single and not p[:f][url_field].empty?
145
+ p[:f][url_field] = []
141
146
  end
147
+
148
+ p[:f][url_field].push(value)
149
+ end
142
150
  end
143
151
  end
data/provision.sh ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+ sudo yum install -y epel-release
3
+ sudo yum install -y curl git java-1.7.0-openjdk-devel nodejs yum-utils gcc bzip2 kernel-devel dkms
4
+
5
+ su - vagrant -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3'
6
+ su - vagrant -c 'curl -sSL https://get.rvm.io | bash -s stable'
7
+ su - vagrant -c 'rvm 2.2.3 --install --default'
8
+ su - vagrant -c 'gem install bundler'
9
+ su - vagrant -c 'cd /home/vagrant/sync && bundle install'
10
+ su - vagrant -c 'cd /home/vagrant/sync && rake engine_cart:generate'
11
+
12
+ echo "
13
+ Now to start Solr and Blacklight run the following from within the Blacklight directory:
14
+
15
+ vagrant ssh
16
+ cd /home/vagrant/sync
17
+ rake blacklight:server[\"-b 0.0.0.0\"]
18
+
19
+ Now you can make changes to Blacklight and see the results.
20
+ "
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blacklight::DeprecatedUrlHelperBehavior do
4
+ around do |test|
5
+ Deprecation.silence(described_class) do
6
+ test.call
7
+ end
8
+ end
9
+
10
+ let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
11
+ let(:params) { {} }
12
+ let(:blacklight_config) { Blacklight::Configuration.new }
13
+
14
+ before do
15
+ allow(helper).to receive(:search_state).and_return(search_state)
16
+ allow(helper).to receive(:params).and_return(params)
17
+ allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
18
+ end
19
+
20
+ describe '#params_for_search' do
21
+ it 'passes through to the search state' do
22
+ expect(helper.params_for_search).to eq search_state.params_for_search
23
+ end
24
+
25
+ it 'passes arguments through to the search state' do
26
+ expect(helper.params_for_search(merge: 1)).to eq search_state.params_for_search(merge: 1)
27
+ end
28
+
29
+ it 'generates a search state for the source parameters' do
30
+ expect(helper.params_for_search({ source: 1 }, { merge: 1 })).to include merge: 1, source: 1
31
+ end
32
+ end
33
+
34
+ describe '#sanitize_search_params' do
35
+ it 'passes through to the parameter sanitizer' do
36
+ expect(helper.sanitize_search_params(a: 1)).to eq Blacklight::Parameters.sanitize(a: 1)
37
+ end
38
+ end
39
+
40
+ describe '#reset_search_params' do
41
+ it 'resets the current page and counter' do
42
+ expect(helper.reset_search_params(page: 1, counter: 10)).to be_blank
43
+ end
44
+ end
45
+
46
+ describe '#add_facet_params' do
47
+ before do
48
+ blacklight_config.add_facet_field 'x'
49
+ end
50
+
51
+ let(:field) { blacklight_config.facet_fields['x'] }
52
+ let(:item) { true }
53
+
54
+ it 'passes through to the search state' do
55
+ expect(helper.add_facet_params(field, item)).to eq search_state.add_facet_params(field, item)
56
+ end
57
+
58
+ it 'generates a search state for the source parameters' do
59
+ expect(helper.add_facet_params(field, item, source: 1)).to include source: 1
60
+ end
61
+ end
62
+
63
+ describe '#add_facet_params_and_redirect' do
64
+ before do
65
+ blacklight_config.add_facet_field 'x'
66
+ end
67
+
68
+ let(:field) { blacklight_config.facet_fields['x'] }
69
+ let(:item) { true }
70
+
71
+ it 'passes through to the search state' do
72
+ expect(helper.add_facet_params_and_redirect(field, item)).to eq search_state.add_facet_params_and_redirect(field, item)
73
+ end
74
+ end
75
+
76
+ describe '#remove_facet_params' do
77
+ before do
78
+ blacklight_config.add_facet_field 'x'
79
+ end
80
+
81
+ let(:field) { blacklight_config.facet_fields['x'] }
82
+ let(:item) { true }
83
+
84
+ it 'passes through to the search state' do
85
+ expect(helper.remove_facet_params(field, item)).to eq search_state.remove_facet_params(field, item)
86
+ end
87
+
88
+ it 'generates a search state for the source parameters' do
89
+ expect(helper.remove_facet_params(field, item, source: 1)).to include source: 1
90
+ end
91
+ end
92
+ end
@@ -222,12 +222,29 @@ describe BlacklightUrlHelper do
222
222
  expect(helper.link_to_document(@document, :title_display, counter: 5)).to include 'data-context-href="tracking url"'
223
223
  end
224
224
 
225
- it "should merge the data- attributes from the options with the counter params" do
225
+ it "includes the data- attributes from the options" do
226
226
  data = {'id'=>'123456','title_display'=>['654321']}
227
227
  @document = SolrDocument.new(data)
228
228
  link = helper.link_to_document @document, { data: { x: 1 } }
229
229
  expect(link).to have_selector '[data-x]'
230
- expect(link).to have_selector '[data-context-href]'
230
+ end
231
+
232
+ it 'adds a controller-specific tracking attribute' do
233
+ data = { 'id'=>'123456', 'title_display'=>['654321'] }
234
+ @document = SolrDocument.new(data)
235
+
236
+ expect(helper).to receive(:track_test_path).and_return('/asdf')
237
+ link = helper.link_to_document @document, { data: { x: 1 } }
238
+
239
+ expect(link).to have_selector '[data-context-href="/asdf"]'
240
+ end
241
+
242
+ it 'adds a global tracking attribute' do
243
+ data = { 'id'=>'123456', 'title_display'=>['654321'] }
244
+ @document = SolrDocument.new(data)
245
+
246
+ link = helper.link_to_document @document, { data: { x: 1 } }
247
+ expect(link).to have_selector '[data-context-href="/catalog/123456/track"]'
231
248
  end
232
249
 
233
250
  it "passes on the title attribute to the link_to_with_data method" do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Blacklight::DocumentPresenter do
4
4
  include Capybara::RSpecMatchers
5
- let(:request_context) { double(:add_facet_params => '') }
5
+ let(:request_context) { double }
6
6
  let(:config) { Blacklight::Configuration.new }
7
7
 
8
8
  subject { presenter }
@@ -16,6 +16,10 @@ describe Blacklight::DocumentPresenter do
16
16
  'mnbv' => 'document mnbv value')
17
17
  end
18
18
 
19
+ before do
20
+ allow(request_context).to receive(:search_state).and_return(Blacklight::SearchState.new({}, config))
21
+ end
22
+
19
23
  describe "link_rel_alternates" do
20
24
  before do
21
25
  class MockDocument
@@ -116,7 +120,6 @@ describe Blacklight::DocumentPresenter do
116
120
  end
117
121
 
118
122
  it "should check for a link_to_search" do
119
- allow(request_context).to receive(:add_facet_params).and_return(:f => { :link_to_search_true => ['x'] })
120
123
  allow(request_context).to receive(:search_action_path).with(:f => { :link_to_search_true => ['x'] }).and_return('/foo')
121
124
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
122
125
  value = subject.render_index_field_value 'link_to_search_true'
@@ -124,7 +127,6 @@ describe Blacklight::DocumentPresenter do
124
127
  end
125
128
 
126
129
  it "should check for a link_to_search with a field name" do
127
- allow(request_context).to receive(:add_facet_params).and_return(:f => { :some_field => ['x'] })
128
130
  allow(request_context).to receive(:search_action_path).with(:f => { :some_field => ['x'] }).and_return('/foo')
129
131
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
130
132
  value = subject.render_index_field_value 'link_to_search_named'
@@ -198,6 +200,21 @@ describe Blacklight::DocumentPresenter do
198
200
  end
199
201
  end
200
202
 
203
+ it 'html-escapes values' do
204
+ value = subject.render_document_show_field_value 'asdf', value: '<b>val1</b>'
205
+ expect(value).to eq '&lt;b&gt;val1&lt;/b&gt;'
206
+ end
207
+
208
+ it 'joins multivalued valued fields' do
209
+ value = subject.render_document_show_field_value 'asdf', value: ['<a', 'b']
210
+ expect(value).to eq '&lt;a and b'
211
+ end
212
+
213
+ it 'joins multivalued valued fields' do
214
+ value = subject.render_document_show_field_value 'asdf', value: ['a', 'b', 'c']
215
+ expect(value).to eq 'a, b, and c'
216
+ end
217
+
201
218
  it "should check for an explicit value" do
202
219
  expect(request_context).to_not receive(:render_asdf_document_show_field)
203
220
  value = subject.render_document_show_field_value 'asdf', :value => 'val1'
@@ -211,14 +228,14 @@ describe Blacklight::DocumentPresenter do
211
228
  end
212
229
 
213
230
  it "should check for a link_to_search" do
214
- allow(request_context).to receive(:search_action_path).with('').and_return('/foo')
231
+ allow(request_context).to receive(:search_action_path).and_return('/foo')
215
232
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
216
233
  value = subject.render_document_show_field_value 'link_to_search_true'
217
234
  expect(value).to eq 'bar'
218
235
  end
219
236
 
220
237
  it "should check for a link_to_search with a field name" do
221
- allow(request_context).to receive(:search_action_path).with('').and_return('/foo')
238
+ allow(request_context).to receive(:search_action_path).and_return('/foo')
222
239
  allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
223
240
  value = subject.render_document_show_field_value 'link_to_search_named'
224
241
  expect(value).to eq 'bar'
@@ -237,6 +254,12 @@ describe Blacklight::DocumentPresenter do
237
254
  expect(value).to eq '<em>highlight</em>'
238
255
  end
239
256
 
257
+ it 'respects the HTML-safeness of multivalued highlight fields' do
258
+ allow(document).to receive(:has_highlight_field?).and_return(true)
259
+ allow(document).to receive(:highlight_field).with('highlight').and_return(['<em>highlight</em>'.html_safe, '<em>other highlight</em>'.html_safe])
260
+ value = subject.render_document_show_field_value 'highlight'
261
+ expect(value).to eq '<em>highlight</em> and <em>other highlight</em>'
262
+ end
240
263
 
241
264
  it "should check the document field value" do
242
265
  value = subject.render_document_show_field_value 'qwer'
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: 6.0.0.pre2
4
+ version: 6.0.0.pre3
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: 2015-11-06 00:00:00.000000000 Z
20
+ date: 2015-11-08 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -272,6 +272,7 @@ files:
272
272
  - README.md
273
273
  - Rakefile
274
274
  - VERSION
275
+ - Vagrantfile
275
276
  - app/assets/images/blacklight/logo.png
276
277
  - app/assets/images/favicon.ico
277
278
  - app/assets/javascripts/blacklight/ajax_modal.js
@@ -321,6 +322,7 @@ files:
321
322
  - app/helpers/blacklight/catalog_helper_behavior.rb
322
323
  - app/helpers/blacklight/component_helper_behavior.rb
323
324
  - app/helpers/blacklight/configuration_helper_behavior.rb
325
+ - app/helpers/blacklight/deprecated_url_helper_behavior.rb
324
326
  - app/helpers/blacklight/facets_helper_behavior.rb
325
327
  - app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb
326
328
  - app/helpers/blacklight/layout_helper_behavior.rb
@@ -520,6 +522,7 @@ files:
520
522
  - lib/generators/blacklight/test_support_generator.rb
521
523
  - lib/generators/blacklight/user_generator.rb
522
524
  - lib/railties/blacklight.rake
525
+ - provision.sh
523
526
  - solr/conf/_rest_managed.json
524
527
  - solr/conf/admin-extra.html
525
528
  - solr/conf/elevate.xml
@@ -568,6 +571,7 @@ files:
568
571
  - spec/helpers/blacklight_helper_spec.rb
569
572
  - spec/helpers/catalog_helper_spec.rb
570
573
  - spec/helpers/configuration_helper_spec.rb
574
+ - spec/helpers/deprecated_url_helper_behavior_spec.rb
571
575
  - spec/helpers/facets_helper_spec.rb
572
576
  - spec/helpers/hash_as_hidden_fields_spec.rb
573
577
  - spec/helpers/layout_helper_spec.rb
@@ -697,6 +701,7 @@ test_files:
697
701
  - spec/helpers/blacklight_helper_spec.rb
698
702
  - spec/helpers/catalog_helper_spec.rb
699
703
  - spec/helpers/configuration_helper_spec.rb
704
+ - spec/helpers/deprecated_url_helper_behavior_spec.rb
700
705
  - spec/helpers/facets_helper_spec.rb
701
706
  - spec/helpers/hash_as_hidden_fields_spec.rb
702
707
  - spec/helpers/layout_helper_spec.rb