blacklight 4.7.0 → 4.8.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/.gitignore +1 -0
- data/.travis.yml +13 -12
- data/Gemfile +37 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.css.scss → _blacklight_base.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_bookmark.css.scss → _bookmark.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_dropdown.css.scss → _dropdown.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_footer.css.scss → _footer.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_group.css.scss → _group.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_header.css.scss → _header.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_layout.css.scss → _layout.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_mixins.css.scss → _mixins.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_modal.css.scss → _modal.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_print.css.scss → _print.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_responsive.css.scss → _responsive.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_search_history.css.scss → _search_history.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight.css.scss → blacklight.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight_defaults.css.scss → blacklight_defaults.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_header.css.scss → _header.scss} +0 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
- data/blacklight.gemspec +5 -6
- data/lib/blacklight/catalog.rb +1 -1
- data/lib/blacklight/catalog/search_context.rb +6 -6
- data/lib/blacklight/solr/document.rb +29 -21
- data/lib/blacklight/solr_helper.rb +6 -4
- data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
- data/spec/controllers/application_controller_spec.rb +3 -3
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +117 -117
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +7 -5
- data/spec/features/record_view_spec.rb +4 -1
- data/spec/features/search_filters_spec.rb +37 -24
- data/spec/features/search_pagination_spec.rb +11 -7
- data/spec/features/search_results_spec.rb +22 -14
- data/spec/features/search_sort_spec.rb +3 -1
- data/spec/features/search_spec.rb +6 -0
- data/spec/helpers/blacklight_helper_spec.rb +175 -166
- data/spec/helpers/catalog_helper_spec.rb +59 -59
- data/spec/helpers/facets_helper_spec.rb +118 -118
- data/spec/helpers/hash_as_hidden_fields_spec.rb +14 -8
- data/spec/helpers/html_head_helper_spec.rb +51 -45
- data/spec/helpers/render_constraints_helper_spec.rb +5 -6
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_marc_spec.rb +3 -3
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +42 -42
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/lib/blacklight_user_spec.rb +5 -5
- data/spec/lib/facet_paginator_spec.rb +12 -12
- data/spec/lib/marc_export_spec.rb +746 -746
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +255 -250
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/tasks/solr_marc_task_spec.rb +6 -6
- data/spec/lib/utils_spec.rb +11 -11
- data/spec/models/bookmark_spec.rb +7 -6
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +7 -7
- data/spec/requests/alternate_controller_spec.rb +3 -3
- data/spec/routing/catalog_routing_spec.rb +10 -15
- data/spec/spec_helper.rb +6 -4
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +11 -0
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +2 -15
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -6
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -12
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_index_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -6
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +28 -28
- data/spec/views/catalog/index.html.erb_spec.rb +6 -6
- metadata +35 -57
- data/gemfiles/rails3.gemfile +0 -25
- data/gemfiles/rails4.gemfile +0 -24
|
@@ -6,19 +6,25 @@ describe HashAsHiddenFieldsHelper do
|
|
|
6
6
|
before(:each) do
|
|
7
7
|
@hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}}
|
|
8
8
|
end
|
|
9
|
+
around(:each) do |example|
|
|
10
|
+
tmp_value = Capybara.ignore_hidden_elements
|
|
11
|
+
Capybara.ignore_hidden_elements = false
|
|
12
|
+
example.run
|
|
13
|
+
Capybara.ignore_hidden_elements = tmp_value
|
|
14
|
+
end
|
|
9
15
|
|
|
10
16
|
it "should convert a hash with nested complex data to Rails-style hidden form fields" do
|
|
11
17
|
|
|
12
18
|
generated = render_hash_as_hidden_fields(@hash)
|
|
13
19
|
|
|
14
|
-
generated.
|
|
15
|
-
generated.
|
|
16
|
-
generated.
|
|
17
|
-
generated.
|
|
18
|
-
generated.
|
|
19
|
-
generated.
|
|
20
|
-
generated.
|
|
21
|
-
|
|
20
|
+
expect(generated).to have_selector("input[type='hidden'][name='q'][value='query']")
|
|
21
|
+
expect(generated).to have_selector("input[type='hidden'][name='per_page'][value='10']")
|
|
22
|
+
expect(generated).to have_selector("input[type='hidden'][name='page'][value='5']")
|
|
23
|
+
expect(generated).to have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']")
|
|
24
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field2][]'][value='z']")
|
|
25
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='a']")
|
|
26
|
+
expect(generated).to have_selector("input[type='hidden'][name='f[field1][]'][value='b']")
|
|
27
|
+
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
end
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
describe HtmlHeadHelper do
|
|
3
|
+
around(:each) do |example|
|
|
4
|
+
tmp_value = Capybara.ignore_hidden_elements
|
|
5
|
+
Capybara.ignore_hidden_elements = false
|
|
6
|
+
example.run
|
|
7
|
+
Capybara.ignore_hidden_elements = tmp_value
|
|
8
|
+
end
|
|
3
9
|
|
|
4
10
|
describe "render_js_includes" do
|
|
5
|
-
helper do
|
|
11
|
+
helper do
|
|
6
12
|
def javascript_includes
|
|
7
|
-
[
|
|
13
|
+
[
|
|
8
14
|
["some_js.js", {:plugin => :blacklight}],
|
|
9
15
|
["other_js"]
|
|
10
16
|
]
|
|
@@ -16,27 +22,27 @@ describe HtmlHeadHelper do
|
|
|
16
22
|
helper.render_js_includes
|
|
17
23
|
end
|
|
18
24
|
|
|
19
|
-
if Rails::VERSION::MAJOR == 4
|
|
20
|
-
html.
|
|
21
|
-
html.
|
|
25
|
+
if Rails::VERSION::MAJOR == 4
|
|
26
|
+
expect(html).to have_selector("script[src='/javascripts/some_js.js']")
|
|
27
|
+
expect(html).to have_selector("script[src='/javascripts/other_js.js']")
|
|
22
28
|
elsif use_asset_pipeline?
|
|
23
29
|
# only for rails 3 with asset pipeline enabled
|
|
24
|
-
html.
|
|
25
|
-
html.
|
|
30
|
+
expect(html).to have_selector("script[src='/assets/some_js.js'][type='text/javascript']")
|
|
31
|
+
expect(html).to have_selector("script[src='/assets/other_js.js'][type='text/javascript']")
|
|
26
32
|
else
|
|
27
33
|
# rails 3 with asset pipeline disabled
|
|
28
|
-
html.
|
|
29
|
-
html.
|
|
34
|
+
expect(html).to have_selector("script[src='/javascripts/some_js.js'][type='text/javascript']")
|
|
35
|
+
expect(html).to have_selector("script[src='/javascripts/other_js.js'][type='text/javascript']")
|
|
30
36
|
end
|
|
31
37
|
|
|
32
|
-
html.html_safe
|
|
38
|
+
expect(html.html_safe?).to eq(true)
|
|
33
39
|
end
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
describe "render_stylesheet_links" do
|
|
37
|
-
helper do
|
|
43
|
+
helper do
|
|
38
44
|
def stylesheet_links
|
|
39
|
-
[
|
|
45
|
+
[
|
|
40
46
|
["my_stylesheet", {:plugin => :blacklight}],
|
|
41
47
|
["other_stylesheet"]
|
|
42
48
|
]
|
|
@@ -48,23 +54,23 @@ describe HtmlHeadHelper do
|
|
|
48
54
|
helper.render_stylesheet_includes
|
|
49
55
|
end
|
|
50
56
|
|
|
51
|
-
if Rails::VERSION::MAJOR == 4
|
|
52
|
-
html.
|
|
53
|
-
html.
|
|
57
|
+
if Rails::VERSION::MAJOR == 4
|
|
58
|
+
expect(html).to have_selector("link[href='/stylesheets/my_stylesheet.css'][rel='stylesheet']")
|
|
59
|
+
expect(html).to have_selector("link[href='/stylesheets/other_stylesheet.css'][rel='stylesheet']")
|
|
54
60
|
elsif use_asset_pipeline?
|
|
55
|
-
html.
|
|
56
|
-
html.
|
|
61
|
+
expect(html).to have_selector("link[href='/assets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
|
62
|
+
expect(html).to have_selector("link[href='/assets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
|
57
63
|
else
|
|
58
|
-
html.
|
|
59
|
-
html.
|
|
64
|
+
expect(html).to have_selector("link[href='/stylesheets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
|
65
|
+
expect(html).to have_selector("link[href='/stylesheets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
|
|
60
66
|
end
|
|
61
67
|
|
|
62
|
-
html.html_safe
|
|
68
|
+
expect(html.html_safe?).to eq(true)
|
|
63
69
|
end
|
|
64
70
|
end
|
|
65
|
-
|
|
71
|
+
|
|
66
72
|
describe "render_extra_head_content" do
|
|
67
|
-
helper do
|
|
73
|
+
helper do
|
|
68
74
|
def extra_head_content
|
|
69
75
|
['<link rel="a">', '<link rel="b">']
|
|
70
76
|
end
|
|
@@ -76,10 +82,10 @@ describe HtmlHeadHelper do
|
|
|
76
82
|
helper.render_extra_head_content
|
|
77
83
|
end
|
|
78
84
|
|
|
79
|
-
html.
|
|
80
|
-
html.
|
|
85
|
+
expect(html).to have_selector("link[rel=a]")
|
|
86
|
+
expect(html).to have_selector("link[rel=b]")
|
|
81
87
|
|
|
82
|
-
html.html_safe
|
|
88
|
+
expect(html.html_safe?).to eq(true)
|
|
83
89
|
end
|
|
84
90
|
end
|
|
85
91
|
|
|
@@ -87,14 +93,14 @@ describe HtmlHeadHelper do
|
|
|
87
93
|
describe "with no methods defined" do
|
|
88
94
|
it "should return empty string without complaint" do
|
|
89
95
|
Deprecation.silence(Blacklight::HtmlHeadHelperBehavior) do
|
|
90
|
-
|
|
91
|
-
helper.render_head_content.
|
|
92
|
-
helper.render_head_content.html_safe
|
|
96
|
+
expect {helper.render_head_content}.not_to raise_error
|
|
97
|
+
expect(helper.render_head_content).to be_blank
|
|
98
|
+
expect(helper.render_head_content.html_safe?).to eq(true)
|
|
93
99
|
end
|
|
94
100
|
end
|
|
95
101
|
end
|
|
96
102
|
describe "with methods defined" do
|
|
97
|
-
helper do
|
|
103
|
+
helper do
|
|
98
104
|
def javascript_includes
|
|
99
105
|
[["my_js"]]
|
|
100
106
|
end
|
|
@@ -104,47 +110,47 @@ describe HtmlHeadHelper do
|
|
|
104
110
|
def extra_head_content
|
|
105
111
|
[
|
|
106
112
|
"<madeup_tag></madeup_tag>",
|
|
107
|
-
'<link rel="rel" type="type" href="href">'
|
|
113
|
+
'<link rel="rel" type="type" href="href">'
|
|
108
114
|
]
|
|
109
115
|
end
|
|
110
116
|
end
|
|
111
117
|
before(:each) do
|
|
112
|
-
helper.
|
|
118
|
+
expect(helper).to receive(:content_for).with(:head).and_return("<meta keywords=\"foo bar\"/>".html_safe)
|
|
113
119
|
|
|
114
120
|
@output = Deprecation.silence(Blacklight::HtmlHeadHelperBehavior) do
|
|
115
121
|
helper.render_head_content
|
|
116
122
|
end
|
|
117
123
|
end
|
|
118
124
|
it "should include extra_head_content" do
|
|
119
|
-
@output.
|
|
120
|
-
@output.
|
|
125
|
+
expect(@output).to have_selector("madeup_tag")
|
|
126
|
+
expect(@output).to have_selector("link[rel=rel][type=type][href=href]")
|
|
121
127
|
end
|
|
122
128
|
it "should include render_javascript_includes" do
|
|
123
|
-
if Rails::VERSION::MAJOR == 4
|
|
124
|
-
@output.
|
|
129
|
+
if Rails::VERSION::MAJOR == 4
|
|
130
|
+
expect(@output).to have_selector("script[src='/javascripts/my_js.js']")
|
|
125
131
|
else
|
|
126
|
-
@output.
|
|
132
|
+
expect(@output).to have_selector("script[src='/assets/my_js.js'][type='text/javascript']")
|
|
127
133
|
end
|
|
128
134
|
end
|
|
129
135
|
it "should include render_stylesheet_links" do
|
|
130
|
-
if Rails::VERSION::MAJOR == 4
|
|
131
|
-
@output.
|
|
136
|
+
if Rails::VERSION::MAJOR == 4
|
|
137
|
+
expect(@output).to have_selector("link[href='/stylesheets/my_css.css']")
|
|
132
138
|
else
|
|
133
|
-
@output.
|
|
139
|
+
expect(@output).to have_selector("link[href='/assets/my_css.css'][type='text/css']")
|
|
134
140
|
end
|
|
135
141
|
end
|
|
136
142
|
it "should include content_for :head" do
|
|
137
|
-
@output.
|
|
143
|
+
expect(@output).to have_selector("meta[keywords]")
|
|
138
144
|
end
|
|
139
145
|
|
|
140
146
|
it "should include all head content" do
|
|
141
|
-
helper.
|
|
142
|
-
helper.
|
|
143
|
-
helper.
|
|
144
|
-
helper.
|
|
147
|
+
expect(helper).to receive(:render_extra_head_content).and_return("".html_safe)
|
|
148
|
+
expect(helper).to receive(:render_js_includes).and_return("".html_safe)
|
|
149
|
+
expect(helper).to receive(:render_stylesheet_includes).and_return("".html_safe)
|
|
150
|
+
expect(helper).to receive(:content_for).with(:head).and_return("".html_safe)
|
|
145
151
|
|
|
146
152
|
Deprecation.silence(Blacklight::HtmlHeadHelperBehavior) do
|
|
147
|
-
helper.render_head_content.
|
|
153
|
+
expect(helper.render_head_content).to be_html_safe
|
|
148
154
|
end
|
|
149
155
|
end
|
|
150
156
|
end
|
|
@@ -4,12 +4,12 @@ describe RenderConstraintsHelper do
|
|
|
4
4
|
|
|
5
5
|
before do
|
|
6
6
|
# the helper methods below infer paths from the current route
|
|
7
|
-
controller.request.path_parameters[
|
|
7
|
+
controller.request.path_parameters[:controller] = 'catalog'
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
describe '#render_constraints_query' do
|
|
11
11
|
it "should have a link relative to the current url" do
|
|
12
|
-
helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'}).
|
|
12
|
+
expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'})).to have_selector "a[href='/?f%5Btype%5D=journal']"
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -18,13 +18,12 @@ describe RenderConstraintsHelper do
|
|
|
18
18
|
@config = Blacklight::Configuration.new do |config|
|
|
19
19
|
config.add_facet_field 'type'
|
|
20
20
|
end
|
|
21
|
-
helper.
|
|
21
|
+
allow(helper).to receive_messages(:blacklight_config => @config)
|
|
22
22
|
end
|
|
23
23
|
it "should have a link relative to the current url" do
|
|
24
24
|
result = helper.render_filter_element('type', ['journal'], {:q=>'biz'})
|
|
25
|
-
result.size.
|
|
26
|
-
|
|
27
|
-
result.first.should have_selector "a[href='/?&q=biz']"
|
|
25
|
+
expect(result.size).to eq(1)
|
|
26
|
+
expect(result.first).to have_link "Remove constraint Type: journal", href: "/?q=biz"
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|
|
@@ -13,41 +13,41 @@ describe SearchHistoryConstraintsHelper do
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
before(:each) do
|
|
16
|
-
helper.
|
|
16
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
describe "render_search_to_s_*" do
|
|
20
20
|
describe "render_search_to_s_element" do
|
|
21
21
|
it "should render basic element" do
|
|
22
22
|
response = helper.render_search_to_s_element("key", "value")
|
|
23
|
-
response.
|
|
24
|
-
span.
|
|
25
|
-
span.
|
|
23
|
+
expect(response).to have_selector("span.constraint") do |span|
|
|
24
|
+
expect(span).to have_selector("span.filterName", :content => "key:")
|
|
25
|
+
expect(span).to have_selector("span.filterValue", :content => "value")
|
|
26
26
|
end
|
|
27
|
-
response.html_safe
|
|
27
|
+
expect(response.html_safe?).to eq(true)
|
|
28
28
|
end
|
|
29
29
|
it "should escape them that need escaping" do
|
|
30
30
|
response = helper.render_search_to_s_element("key>", "value>")
|
|
31
|
-
response.
|
|
32
|
-
span.
|
|
31
|
+
expect(response).to have_selector("span.constraint") do |span|
|
|
32
|
+
expect(span).to have_selector("span.filterName") do |s2|
|
|
33
33
|
# Note: nokogiri's gettext will unescape the inner html
|
|
34
34
|
# which seems to be what rspecs "contains" method calls on
|
|
35
35
|
# text nodes - thus the to_s inserted below.
|
|
36
|
-
s2.to_s.
|
|
36
|
+
expect(s2.to_s).to match(/key>:/)
|
|
37
37
|
end
|
|
38
|
-
span.
|
|
39
|
-
s3.to_s.
|
|
38
|
+
expect(span).to have_selector("span.filterValue") do |s3|
|
|
39
|
+
expect(s3.to_s).to match(/value>/)
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
|
-
response.html_safe
|
|
42
|
+
expect(response.html_safe?).to eq(true)
|
|
43
43
|
end
|
|
44
44
|
it "should not escape with options set thus" do
|
|
45
45
|
response = helper.render_search_to_s_element("key>", "value>", :escape_key => false, :escape_value => false)
|
|
46
|
-
response.
|
|
47
|
-
span.
|
|
48
|
-
span.
|
|
46
|
+
expect(response).to have_selector("span.constraint") do |span|
|
|
47
|
+
expect(span).to have_selector("span.filterName", :content => "key>:")
|
|
48
|
+
expect(span).to have_selector("span.filterValue", :content => "value>")
|
|
49
49
|
end
|
|
50
|
-
response.html_safe
|
|
50
|
+
expect(response.html_safe?).to eq(true)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -56,15 +56,15 @@ describe SearchHistoryConstraintsHelper do
|
|
|
56
56
|
@params = {:q => "history", :f => {"some_facet" => ["value1", "value1"], "other_facet" => ["other1"]}}
|
|
57
57
|
end
|
|
58
58
|
it "should call lesser methods" do
|
|
59
|
-
helper.
|
|
60
|
-
helper.
|
|
61
|
-
helper.
|
|
59
|
+
allow(helper).to receive(:blacklight_config).and_return(@config)
|
|
60
|
+
allow(helper).to receive(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(:key => 'default_search_field', :display_label => 'Default'))
|
|
61
|
+
allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
|
|
62
62
|
# API hooks expect this to be so
|
|
63
63
|
response = helper.render_search_to_s(@params)
|
|
64
64
|
|
|
65
|
-
response.
|
|
66
|
-
response.
|
|
67
|
-
response.html_safe
|
|
65
|
+
expect(response).to include( helper.render_search_to_s_q(@params))
|
|
66
|
+
expect(response).to include( helper.render_search_to_s_filters(@params))
|
|
67
|
+
expect(response.html_safe?).to eq(true)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -12,9 +12,9 @@ describe Blacklight::SolrResponse::GroupResponse do
|
|
|
12
12
|
|
|
13
13
|
describe "groups" do
|
|
14
14
|
it "should return an array of Groups" do
|
|
15
|
-
response.grouped.
|
|
15
|
+
expect(response.grouped).to be_a Array
|
|
16
16
|
|
|
17
|
-
expect(group.groups).to
|
|
17
|
+
expect(group.groups.size).to eq(2)
|
|
18
18
|
group.groups.each do |group|
|
|
19
19
|
expect(group).to be_a Blacklight::SolrResponse::Group
|
|
20
20
|
end
|
|
@@ -20,17 +20,17 @@ describe "Blacklight::Configurable" do
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
it "should inherit the configuration when subclassed" do
|
|
23
|
-
TestCaseInheritence::Child.blacklight_config.list.
|
|
23
|
+
expect(TestCaseInheritence::Child.blacklight_config.list).to include(1,2,3)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "inherited version should be a deep copy, not original" do
|
|
27
|
-
TestCaseInheritence::Child.blacklight_config.
|
|
27
|
+
expect(TestCaseInheritence::Child.blacklight_config).not_to be(TestCaseInheritence::Parent.blacklight_config)
|
|
28
28
|
|
|
29
29
|
TestCaseInheritence::Child.blacklight_config.list << "child_only"
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
TestCaseInheritence::Child.blacklight_config.list.
|
|
33
|
-
TestCaseInheritence::Parent.blacklight_config.list.
|
|
32
|
+
expect(TestCaseInheritence::Child.blacklight_config.list).to include("child_only")
|
|
33
|
+
expect(TestCaseInheritence::Parent.blacklight_config.list).not_to include("child_only")
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -47,7 +47,7 @@ describe "Blacklight::Configurable" do
|
|
|
47
47
|
a = Class.new
|
|
48
48
|
a.send(:include, Blacklight::Configurable)
|
|
49
49
|
|
|
50
|
-
a.blacklight_config.default_solr_params.
|
|
50
|
+
expect(a.blacklight_config.default_solr_params).to be_empty
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should allow the user to provide a default configuration" do
|
|
@@ -56,7 +56,7 @@ describe "Blacklight::Configurable" do
|
|
|
56
56
|
Blacklight::Configurable.default_configuration = Blacklight::Configuration.new :a => 1
|
|
57
57
|
|
|
58
58
|
a.send(:include, Blacklight::Configurable)
|
|
59
|
-
a.blacklight_config.a.
|
|
59
|
+
expect(a.blacklight_config.a).to eq(1)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "has configure_blacklight convenience method" do
|
|
@@ -67,7 +67,7 @@ describe "Blacklight::Configurable" do
|
|
|
67
67
|
config.my_key = 'value'
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
klass.blacklight_config.my_key.
|
|
70
|
+
expect(klass.blacklight_config.my_key).to eq('value')
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it "allows the instance to set a radically different config from the class" do
|
|
@@ -78,8 +78,8 @@ describe "Blacklight::Configurable" do
|
|
|
78
78
|
instance = klass.new
|
|
79
79
|
instance.blacklight_config = Blacklight::Configuration.new
|
|
80
80
|
|
|
81
|
-
instance.blacklight_config.
|
|
82
|
-
instance.blacklight_config.foo.
|
|
81
|
+
expect(instance.blacklight_config).not_to eq(klass.blacklight_config)
|
|
82
|
+
expect(instance.blacklight_config.foo).to be_nil
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "allows instance to set it's own config seperate from class" do
|
|
@@ -94,11 +94,11 @@ describe "Blacklight::Configurable" do
|
|
|
94
94
|
|
|
95
95
|
instance = klass.new
|
|
96
96
|
instance.blacklight_config.bar << "123"
|
|
97
|
-
instance.blacklight_config.
|
|
98
|
-
klass.blacklight_config.foo.
|
|
99
|
-
instance.blacklight_config.foo.
|
|
100
|
-
klass.blacklight_config.bar.
|
|
101
|
-
instance.blacklight_config.bar.
|
|
97
|
+
expect(instance.blacklight_config).not_to eq(klass.blacklight_config)
|
|
98
|
+
expect(klass.blacklight_config.foo).to eq("bar")
|
|
99
|
+
expect(instance.blacklight_config.foo).to eq("bar")
|
|
100
|
+
expect(klass.blacklight_config.bar).not_to include("123")
|
|
101
|
+
expect(instance.blacklight_config.bar).to include("asd", "123")
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "configurable classes should not mutate the default configuration object" do
|
|
@@ -110,8 +110,8 @@ describe "Blacklight::Configurable" do
|
|
|
110
110
|
klass2.send(:include, Blacklight::Configurable)
|
|
111
111
|
klass2.blacklight_config.foo = "asdf"
|
|
112
112
|
|
|
113
|
-
klass.blacklight_config.foo.
|
|
114
|
-
klass2.blacklight_config.foo.
|
|
113
|
+
expect(klass.blacklight_config.foo).to eq("bar")
|
|
114
|
+
expect(klass2.blacklight_config.foo).to eq("asdf")
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
4
4
|
|
|
5
5
|
describe "Blacklight::Configuration" do
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
before(:each) do
|
|
8
8
|
@config = Blacklight::Configuration.new
|
|
9
9
|
end
|
|
@@ -11,60 +11,60 @@ describe "Blacklight::Configuration" do
|
|
|
11
11
|
it "should support arbitrary configuration values" do
|
|
12
12
|
@config.a = 1
|
|
13
13
|
|
|
14
|
-
@config.a.
|
|
15
|
-
@config[:a].
|
|
14
|
+
expect(@config.a).to eq(1)
|
|
15
|
+
expect(@config[:a]).to eq(1)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe "initialization" do
|
|
19
19
|
it "should be an OpenStructWithHashAccess" do
|
|
20
|
-
@config.
|
|
20
|
+
expect(@config).to be_a_kind_of Blacklight::OpenStructWithHashAccess
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should accept a block for configuration" do
|
|
24
24
|
config = Blacklight::Configuration.new(:a => 1) { |c| c.a = 2 }
|
|
25
25
|
|
|
26
|
-
config.a.
|
|
26
|
+
expect(config.a).to eq(2)
|
|
27
27
|
|
|
28
28
|
config.configure { |c| c.a = 3 }
|
|
29
29
|
|
|
30
|
-
config.a.
|
|
30
|
+
expect(config.a).to eq(3)
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe "defaults" do
|
|
35
35
|
it "should have a hash of default rsolr query parameters" do
|
|
36
|
-
@config.default_solr_params.
|
|
36
|
+
expect(@config.default_solr_params).to be_a_kind_of Hash
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should have openstruct values for show and index parameters" do
|
|
40
|
-
@config.show.
|
|
41
|
-
@config.index.
|
|
40
|
+
expect(@config.show).to be_a_kind_of OpenStruct
|
|
41
|
+
expect(@config.index).to be_a_kind_of OpenStruct
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "should introspect SolrDocument for sensible defaults for show + index" do
|
|
45
|
-
@config.show.html_title.
|
|
46
|
-
@config.show.heading.
|
|
47
|
-
@config.index.show_link.
|
|
45
|
+
expect(@config.show.html_title).to eq('id')
|
|
46
|
+
expect(@config.show.heading).to eq('id')
|
|
47
|
+
expect(@config.index.show_link).to eq('id')
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should have ordered hashes for field configuration" do
|
|
51
|
-
@config.facet_fields.
|
|
52
|
-
@config.index_fields.
|
|
53
|
-
@config.show_fields.
|
|
54
|
-
@config.search_fields.
|
|
55
|
-
@config.show_fields.
|
|
56
|
-
@config.search_fields.
|
|
57
|
-
@config.sort_fields.
|
|
51
|
+
expect(@config.facet_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
52
|
+
expect(@config.index_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
53
|
+
expect(@config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
54
|
+
expect(@config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
55
|
+
expect(@config.show_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
56
|
+
expect(@config.search_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
57
|
+
expect(@config.sort_fields).to be_a_kind_of ActiveSupport::OrderedHash
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
describe "spell_max" do
|
|
62
62
|
it "should default to 5" do
|
|
63
|
-
Blacklight::Configuration.new.spell_max.
|
|
63
|
+
expect(Blacklight::Configuration.new.spell_max).to eq(5)
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
it "should accept config'd value" do
|
|
67
|
-
Blacklight::Configuration.new(:spell_max => 10).spell_max.
|
|
67
|
+
expect(Blacklight::Configuration.new(:spell_max => 10).spell_max).to eq(10)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -76,8 +76,8 @@ describe "Blacklight::Configuration" do
|
|
|
76
76
|
@mock_facet = Blacklight::Configuration::FacetField.new
|
|
77
77
|
config_copy.add_facet_field "dummy_field", @mock_facet
|
|
78
78
|
|
|
79
|
-
@config.a.
|
|
80
|
-
@config.facet_fields.
|
|
79
|
+
expect(@config.a).to be_nil
|
|
80
|
+
expect(@config.facet_fields).not_to include(@mock_facet)
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -89,9 +89,9 @@ describe "Blacklight::Configuration" do
|
|
|
89
89
|
config.add_my_custom_field 'qwerty', :label => "asdf"
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
|
|
93
92
|
|
|
94
|
-
|
|
93
|
+
|
|
94
|
+
expect(config.my_custom_fields.keys).to include('qwerty')
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
it "should let you define a field accessor that uses an existing field-type" do
|
|
@@ -102,37 +102,37 @@ describe "Blacklight::Configuration" do
|
|
|
102
102
|
config.add_my_custom_facet_field 'qwerty', :label => "asdf"
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
|
|
107
|
+
expect(config.my_custom_facet_fields['qwerty']).to be_a_kind_of(Blacklight::Configuration::FacetField)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
end
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
describe "add_facet_field" do
|
|
113
113
|
it "should accept field name and hash form arg" do
|
|
114
114
|
@config.add_facet_field('format', :label => "Format", :limit => true)
|
|
115
|
-
|
|
116
|
-
@config.facet_fields["format"].
|
|
117
|
-
@config.facet_fields["format"]["label"].
|
|
118
|
-
@config.facet_fields["format"]["limit"].
|
|
115
|
+
|
|
116
|
+
expect(@config.facet_fields["format"]).not_to be_nil
|
|
117
|
+
expect(@config.facet_fields["format"]["label"]).to eq("Format")
|
|
118
|
+
expect(@config.facet_fields["format"]["limit"]).to eq(true)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
it "should accept FacetField obj arg" do
|
|
122
122
|
@config.add_facet_field("format", Blacklight::Configuration::FacetField.new( :label => "Format"))
|
|
123
|
-
|
|
124
|
-
@config.facet_fields["format"].
|
|
125
|
-
@config.facet_fields["format"]["label"].
|
|
123
|
+
|
|
124
|
+
expect(@config.facet_fields["format"]).not_to be_nil
|
|
125
|
+
expect(@config.facet_fields["format"]["label"]).to eq("Format")
|
|
126
126
|
end
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
it "should accept field name and block form" do
|
|
129
|
-
@config.add_facet_field("format") do |facet|
|
|
129
|
+
@config.add_facet_field("format") do |facet|
|
|
130
130
|
facet.label = "Format"
|
|
131
131
|
facet.limit = true
|
|
132
132
|
end
|
|
133
|
-
|
|
134
|
-
@config.facet_fields["format"].
|
|
135
|
-
@config.facet_fields["format"].limit.
|
|
133
|
+
|
|
134
|
+
expect(@config.facet_fields["format"]).not_to be_nil
|
|
135
|
+
expect(@config.facet_fields["format"].limit).to eq(true)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "should accept block form" do
|
|
@@ -141,208 +141,208 @@ describe "Blacklight::Configuration" do
|
|
|
141
141
|
facet.label = "Format"
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
@config.facet_fields['format'].
|
|
144
|
+
expect(@config.facet_fields['format']).not_to be_nil
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "should accept a configuration hash" do
|
|
148
148
|
@config.add_facet_field :field => 'format', :label => 'Format'
|
|
149
|
-
@config.facet_fields['format'].
|
|
149
|
+
expect(@config.facet_fields['format']).not_to be_nil
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
it "should accept array form" do
|
|
153
153
|
@config.add_facet_field([{ :field => 'format', :label => 'Format'}, { :field => 'publication_date', :label => 'Publication Date' }])
|
|
154
154
|
|
|
155
|
-
@config.facet_fields.length.
|
|
155
|
+
expect(@config.facet_fields.length).to eq(2)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
it "should create default label from titleized solr field" do
|
|
159
159
|
@config.add_facet_field("publication_date")
|
|
160
|
-
|
|
161
|
-
@config.facet_fields["publication_date"].label.
|
|
160
|
+
|
|
161
|
+
expect(@config.facet_fields["publication_date"].label).to eq("Publication Date")
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
it "should allow you to not show the facet in the facet bar" do
|
|
165
165
|
@config.add_facet_field("publication_date", :show=>false)
|
|
166
|
-
|
|
167
|
-
@config.facet_fields["publication_date"]['show'].
|
|
166
|
+
|
|
167
|
+
expect(@config.facet_fields["publication_date"]['show']).to eq false
|
|
168
168
|
end
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
it "should raise on nil solr field name" do
|
|
171
|
-
|
|
171
|
+
expect { @config.add_facet_field(nil) }.to raise_error ArgumentError
|
|
172
172
|
end
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
end
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
describe "add_index_field" do
|
|
177
177
|
it "takes hash form" do
|
|
178
178
|
@config.add_index_field("title_display", :label => "Title")
|
|
179
|
-
|
|
180
|
-
@config.index_fields["title_display"].
|
|
181
|
-
@config.index_fields["title_display"].label.
|
|
179
|
+
|
|
180
|
+
expect(@config.index_fields["title_display"]).not_to be_nil
|
|
181
|
+
expect(@config.index_fields["title_display"].label).to eq("Title")
|
|
182
182
|
end
|
|
183
183
|
it "takes IndexField param" do
|
|
184
184
|
@config.add_index_field("title_display", Blacklight::Configuration::IndexField.new(:field => "title_display", :label => "Title"))
|
|
185
|
-
|
|
186
|
-
@config.index_fields["title_display"].
|
|
187
|
-
@config.index_fields["title_display"].label.
|
|
185
|
+
|
|
186
|
+
expect(@config.index_fields["title_display"]).not_to be_nil
|
|
187
|
+
expect(@config.index_fields["title_display"].label).to eq("Title")
|
|
188
188
|
end
|
|
189
189
|
it "takes block form" do
|
|
190
|
-
@config.add_index_field("title_display") do |field|
|
|
190
|
+
@config.add_index_field("title_display") do |field|
|
|
191
191
|
field.label = "Title"
|
|
192
192
|
end
|
|
193
|
-
@config.index_fields["title_display"].
|
|
194
|
-
@config.index_fields["title_display"].label.
|
|
193
|
+
expect(@config.index_fields["title_display"]).not_to be_nil
|
|
194
|
+
expect(@config.index_fields["title_display"].label).to eq("Title")
|
|
195
195
|
end
|
|
196
|
-
|
|
196
|
+
|
|
197
197
|
it "creates default label from titleized field" do
|
|
198
198
|
@config.add_index_field("title_display")
|
|
199
|
-
|
|
200
|
-
@config.index_fields["title_display"].label.
|
|
199
|
+
|
|
200
|
+
expect(@config.index_fields["title_display"].label).to eq("Title Display")
|
|
201
201
|
end
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
it "should raise on nil solr field name" do
|
|
204
|
-
|
|
204
|
+
expect { @config.add_index_field(nil) }.to raise_error ArgumentError
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
end
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
describe "add_show_field" do
|
|
210
210
|
it "takes hash form" do
|
|
211
211
|
@config.add_show_field("title_display", :label => "Title")
|
|
212
|
-
|
|
213
|
-
@config.show_fields["title_display"].
|
|
214
|
-
@config.show_fields["title_display"].label.
|
|
212
|
+
|
|
213
|
+
expect(@config.show_fields["title_display"]).not_to be_nil
|
|
214
|
+
expect(@config.show_fields["title_display"].label).to eq("Title")
|
|
215
215
|
end
|
|
216
216
|
it "takes ShowField argument" do
|
|
217
217
|
@config.add_show_field("title_display", Blacklight::Configuration::ShowField.new(:field => "title_display", :label => "Title"))
|
|
218
|
-
|
|
219
|
-
@config.show_fields["title_display"].
|
|
220
|
-
@config.show_fields["title_display"].label.
|
|
218
|
+
|
|
219
|
+
expect(@config.show_fields["title_display"]).not_to be_nil
|
|
220
|
+
expect(@config.show_fields["title_display"].label).to eq("Title")
|
|
221
221
|
end
|
|
222
222
|
it "takes block form" do
|
|
223
|
-
@config.add_show_field("title_display") do |f|
|
|
223
|
+
@config.add_show_field("title_display") do |f|
|
|
224
224
|
f.label = "Title"
|
|
225
225
|
end
|
|
226
|
-
|
|
227
|
-
@config.show_fields["title_display"].
|
|
228
|
-
@config.show_fields["title_display"].label.
|
|
226
|
+
|
|
227
|
+
expect(@config.show_fields["title_display"]).not_to be_nil
|
|
228
|
+
expect(@config.show_fields["title_display"].label).to eq("Title")
|
|
229
229
|
end
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
it "creates default label humanized from field" do
|
|
232
232
|
@config.add_show_field("my_custom_field")
|
|
233
|
-
|
|
234
|
-
@config.show_fields["my_custom_field"].label.
|
|
233
|
+
|
|
234
|
+
expect(@config.show_fields["my_custom_field"].label).to eq("My Custom Field")
|
|
235
235
|
end
|
|
236
|
-
|
|
236
|
+
|
|
237
237
|
it "should raise on nil solr field name" do
|
|
238
|
-
|
|
238
|
+
expect { @config.add_show_field(nil) }.to raise_error ArgumentError
|
|
239
239
|
end
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
end
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
|
|
243
|
+
|
|
244
244
|
describe "add_search_field" do
|
|
245
245
|
it "should accept hash form" do
|
|
246
246
|
c = Blacklight::Configuration.new
|
|
247
247
|
c.add_search_field(:key => "my_search_key")
|
|
248
|
-
c.search_fields["my_search_key"].
|
|
248
|
+
expect(c.search_fields["my_search_key"]).not_to be_nil
|
|
249
249
|
end
|
|
250
250
|
|
|
251
251
|
it "should accept two-arg hash form" do
|
|
252
252
|
c = Blacklight::Configuration.new
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
c.add_search_field("my_search_type",
|
|
255
255
|
:key => "my_search_type",
|
|
256
|
-
:solr_parameters => { :qf => "my_field_qf^10" },
|
|
256
|
+
:solr_parameters => { :qf => "my_field_qf^10" },
|
|
257
257
|
:solr_local_parameters => { :pf=>"$my_field_pf"})
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
field = c.search_fields["my_search_type"]
|
|
260
|
-
|
|
261
|
-
field.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
field.solr_parameters.
|
|
265
|
-
field.solr_local_parameters.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
end
|
|
269
|
-
|
|
260
|
+
|
|
261
|
+
expect(field).not_to be_nil
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
expect(field.solr_parameters).not_to be_nil
|
|
265
|
+
expect(field.solr_local_parameters).not_to be_nil
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
270
|
it "should accept block form" do
|
|
271
271
|
c = Blacklight::Configuration.new
|
|
272
|
-
|
|
273
|
-
c.add_search_field("some_field") do |field|
|
|
272
|
+
|
|
273
|
+
c.add_search_field("some_field") do |field|
|
|
274
274
|
field.solr_parameters = {:qf => "solr_field^10"}
|
|
275
275
|
field.solr_local_parameters = {:pf => "$some_field_pf"}
|
|
276
276
|
end
|
|
277
|
-
|
|
277
|
+
|
|
278
278
|
f = c.search_fields["some_field"]
|
|
279
|
-
|
|
280
|
-
f.
|
|
281
|
-
f.solr_parameters.
|
|
282
|
-
f.solr_local_parameters.
|
|
279
|
+
|
|
280
|
+
expect(f).not_to be_nil
|
|
281
|
+
expect(f.solr_parameters).not_to be_nil
|
|
282
|
+
expect(f.solr_local_parameters).not_to be_nil
|
|
283
283
|
end
|
|
284
|
-
|
|
284
|
+
|
|
285
285
|
it "should accept SearchField object" do
|
|
286
286
|
c = Blacklight::Configuration.new
|
|
287
|
-
|
|
287
|
+
|
|
288
288
|
f = Blacklight::Configuration::SearchField.new( :foo => "bar")
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
c.add_search_field("foo", f)
|
|
291
|
-
|
|
292
|
-
c.search_fields["foo"].
|
|
291
|
+
|
|
292
|
+
expect(c.search_fields["foo"]).not_to be_nil
|
|
293
293
|
end
|
|
294
|
-
|
|
294
|
+
|
|
295
295
|
it "should raise on nil key" do
|
|
296
|
-
|
|
296
|
+
expect {@config.add_search_field(nil, :foo => "bar")}.to raise_error ArgumentError
|
|
297
297
|
end
|
|
298
|
-
|
|
298
|
+
|
|
299
299
|
it "creates default label from titleized field key" do
|
|
300
300
|
@config.add_search_field("author_name")
|
|
301
|
-
|
|
302
|
-
@config.search_fields["author_name"].label.
|
|
301
|
+
|
|
302
|
+
expect(@config.search_fields["author_name"].label).to eq("Author Name")
|
|
303
303
|
end
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
|
|
305
|
+
|
|
306
306
|
end
|
|
307
|
-
|
|
307
|
+
|
|
308
308
|
describe "add_sort_field" do
|
|
309
309
|
it "should take a hash" do
|
|
310
310
|
c = Blacklight::Configuration.new
|
|
311
311
|
c.add_sort_field(:key => "my_sort_key", :sort => "score desc")
|
|
312
|
-
c.sort_fields["my_sort_key"].
|
|
312
|
+
expect(c.sort_fields["my_sort_key"]).not_to be_nil
|
|
313
313
|
end
|
|
314
314
|
|
|
315
315
|
it "should take a two-arg form with a hash" do
|
|
316
|
-
@config.add_sort_field("score desc, pub_date_sort desc, title_sort asc", :label => "relevance")
|
|
316
|
+
@config.add_sort_field("score desc, pub_date_sort desc, title_sort asc", :label => "relevance")
|
|
317
|
+
|
|
317
318
|
|
|
318
|
-
|
|
319
|
-
@config.sort_fields.values.find{|f| f.label == "relevance"}.should_not be_nil
|
|
319
|
+
expect(@config.sort_fields.values.find{|f| f.label == "relevance"}).not_to be_nil
|
|
320
320
|
end
|
|
321
|
-
|
|
321
|
+
|
|
322
322
|
it "should take a SortField object" do
|
|
323
323
|
@config.add_sort_field(Blacklight::Configuration::SortField.new(:label => "relevance", :sort => "score desc, pub_date_sort desc, title_sort asc"
|
|
324
|
-
))
|
|
325
|
-
@config.sort_fields.values.find{|f| f.label == "relevance"}.
|
|
324
|
+
))
|
|
325
|
+
expect(@config.sort_fields.values.find{|f| f.label == "relevance"}).not_to be_nil
|
|
326
326
|
end
|
|
327
|
-
|
|
327
|
+
|
|
328
328
|
it "should take block form" do
|
|
329
329
|
@config.add_sort_field do |field|
|
|
330
330
|
field.label = "relevance"
|
|
331
331
|
field.sort = "score desc, pub_date_sort desc, title_sort asc"
|
|
332
332
|
end
|
|
333
|
-
|
|
334
|
-
@config.sort_fields.values.find{|f| f.label == "relevance"}.
|
|
333
|
+
|
|
334
|
+
expect(@config.sort_fields.values.find{|f| f.label == "relevance"}).not_to be_nil
|
|
335
335
|
|
|
336
336
|
end
|
|
337
337
|
end
|
|
338
|
-
|
|
338
|
+
|
|
339
339
|
describe "#default_search_field" do
|
|
340
340
|
it "should use the field with a :default key" do
|
|
341
341
|
@config.add_search_field('search_field_1')
|
|
342
342
|
@config.add_search_field('search_field_2', :default => true)
|
|
343
343
|
|
|
344
|
-
@config.default_search_field.key.
|
|
344
|
+
expect(@config.default_search_field.key).to eq('search_field_2')
|
|
345
345
|
end
|
|
346
346
|
end
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
end
|