blacklight 5.0.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/Gemfile +9 -9
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.css.scss +2 -1
- data/app/controllers/bookmarks_controller.rb +0 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/catalog_helper_behavior.rb +5 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +60 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +3 -5
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +24 -19
- data/app/views/catalog/_facet_layout.html.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +2 -4
- data/app/views/catalog/_facet_pagination.html.erb +0 -1
- data/app/views/catalog/facet.html.erb +2 -13
- data/blacklight.gemspec +3 -3
- data/gemfiles/rails3.gemfile +19 -5
- data/gemfiles/rails4.gemfile +17 -5
- data/lib/blacklight/catalog.rb +55 -10
- data/lib/blacklight/configuration.rb +6 -1
- data/lib/blacklight/configuration/fields.rb +38 -4
- data/lib/blacklight/controller.rb +10 -1
- data/lib/blacklight/facet.rb +8 -0
- data/lib/blacklight/solr_helper.rb +53 -25
- data/lib/blacklight/solr_response/facets.rb +22 -4
- data/spec/controllers/catalog_controller_spec.rb +59 -2
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +5 -5
- data/spec/helpers/catalog_helper_spec.rb +20 -7
- data/spec/helpers/configuration_helper_spec.rb +42 -0
- data/spec/helpers/facets_helper_spec.rb +5 -12
- data/spec/helpers/render_constraints_helper_spec.rb +4 -1
- data/spec/helpers/url_helper_spec.rb +37 -49
- data/spec/lib/blacklight/configuration_spec.rb +53 -1
- data/spec/lib/blacklight/solr_helper_spec.rb +37 -4
- data/spec/test_app_templates/Gemfile.extra +21 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +5 -0
- data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +14 -0
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +42 -40
- data/spec/views/catalog/facet.html.erb_spec.rb +30 -0
- metadata +23 -33
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +0 -10
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "Alternate Controller Behaviors" do
|
4
4
|
it "should have the correct per-page form" do
|
5
5
|
visit alternate_index_path
|
6
|
-
page.should have_selector("form[action='#{
|
6
|
+
page.should have_selector("form[action='#{alternate_index_url}']")
|
7
7
|
fill_in "q", :with=>"history"
|
8
8
|
click_button 'search'
|
9
9
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -15,7 +15,7 @@ describe "Alternate Controller Behaviors" do
|
|
15
15
|
|
16
16
|
it "should have the correct search field form" do
|
17
17
|
visit alternate_index_path
|
18
|
-
page.should have_selector("form[action='#{
|
18
|
+
page.should have_selector("form[action='#{alternate_index_url}']")
|
19
19
|
fill_in "q", :with=>"history"
|
20
20
|
click_button 'search'
|
21
21
|
expect(current_path).to match /#{alternate_index_path}/
|
@@ -25,7 +25,7 @@ describe "Alternate Controller Behaviors" do
|
|
25
25
|
|
26
26
|
it "should display document thumbnails" do
|
27
27
|
visit alternate_index_path
|
28
|
-
page.should have_selector("form[action='#{
|
28
|
+
page.should have_selector("form[action='#{alternate_index_url}']")
|
29
29
|
fill_in "q", :with=>"history"
|
30
30
|
click_button 'search'
|
31
31
|
expect(page).to have_selector ".document-thumbnail"
|
@@ -35,6 +35,6 @@ describe "Record View" do
|
|
35
35
|
it "should not display 404" do
|
36
36
|
visit catalog_path('this_id_does_not_exist')
|
37
37
|
page.driver.status_code.should == 404
|
38
|
-
expect(page).to have_content "
|
38
|
+
expect(page).to have_content "The page you were looking for doesn't exist."
|
39
39
|
end
|
40
40
|
end
|
@@ -12,7 +12,7 @@ describe BlacklightHelper do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
before(:each) do
|
15
|
-
helper.stub(:
|
15
|
+
helper.stub(:search_action_path) do |*args|
|
16
16
|
catalog_index_url *args
|
17
17
|
end
|
18
18
|
end
|
@@ -155,14 +155,14 @@ describe BlacklightHelper do
|
|
155
155
|
doc = double()
|
156
156
|
doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
157
157
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_true'
|
158
|
-
expect(value).to eq helper.link_to("x", helper.
|
158
|
+
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :link_to_search_true => ['x'] }))
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should check for a link_to_search with a field name" do
|
162
162
|
doc = double()
|
163
163
|
doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
164
164
|
value = helper.render_index_field_value :document => doc, :field => 'link_to_search_named'
|
165
|
-
expect(value).to eq helper.link_to("x", helper.
|
165
|
+
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :some_field => ['x'] }))
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should gracefully handle when no highlight field is available" do
|
@@ -253,14 +253,14 @@ describe BlacklightHelper do
|
|
253
253
|
doc = double()
|
254
254
|
doc.should_receive(:get).with('link_to_search_true', :sep => nil).and_return('x')
|
255
255
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_true'
|
256
|
-
expect(value).to eq helper.link_to("x", helper.
|
256
|
+
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :link_to_search_true => ['x'] }))
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should check for a link_to_search with a field name" do
|
260
260
|
doc = double()
|
261
261
|
doc.should_receive(:get).with('link_to_search_named', :sep => nil).and_return('x')
|
262
262
|
value = helper.render_document_show_field_value :document => doc, :field => 'link_to_search_named'
|
263
|
-
expect(value).to eq helper.link_to("x", helper.
|
263
|
+
expect(value).to eq helper.link_to("x", helper.search_action_path(:f => { :some_field => ['x'] }))
|
264
264
|
end
|
265
265
|
|
266
266
|
it "should gracefully handle when no highlight field is available" do
|
@@ -177,9 +177,9 @@ describe CatalogHelper do
|
|
177
177
|
end
|
178
178
|
|
179
179
|
describe "render_thumbnail_tag" do
|
180
|
+
let(:document) { double }
|
180
181
|
it "should call the provided thumbnail method" do
|
181
182
|
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
182
|
-
document = double()
|
183
183
|
helper.stub(:xyz => "some-thumbnail")
|
184
184
|
|
185
185
|
helper.should_receive(:link_to_document).with(document, :label => "some-thumbnail")
|
@@ -188,8 +188,7 @@ describe CatalogHelper do
|
|
188
188
|
|
189
189
|
it "should create an image tag from the given field" do
|
190
190
|
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
|
191
|
-
|
192
|
-
|
191
|
+
|
193
192
|
document.stub(:has?).with(:xyz).and_return(true)
|
194
193
|
document.stub(:first).with(:xyz).and_return("http://example.com/some.jpg")
|
195
194
|
|
@@ -197,18 +196,32 @@ describe CatalogHelper do
|
|
197
196
|
helper.render_thumbnail_tag document
|
198
197
|
end
|
199
198
|
|
199
|
+
it "should not link to the document if the url options are false" do
|
200
|
+
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
201
|
+
helper.stub(:xyz => "some-thumbnail")
|
202
|
+
|
203
|
+
result = helper.render_thumbnail_tag document, {}, false
|
204
|
+
expect(result).to eq "some-thumbnail"
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should not link to the document if the url options have :suppress_link" do
|
208
|
+
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
209
|
+
helper.stub(:xyz => "some-thumbnail")
|
210
|
+
|
211
|
+
result = helper.render_thumbnail_tag document, {}, suppress_link: true
|
212
|
+
expect(result).to eq "some-thumbnail"
|
213
|
+
end
|
214
|
+
|
215
|
+
|
200
216
|
it "should return nil if no thumbnail is available" do
|
201
217
|
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
|
202
|
-
|
203
|
-
document = double()
|
204
218
|
expect(helper.render_thumbnail_tag document).to be_nil
|
205
219
|
end
|
206
220
|
|
207
221
|
it "should return nil if no thumbnail is returned from the thumbnail method" do
|
208
222
|
helper.stub(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
|
209
223
|
helper.stub(:xyz => nil)
|
210
|
-
|
211
|
-
|
224
|
+
|
212
225
|
expect(helper.render_thumbnail_tag document).to be_nil
|
213
226
|
end
|
214
227
|
end
|
@@ -58,4 +58,46 @@ describe BlacklightConfigurationHelper do
|
|
58
58
|
expect(helper.spell_check_max).to eq config_value
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
describe "#index_field_label" do
|
63
|
+
let(:document) { double }
|
64
|
+
it "should look up the label to display for the given document and field" do
|
65
|
+
helper.stub(:index_fields).and_return({ "my_field" => double(label: "some label") })
|
66
|
+
helper.should_receive(:solr_field_label).with("some label", :"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field")
|
67
|
+
helper.index_field_label document, "my_field"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#document_show_field_label" do
|
72
|
+
let(:document) { double }
|
73
|
+
it "should look up the label to display for the given document and field" do
|
74
|
+
helper.stub(:document_show_fields).and_return({ "my_field" => double(label: "some label") })
|
75
|
+
helper.should_receive(:solr_field_label).with("some label", :"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field")
|
76
|
+
helper.document_show_field_label document, "my_field"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#facet_field_label" do
|
81
|
+
let(:document) { double }
|
82
|
+
it "should look up the label to display for the given document and field" do
|
83
|
+
blacklight_config.stub(:facet_fields).and_return({ "my_field" => double(label: "some label") })
|
84
|
+
helper.should_receive(:solr_field_label).with("some label", :"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field")
|
85
|
+
helper.facet_field_label "my_field"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#solr_field_label" do
|
90
|
+
it "should look up the label as an i18n string" do
|
91
|
+
helper.should_receive(:t).with(:some_key).and_return "my label"
|
92
|
+
label = helper.solr_field_label :some_key
|
93
|
+
|
94
|
+
expect(label).to eq "my label"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should pass the provided i18n keys to I18n.t" do
|
98
|
+
helper.should_receive(:t).with(:key_a, default: [:key_b, "default text"])
|
99
|
+
|
100
|
+
label = helper.solr_field_label "default text", :key_a, :key_b
|
101
|
+
end
|
102
|
+
end
|
61
103
|
end
|
@@ -299,9 +299,13 @@ describe FacetsHelper do
|
|
299
299
|
helper.stub(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :single => false))
|
300
300
|
helper.should_receive(:facet_display_value).and_return('Z')
|
301
301
|
helper.should_receive(:add_facet_params_and_redirect).and_return({controller:'catalog'})
|
302
|
+
|
303
|
+
helper.stub(:search_action_path) do |*args|
|
304
|
+
catalog_index_path *args
|
305
|
+
end
|
302
306
|
end
|
303
307
|
describe "simple case" do
|
304
|
-
let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"
|
308
|
+
let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"/catalog\">Z</a></span><span class=\"facet-count\">10</span>" }
|
305
309
|
it "should use facet_display_value" do
|
306
310
|
result = helper.render_facet_value('simple_field', item)
|
307
311
|
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
@@ -315,17 +319,6 @@ describe FacetsHelper do
|
|
315
319
|
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
316
320
|
end
|
317
321
|
end
|
318
|
-
|
319
|
-
describe "when a route_set is passed" do
|
320
|
-
let(:my_engine) { double("Engine") }
|
321
|
-
let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"/\">Z</a></span><span class=\"facet-count\">10</span>" }
|
322
|
-
|
323
|
-
it "should use the engine scope" do
|
324
|
-
expect(my_engine).to receive(:url_for).and_return({controller: 'catalog'})
|
325
|
-
result = helper.render_facet_value('simple_field', item, route_set: my_engine)
|
326
|
-
expect(result).to be_equivalent_to(expected_html).respecting_element_order
|
327
|
-
end
|
328
|
-
end
|
329
322
|
end
|
330
323
|
|
331
324
|
describe "#facet_display_value" do
|
@@ -5,6 +5,9 @@ describe RenderConstraintsHelper do
|
|
5
5
|
before do
|
6
6
|
# the helper methods below infer paths from the current route
|
7
7
|
controller.request.path_parameters["controller"] = 'catalog'
|
8
|
+
helper.stub(:search_action_path) do |*args|
|
9
|
+
catalog_index_path *args
|
10
|
+
end
|
8
11
|
end
|
9
12
|
|
10
13
|
describe '#render_constraints_query' do
|
@@ -23,7 +26,7 @@ describe RenderConstraintsHelper do
|
|
23
26
|
it "should have a link relative to the current url" do
|
24
27
|
result = helper.render_filter_element('type', ['journal'], {:q=>'biz'})
|
25
28
|
# I'm not certain how the ampersand gets in there. It's not important.
|
26
|
-
expect(result).to
|
29
|
+
expect(result).to have_link "Remove constraint Type: journal", href: "/catalog?&q=biz"
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe BlacklightUrlHelper do
|
4
4
|
|
5
5
|
let(:blacklight_config) do
|
6
6
|
@config ||= Blacklight::Configuration.new.configure do |config|
|
@@ -10,15 +10,12 @@ describe BlacklightHelper do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
before(:each) do
|
13
|
-
helper.stub(:
|
13
|
+
helper.stub(:search_action_path) do |*args|
|
14
14
|
catalog_index_url *args
|
15
15
|
end
|
16
16
|
|
17
|
-
helper.stub(:blacklight_config)
|
18
|
-
|
19
|
-
|
20
|
-
def current_search_session
|
21
|
-
|
17
|
+
helper.stub(blacklight_config: blacklight_config)
|
18
|
+
helper.stub(current_search_session: nil)
|
22
19
|
end
|
23
20
|
|
24
21
|
describe "link_back_to_catalog" do
|
@@ -61,96 +58,96 @@ describe BlacklightHelper do
|
|
61
58
|
describe "link_to_query" do
|
62
59
|
it "should build a link tag to catalog using query string (no other params)" do
|
63
60
|
query = "brilliant"
|
64
|
-
|
65
|
-
tag = link_to_query(query)
|
61
|
+
helper.stub(params: {})
|
62
|
+
tag = helper.link_to_query(query)
|
66
63
|
expect(tag).to match /q=#{query}/
|
67
64
|
expect(tag).to match />#{query}<\/a>/
|
68
65
|
end
|
69
66
|
it "should build a link tag to catalog using query string and other existing params" do
|
70
67
|
query = "wonderful"
|
71
|
-
|
72
|
-
tag = link_to_query(query)
|
68
|
+
helper.stub(params: {:qt => "title_search", :per_page => "50"})
|
69
|
+
tag = helper.link_to_query(query)
|
73
70
|
expect(tag).to match /qt=title_search/
|
74
71
|
expect(tag).to match /per_page=50/
|
75
72
|
end
|
76
73
|
it "should ignore existing :page param" do
|
77
74
|
query = "yes"
|
78
|
-
|
79
|
-
tag = link_to_query(query)
|
75
|
+
helper.stub(params: {:page => "2", :qt => "author_search"})
|
76
|
+
tag = helper.link_to_query(query)
|
80
77
|
expect(tag).to match /qt=author_search/
|
81
78
|
expect(tag).to_not match /page/
|
82
79
|
end
|
83
80
|
it "should be html_safe" do
|
84
81
|
query = "brilliant"
|
85
|
-
|
86
|
-
tag = link_to_query(query)
|
82
|
+
helper.stub(params: {:page => "2", :qt => "author_search"})
|
83
|
+
tag = helper.link_to_query(query)
|
87
84
|
expect(tag).to be_html_safe
|
88
85
|
end
|
89
86
|
end
|
90
87
|
|
91
88
|
describe "sanitize_search_params" do
|
92
89
|
it "should strip nil values" do
|
93
|
-
result = sanitize_search_params(:a => nil, :b => 1)
|
90
|
+
result = helper.sanitize_search_params(:a => nil, :b => 1)
|
94
91
|
expect(result).to_not have_key(:a)
|
95
92
|
expect(result[:b]).to eq 1
|
96
93
|
end
|
97
94
|
|
98
95
|
it "should remove blacklisted keys" do
|
99
|
-
result = sanitize_search_params(:action => true, :controller => true, :id => true, :commit => true, :utf8 => true)
|
96
|
+
result = helper.sanitize_search_params(:action => true, :controller => true, :id => true, :commit => true, :utf8 => true)
|
100
97
|
expect(result).to be_empty
|
101
98
|
end
|
102
99
|
end
|
103
100
|
|
104
101
|
describe "params_for_search" do
|
105
|
-
|
106
|
-
{ 'default' => 'params'}
|
102
|
+
before do
|
103
|
+
helper.stub(params: { 'default' => 'params'})
|
107
104
|
end
|
108
105
|
|
109
106
|
it "should default to using the controller's params" do
|
110
|
-
result = params_for_search
|
111
|
-
expect(result).to eq params
|
107
|
+
result = helper.params_for_search
|
108
|
+
expect(result).to eq({ 'default' => 'params' })
|
112
109
|
expect(params.object_id).to_not eq result.object_id
|
113
110
|
end
|
114
111
|
|
115
112
|
it "should let you pass in params to merge into the controller's params" do
|
116
113
|
source_params = { :q => 'query'}
|
117
|
-
result = params_for_search( source_params )
|
114
|
+
result = helper.params_for_search( source_params )
|
118
115
|
expect(result).to include(:q => 'query', 'default' => 'params')
|
119
116
|
end
|
120
117
|
|
121
118
|
it "should not return blacklisted elements" do
|
122
119
|
source_params = { :action => 'action', :controller => 'controller', :id => "id", :commit => 'commit'}
|
123
|
-
result = params_for_search(source_params)
|
120
|
+
result = helper.params_for_search(source_params)
|
124
121
|
expect(result.keys).to_not include(:action, :controller, :commit, :id)
|
125
122
|
end
|
126
123
|
|
127
124
|
it "should adjust the current page if the per_page changes" do
|
128
125
|
source_params = { :per_page => 20, :page => 5}
|
129
|
-
result = params_for_search(source_params, :per_page => 100)
|
126
|
+
result = helper.params_for_search(source_params, :per_page => 100)
|
130
127
|
expect(result[:page]).to eq 1
|
131
128
|
end
|
132
129
|
|
133
130
|
it "should not adjust the current page if the per_page is the same as it always was" do
|
134
131
|
source_params = { :per_page => 20, :page => 5}
|
135
|
-
result = params_for_search(source_params, :per_page => 20)
|
132
|
+
result = helper.params_for_search(source_params, :per_page => 20)
|
136
133
|
expect(result[:page]).to eq 5
|
137
134
|
end
|
138
135
|
|
139
136
|
it "should adjust the current page if the sort changes" do
|
140
137
|
source_params = { :sort => 'field_a', :page => 5}
|
141
|
-
result = params_for_search(source_params, :sort => 'field_b')
|
138
|
+
result = helper.params_for_search(source_params, :sort => 'field_b')
|
142
139
|
expect(result[:page]).to eq 1
|
143
140
|
end
|
144
141
|
|
145
142
|
it "should not adjust the current page if the sort is the same as it always was" do
|
146
143
|
source_params = { :sort => 'field_a', :page => 5}
|
147
|
-
result = params_for_search(source_params, :sort => 'field_a')
|
144
|
+
result = helper.params_for_search(source_params, :sort => 'field_a')
|
148
145
|
expect(result[:page]).to eq 5
|
149
146
|
end
|
150
147
|
|
151
148
|
describe "params_for_search with a block" do
|
152
149
|
it "should evalute the block and allow it to add or remove keys" do
|
153
|
-
result = params_for_search({:a => 1, :b => 2}, :c => 3) do |params|
|
150
|
+
result = helper.params_for_search({:a => 1, :b => 2}, :c => 3) do |params|
|
154
151
|
params.except! :a, :b
|
155
152
|
params[:d] = 'd'
|
156
153
|
end
|
@@ -183,53 +180,53 @@ describe BlacklightHelper do
|
|
183
180
|
it "should consist of the document title wrapped in a <a>" do
|
184
181
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
185
182
|
@document = SolrDocument.new(data)
|
186
|
-
expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
|
183
|
+
expect(helper.link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
|
187
184
|
end
|
188
185
|
|
189
186
|
it "should accept and return a string label" do
|
190
187
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
191
188
|
@document = SolrDocument.new(data)
|
192
|
-
expect(link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
|
189
|
+
expect(helper.link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
|
193
190
|
end
|
194
191
|
|
195
192
|
it "should accept and return a Proc" do
|
196
193
|
data = {'id'=>'123456','title_display'=>['654321'] }
|
197
194
|
@document = SolrDocument.new(data)
|
198
|
-
expect(link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
|
195
|
+
expect(helper.link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
|
199
196
|
end
|
200
197
|
|
201
198
|
it "should return id when label is missing" do
|
202
199
|
data = {'id'=>'123456'}
|
203
200
|
@document = SolrDocument.new(data)
|
204
|
-
expect(link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
|
201
|
+
expect(helper.link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
|
205
202
|
end
|
206
203
|
|
207
204
|
it "should be html safe" do
|
208
205
|
data = {'id'=>'123456'}
|
209
206
|
@document = SolrDocument.new(data)
|
210
|
-
expect(link_to_document(@document, { :label => :title_display })).to be_html_safe
|
207
|
+
expect(helper.link_to_document(@document, { :label => :title_display })).to be_html_safe
|
211
208
|
end
|
212
209
|
|
213
210
|
it "should convert the counter parameter into a data- attribute" do
|
214
211
|
data = {'id'=>'123456','title_display'=>['654321']}
|
215
212
|
@document = SolrDocument.new(data)
|
216
|
-
expect(link_to_document(@document, { :label => :title_display, :counter => 5 })).to match /data-counter="5"/
|
213
|
+
expect(helper.link_to_document(@document, { :label => :title_display, :counter => 5 })).to match /data-counter="5"/
|
217
214
|
end
|
218
215
|
|
219
216
|
it "passes on the title attribute to the link_to_with_data method" do
|
220
217
|
@document = SolrDocument.new('id'=>'123456')
|
221
|
-
expect(link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
|
218
|
+
expect(helper.link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
|
222
219
|
end
|
223
220
|
|
224
221
|
it "doesn't add an erroneous title attribute if one isn't provided" do
|
225
222
|
@document = SolrDocument.new('id'=>'123456')
|
226
|
-
expect(link_to_document(@document,:label=>"Some crazy long label...")).to_not match(/title=/)
|
223
|
+
expect(helper.link_to_document(@document,:label=>"Some crazy long label...")).to_not match(/title=/)
|
227
224
|
end
|
228
225
|
|
229
226
|
it "should work with integer ids" do
|
230
227
|
data = {'id'=> 123456 }
|
231
228
|
@document = SolrDocument.new(data)
|
232
|
-
expect(link_to_document(@document)).to have_selector("a")
|
229
|
+
expect(helper.link_to_document(@document)).to have_selector("a")
|
233
230
|
end
|
234
231
|
|
235
232
|
end
|
@@ -238,7 +235,7 @@ describe BlacklightHelper do
|
|
238
235
|
it "should link to the given search parameters" do
|
239
236
|
params = {}
|
240
237
|
helper.should_receive(:render_search_to_s).with(params).and_return "link text"
|
241
|
-
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text",
|
238
|
+
expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
|
242
239
|
end
|
243
240
|
end
|
244
241
|
|
@@ -330,17 +327,12 @@ describe BlacklightHelper do
|
|
330
327
|
:per_page => "50",
|
331
328
|
:page => "5",
|
332
329
|
:f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
|
333
|
-
Blacklight::Solr::FacetPaginator.request_keys[:
|
330
|
+
Blacklight::Solr::FacetPaginator.request_keys[:page] => "100",
|
334
331
|
Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
|
335
332
|
:id => 'facet_field_name'
|
336
333
|
}
|
337
334
|
helper.stub(:params).and_return(catalog_facet_params)
|
338
335
|
end
|
339
|
-
it "should redirect to 'index' action" do
|
340
|
-
params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
341
|
-
|
342
|
-
expect(params[:action]).to eq "index"
|
343
|
-
end
|
344
336
|
it "should not include request parameters used by the facet paginator" do
|
345
337
|
params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
346
338
|
|
@@ -351,17 +343,13 @@ describe BlacklightHelper do
|
|
351
343
|
end
|
352
344
|
it 'should remove :page request key' do
|
353
345
|
params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
354
|
-
|
355
346
|
expect(params.keys).to_not include(:page)
|
356
347
|
end
|
357
348
|
it "should otherwise do the same thing as add_facet_params" do
|
358
349
|
added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
|
359
350
|
added_facet_params_from_facet_action = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
|
360
351
|
|
361
|
-
added_facet_params_from_facet_action.
|
362
|
-
next if key == :action
|
363
|
-
expect(value).to eq added_facet_params[key]
|
364
|
-
end
|
352
|
+
expect(added_facet_params_from_facet_action).to eq added_facet_params.except(Blacklight::Solr::FacetPaginator.request_keys[:page], Blacklight::Solr::FacetPaginator.request_keys[:sort])
|
365
353
|
end
|
366
354
|
end
|
367
355
|
end
|