blacklight 7.5.1 → 7.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/app/Dockerfile +26 -0
  3. data/.docker/app/entrypoint.sh +6 -0
  4. data/.env +5 -0
  5. data/.gitignore +0 -1
  6. data/.rubocop_todo.yml +25 -36
  7. data/.travis.yml +15 -23
  8. data/Gemfile +4 -1
  9. data/README.md +4 -0
  10. data/VERSION +1 -1
  11. data/app/assets/stylesheets/blacklight/_facets.scss +20 -4
  12. data/app/assets/stylesheets/blacklight/_pagination.scss +4 -0
  13. data/app/components/blacklight/constraint_layout_component.html.erb +23 -0
  14. data/app/components/blacklight/constraint_layout_component.rb +16 -0
  15. data/app/components/blacklight/facet_field_component.html.erb +25 -0
  16. data/app/components/blacklight/facet_field_component.rb +11 -0
  17. data/app/components/blacklight/facet_field_list_component.html.erb +18 -0
  18. data/app/components/blacklight/facet_field_list_component.rb +22 -0
  19. data/app/components/blacklight/facet_field_no_layout_component.rb +13 -0
  20. data/app/components/blacklight/facet_item_component.rb +120 -0
  21. data/app/components/blacklight/facet_item_pivot_component.rb +84 -0
  22. data/app/helpers/blacklight/blacklight_helper_behavior.rb +4 -2
  23. data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -4
  24. data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -2
  25. data/app/helpers/blacklight/facets_helper_behavior.rb +92 -49
  26. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +64 -33
  27. data/app/javascript/blacklight/modal.js +1 -1
  28. data/app/models/blacklight/icon.rb +13 -11
  29. data/app/models/concerns/blacklight/document.rb +0 -10
  30. data/app/models/concerns/blacklight/document/extensions.rb +3 -0
  31. data/app/models/concerns/blacklight/document/semantic_fields.rb +0 -4
  32. data/app/presenters/blacklight/document_presenter.rb +27 -36
  33. data/app/presenters/blacklight/facet_field_presenter.rb +57 -0
  34. data/app/presenters/blacklight/facet_item_presenter.rb +81 -0
  35. data/app/presenters/blacklight/field_presenter.rb +31 -6
  36. data/app/presenters/blacklight/index_presenter.rb +2 -2
  37. data/app/presenters/blacklight/show_presenter.rb +3 -3
  38. data/app/views/catalog/_citation.html.erb +1 -1
  39. data/app/views/catalog/_constraints.html.erb +3 -3
  40. data/app/views/catalog/_constraints_element.html.erb +5 -24
  41. data/app/views/catalog/_email_form.html.erb +1 -1
  42. data/app/views/catalog/_facet_layout.html.erb +8 -17
  43. data/app/views/catalog/_facet_limit.html.erb +3 -12
  44. data/app/views/catalog/_facet_pagination.html.erb +2 -2
  45. data/app/views/catalog/_facet_pivot.html.erb +3 -18
  46. data/app/views/catalog/_field.json.jbuilder +2 -2
  47. data/app/views/catalog/_index.html.erb +3 -3
  48. data/app/views/catalog/_previous_next_doc.html.erb +5 -5
  49. data/app/views/catalog/_search_form.html.erb +1 -1
  50. data/app/views/catalog/_show.html.erb +3 -3
  51. data/app/views/catalog/_sms_form.html.erb +1 -1
  52. data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
  53. data/app/views/catalog/_start_over.html.erb +1 -0
  54. data/app/views/catalog/_thumbnail.html.erb +1 -1
  55. data/app/views/catalog/index.json.jbuilder +2 -1
  56. data/app/views/catalog/show.html.erb +1 -1
  57. data/app/views/catalog/show.json.jbuilder +2 -1
  58. data/app/views/layouts/blacklight/base.html.erb +2 -2
  59. data/blacklight.gemspec +1 -0
  60. data/config/locales/blacklight.ar.yml +33 -24
  61. data/config/locales/blacklight.de.yml +5 -0
  62. data/config/locales/blacklight.en.yml +5 -0
  63. data/config/locales/blacklight.es.yml +5 -0
  64. data/config/locales/blacklight.fr.yml +5 -0
  65. data/config/locales/blacklight.hu.yml +5 -0
  66. data/config/locales/blacklight.it.yml +5 -0
  67. data/config/locales/blacklight.nl.yml +5 -0
  68. data/config/locales/blacklight.pt-BR.yml +5 -0
  69. data/config/locales/blacklight.sq.yml +5 -0
  70. data/config/locales/blacklight.zh.yml +5 -0
  71. data/docker-compose.yml +35 -0
  72. data/lib/blacklight/configuration.rb +35 -8
  73. data/lib/blacklight/configuration/field.rb +5 -4
  74. data/lib/blacklight/engine.rb +2 -6
  75. data/lib/blacklight/search_state.rb +52 -0
  76. data/lib/blacklight/solr/response/facets.rb +2 -0
  77. data/lib/generators/blacklight/assets_generator.rb +10 -0
  78. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
  79. data/package-lock.json +4 -4
  80. data/package.json +2 -2
  81. data/spec/{views/catalog/_constraints_element.html.erb_spec.rb → components/blacklight/constraint_layout_component_spec.rb} +22 -12
  82. data/spec/components/blacklight/facet_field_list_component_spec.rb +108 -0
  83. data/spec/components/blacklight/facet_item_component_spec.rb +50 -0
  84. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +66 -0
  85. data/spec/features/facets_spec.rb +21 -1
  86. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
  87. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +24 -12
  88. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +4 -23
  89. data/spec/helpers/blacklight_helper_spec.rb +17 -0
  90. data/spec/helpers/catalog_helper_spec.rb +0 -7
  91. data/spec/lib/blacklight/search_state_spec.rb +50 -0
  92. data/spec/models/blacklight/configuration_spec.rb +4 -0
  93. data/spec/models/blacklight/icon_spec.rb +11 -10
  94. data/spec/models/blacklight/solr/response/facets_spec.rb +30 -1
  95. data/spec/presenters/blacklight/document_presenter_spec.rb +22 -62
  96. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +109 -0
  97. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +92 -0
  98. data/spec/presenters/blacklight/field_presenter_spec.rb +268 -0
  99. data/spec/presenters/blacklight/index_presenter_spec.rb +0 -142
  100. data/spec/presenters/blacklight/show_presenter_spec.rb +0 -177
  101. data/spec/spec_helper.rb +3 -0
  102. data/spec/support/presenter_test_helpers.rb +11 -0
  103. data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
  104. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +18 -0
  105. data/tasks/blacklight.rake +30 -23
  106. metadata +51 -7
  107. data/Vagrantfile +0 -79
  108. data/provision.sh +0 -30
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::FacetItemComponent, type: :component do
6
+ subject(:render) do
7
+ render_inline(described_class.new(facet_item: facet_item))
8
+ end
9
+
10
+ let(:rendered) do
11
+ Capybara::Node::Simple.new(render)
12
+ end
13
+
14
+ let(:facet_item) do
15
+ instance_double(
16
+ Blacklight::FacetItemPresenter,
17
+ facet_config: Blacklight::Configuration::FacetField.new,
18
+ label: 'x',
19
+ hits: 10,
20
+ href: '/catalog?f=x',
21
+ selected?: false
22
+ )
23
+ end
24
+
25
+ it 'links to the facet and shows the number of hits' do
26
+ expect(rendered).to have_selector 'li'
27
+ expect(rendered).to have_link 'x', href: '/catalog?f=x'
28
+ expect(rendered).to have_selector '.facet-count', text: '10'
29
+ end
30
+
31
+ context 'with a selected facet' do
32
+ let(:facet_item) do
33
+ instance_double(
34
+ Blacklight::FacetItemPresenter,
35
+ facet_config: Blacklight::Configuration::FacetField.new,
36
+ label: 'x',
37
+ hits: 10,
38
+ href: '/catalog',
39
+ selected?: true
40
+ )
41
+ end
42
+
43
+ it 'links to the facet and shows the number of hits' do
44
+ expect(rendered).to have_selector 'li'
45
+ expect(rendered).to have_selector '.selected', text: 'x'
46
+ expect(rendered).to have_link '[remove]', href: '/catalog'
47
+ expect(rendered).to have_selector '.selected.facet-count', text: '10'
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::FacetItemPivotComponent, type: :component do
6
+ subject(:render) do
7
+ render_inline(described_class.new(facet_item: facet_item))
8
+ end
9
+
10
+ let(:rendered) do
11
+ Capybara::Node::Simple.new(render)
12
+ end
13
+
14
+ let(:search_state) do
15
+ Blacklight::SearchState.new({}, Blacklight::Configuration.new)
16
+ end
17
+
18
+ let(:facet_item) do
19
+ instance_double(
20
+ Blacklight::FacetItemPresenter,
21
+ facet_config: Blacklight::Configuration::FacetField.new(key: 'z'),
22
+ facet_field: 'z',
23
+ label: 'x',
24
+ hits: 10,
25
+ href: '/catalog?f[z]=x',
26
+ selected?: false,
27
+ search_state: search_state,
28
+ items: [OpenStruct.new(value: 'x:1', hits: 5)]
29
+ )
30
+ end
31
+
32
+ it 'links to the facet and shows the number of hits' do
33
+ expect(rendered).to have_selector 'li'
34
+ expect(rendered).to have_link 'x', href: '/catalog?f[z]=x'
35
+ expect(rendered).to have_selector '.facet-count', text: '10'
36
+ end
37
+
38
+ it 'has the facet hierarchy' do
39
+ puts render
40
+ expect(rendered).to have_selector 'li ul.pivot-facet'
41
+ expect(rendered).to have_link 'x:1', href: /f%5Bz%5D%5B%5D=x%3A1/
42
+ end
43
+
44
+ context 'with a selected facet' do
45
+ let(:facet_item) do
46
+ instance_double(
47
+ Blacklight::FacetItemPresenter,
48
+ facet_config: Blacklight::Configuration::FacetField.new,
49
+ facet_field: 'z',
50
+ label: 'x',
51
+ hits: 10,
52
+ href: '/catalog',
53
+ selected?: true,
54
+ search_state: search_state,
55
+ items: []
56
+ )
57
+ end
58
+
59
+ it 'links to the facet and shows the number of hits' do
60
+ expect(rendered).to have_selector 'li'
61
+ expect(rendered).to have_selector '.selected', text: 'x'
62
+ expect(rendered).to have_link '[remove]', href: '/catalog'
63
+ expect(rendered).to have_selector '.selected.facet-count', text: '10'
64
+ end
65
+ end
66
+ end
@@ -67,6 +67,26 @@ RSpec.describe "Facets" do
67
67
  expect(page).to have_css('#facet-format', visible: true) # assert that it didn't re-collapse
68
68
  end
69
69
 
70
+ it 'is able to expand pivot facets when javascript is enabled', js: true do
71
+ visit root_path
72
+
73
+ within('#facets .facets-header') do
74
+ page.find('button.navbar-toggler').click
75
+ end
76
+
77
+ page.find('h3.facet-field-heading button', text: 'Pivot Field').click
78
+
79
+ within '#facet-example_pivot_field' do
80
+ expect(page).to have_css('.facet-leaf-node', text: 'Book 30')
81
+ expect(page).not_to have_css('.facet-select', text: 'Tibetan')
82
+ page.find('.facet-toggle-handle').click
83
+ click_link 'Tibetan'
84
+ end
85
+
86
+ expect(page).to have_css('.constraint-value', text: 'Format Book')
87
+ expect(page).to have_css('.constraint-value', text: 'Language Tibetan')
88
+ end
89
+
70
90
  describe 'heading button focus with Firefox' do
71
91
  before do
72
92
  Capybara.current_driver = :selenium_headless
@@ -88,7 +108,7 @@ RSpec.describe "Facets" do
88
108
  it 'has default more link with sr-only text' do
89
109
  visit root_path
90
110
  within '#facet-language_ssim' do
91
- expect(page).to have_css 'li.more_facets', text: 'more Language'
111
+ expect(page).to have_css 'div.more_facets', text: 'more Language'
92
112
  end
93
113
  end
94
114
  end
@@ -274,6 +274,9 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
274
274
  it 'handles a missing key' do
275
275
  expect(helper.label_for_search_field('not-found')).to eq 'Not Found'
276
276
  end
277
+ it 'handles a missing field' do
278
+ expect(helper.label_for_search_field(nil)).to eq nil
279
+ end
277
280
  end
278
281
 
279
282
  describe '#sort_field_label' do
@@ -214,7 +214,11 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
214
214
 
215
215
  context "when one of the facet items is rendered as nil" do
216
216
  # An app may override render_facet_item to filter out some undesired facet items by returning nil.
217
- before { allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil) }
217
+ before do
218
+ allow(helper.method(:render_facet_item)).to receive(:owner).and_return(self.class)
219
+ # allow_any_instance_of(Blacklight::FacetItemComponent).to receive(:overridden_helper_methods?).and_return(true)
220
+ allow(helper).to receive(:render_facet_item).and_return('<a class="facet-select">Book</a>'.html_safe, nil)
221
+ end
218
222
 
219
223
  it "draws a list of elements" do
220
224
  expect(subject).to have_selector 'li', count: 1
@@ -246,36 +250,44 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
246
250
  end
247
251
 
248
252
  describe "facet_field_in_params?" do
253
+ let(:search_state) { double }
254
+
255
+ before do
256
+ allow(helper).to receive_messages(search_state: search_state)
257
+ end
258
+
249
259
  it "checks if any value is selected for a given facet" do
250
- allow(helper).to receive_messages(facet_params: ["x"])
260
+ allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(true)
251
261
  expect(helper.facet_field_in_params?("some-facet")).to eq true
252
262
  end
253
263
 
254
264
  it "is false if no value for facet is selected" do
255
- allow(helper).to receive_messages(facet_params: nil)
265
+ allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet')).and_return(false)
256
266
  expect(helper.facet_field_in_params?("some-facet")).to eq false
257
267
  end
258
268
  end
259
269
 
260
270
  describe "facet_in_params?" do
271
+ let(:search_state) { double }
272
+
273
+ before do
274
+ allow(helper).to receive_messages(search_state: search_state)
275
+ allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'x').and_return(true)
276
+ allow(search_state).to receive(:has_facet?).with(having_attributes(key: 'some-facet'), value: 'y').and_return(false)
277
+ end
278
+
261
279
  it "checks if a particular value is set in the facet params" do
262
- allow(helper).to receive_messages(facet_params: ["x"])
263
280
  expect(helper.facet_in_params?("some-facet", "x")).to eq true
264
281
  expect(helper.facet_in_params?("some-facet", "y")).to eq false
265
282
  end
266
-
267
- it "is false if no value for facet is selected" do
268
- allow(helper).to receive_messages(facet_params: nil)
269
- expect(helper.facet_in_params?("some-facet", "x")).to eq false
270
- end
271
283
  end
272
284
 
273
285
  describe "render_facet_value" do
274
286
  let(:item) { double(value: 'A', hits: 10) }
275
- let(:search_state) { double(add_facet_params_and_redirect: { controller: 'catalog' }) }
287
+ let(:search_state) { double(has_facet?: false, add_facet_params_and_redirect: { controller: 'catalog' }) }
276
288
 
277
289
  before do
278
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, single: false, url_method: nil))
290
+ allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: nil))
279
291
  allow(helper).to receive(:facet_display_value).and_return('Z')
280
292
  allow(helper).to receive(:search_state).and_return(search_state)
281
293
  allow(helper).to receive(:search_action_path) do |*args|
@@ -296,7 +308,7 @@ RSpec.describe Blacklight::FacetsHelperBehavior do
296
308
  let(:expected_html) { '<span class="facet-label"><a class="facet-select" href="/blabla">Z</a></span><span class="facet-count">10</span>' }
297
309
 
298
310
  it "uses that method" do
299
- allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method))
311
+ allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(Blacklight::Configuration::FacetField.new(key: 'simple_field', query: nil, date: nil, helper_method: nil, single: false, url_method: :test_method))
300
312
  allow(helper).to receive(:test_method).with('simple_field', item).and_return('/blabla')
301
313
  result = helper.render_facet_value('simple_field', item)
302
314
  expect(result).to be_equivalent_to(expected_html).respecting_element_order
@@ -13,6 +13,9 @@ RSpec.describe Blacklight::RenderConstraintsHelperBehavior do
13
13
  allow(helper).to receive(:search_action_path) do |*args|
14
14
  search_catalog_path *args
15
15
  end
16
+
17
+ allow(helper).to receive(:blacklight_config).and_return(config)
18
+ allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
16
19
  end
17
20
 
18
21
  describe '#render_constraints_query' do
@@ -22,24 +25,7 @@ RSpec.describe Blacklight::RenderConstraintsHelperBehavior do
22
25
  let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }) }
23
26
 
24
27
  it "has a link relative to the current url" do
25
- expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
26
- end
27
-
28
- context 'with an ordinary hash' do
29
- let(:params) { { q: 'foobar', f: { type: 'journal' } } }
30
-
31
- it "has a link relative to the current url" do
32
- expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
33
- end
34
- end
35
-
36
- context "with a route_set" do
37
- let(:params) { ActionController::Parameters.new(q: 'foobar', f: { type: 'journal' }, route_set: my_engine) }
38
-
39
- it "accepts an optional route set" do
40
- expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
41
- expect(subject).to have_selector "a[href='/?f%5Btype%5D=journal']"
42
- end
28
+ expect(subject).to have_link 'Remove constraint', href: '/catalog?f%5Btype%5D=journal'
43
29
  end
44
30
  end
45
31
 
@@ -73,11 +59,6 @@ RSpec.describe Blacklight::RenderConstraintsHelperBehavior do
73
59
 
74
60
  let(:params) { ActionController::Parameters.new f: { 'type' => [''] } }
75
61
 
76
- before do
77
- allow(helper).to receive(:blacklight_config).and_return(config)
78
- allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
79
- end
80
-
81
62
  it "renders nothing for empty facet limit param" do
82
63
  expect(subject).to be_blank
83
64
  end
@@ -208,6 +208,23 @@ RSpec.describe BlacklightHelper do
208
208
  end
209
209
  end
210
210
 
211
+ describe '#render_index_field_label' do
212
+ let(:doc) { SolrDocument.new({}) }
213
+
214
+ before do
215
+ allow(helper).to receive_messages(document_index_view_type: :current_view)
216
+ end
217
+
218
+ it 'accepts an explicit field label' do
219
+ expect(helper.render_index_field_label(doc, field: 'xyz', label: 'some label')).to eq 'some label:'
220
+ end
221
+
222
+ it 'calculates the appropriate field label for a field' do
223
+ allow(helper).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
224
+ expect(helper.render_index_field_label(doc, field: 'xyz')).to eq 'Xyz:'
225
+ end
226
+ end
227
+
211
228
  describe "render_grouped_response?" do
212
229
  it "checks if the response ivar contains grouped data" do
213
230
  assign(:response, instance_double(Blacklight::Solr::Response, grouped?: true))
@@ -39,13 +39,6 @@ RSpec.describe CatalogHelper do
39
39
  expect(html).to be_html_safe
40
40
  end
41
41
 
42
- it "with an empty page of results" do
43
- @response = double(limit_value: -1)
44
-
45
- html = page_entries_info(@response)
46
- expect(html).to be_blank
47
- end
48
-
49
42
  context "when response.entry_name is nil" do
50
43
  it "does not raise an error" do
51
44
  collection = mock_response total: 10
@@ -48,6 +48,56 @@ RSpec.describe Blacklight::SearchState do
48
48
  end
49
49
  end
50
50
 
51
+ describe 'interface compatibility with params' do
52
+ let(:params) { parameter_class.new f: { ff: ['xyz'] } }
53
+
54
+ it 'implements param methods' do
55
+ Deprecation.silence(described_class) do
56
+ expect(search_state.to_unsafe_h).to eq('f' => { 'ff' => ['xyz'] })
57
+ expect(search_state.fetch(:f)).to eq('ff' => ['xyz'])
58
+ expect(search_state.select { |k, _v,| k == 'f' }).to eq('f' => { 'ff' => ['xyz'] })
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#query_param' do
64
+ let(:params) { parameter_class.new q: 'xyz' }
65
+
66
+ it 'returns the query param' do
67
+ expect(search_state.query_param).to eq 'xyz'
68
+ end
69
+ end
70
+
71
+ describe '#filter_params' do
72
+ let(:params) { parameter_class.new f: { ff: ['xyz'] } }
73
+
74
+ it 'returns the query param' do
75
+ expect(search_state.filter_params.deep_symbolize_keys).to eq(ff: ['xyz'])
76
+ end
77
+ end
78
+
79
+ describe '#has_constraints?' do
80
+ it 'is false' do
81
+ expect(search_state.has_constraints?).to eq false
82
+ end
83
+
84
+ context 'with a query param' do
85
+ let(:params) { parameter_class.new q: 'xyz' }
86
+
87
+ it 'is true' do
88
+ expect(search_state.has_constraints?).to eq true
89
+ end
90
+ end
91
+
92
+ context 'with a facet param' do
93
+ let(:params) { parameter_class.new f: { ff: ['xyz'] } }
94
+
95
+ it 'is true' do
96
+ expect(search_state.has_constraints?).to eq true
97
+ end
98
+ end
99
+ end
100
+
51
101
  describe "params_for_search" do
52
102
  let(:params) { parameter_class.new 'default' => 'params' }
53
103
 
@@ -189,14 +189,18 @@ RSpec.describe "Blacklight::Configuration", api: true do
189
189
  it "provides cloned copies of mutable data structures" do
190
190
  config.a = { value: 1 }
191
191
  config.b = [1, 2, 3]
192
+ config.c = Blacklight::Configuration::Field.new(key: 'c', value: %w[a b])
192
193
 
193
194
  config_copy.a[:value] = 2
194
195
  config_copy.b << 5
196
+ config_copy.c.value << 'c'
195
197
 
196
198
  expect(config.a[:value]).to eq 1
197
199
  expect(config_copy.a[:value]).to eq 2
198
200
  expect(config.b).to match_array [1, 2, 3]
199
201
  expect(config_copy.b).to match_array [1, 2, 3, 5]
202
+ expect(config.c.value).to match_array %w[a b]
203
+ expect(config_copy.c.value).to match_array %w[a b c]
200
204
  end
201
205
  end
202
206
 
@@ -17,29 +17,30 @@ RSpec.describe Blacklight::Icon do
17
17
  end
18
18
  it 'adds title' do
19
19
  expect(Capybara.string(subject.svg))
20
- .to have_css 'title[id^="bl-icon-search-"]', text: 'search icon'
21
- end
22
- it 'adds aria-labelledby' do
23
- expect(Capybara.string(subject.svg))
24
- .to have_css 'svg[aria-labelledby^="bl-icon-search-"]'
20
+ .to have_css 'title', text: 'Search'
25
21
  end
26
22
  context 'when label is false' do
27
23
  subject { described_class.new(:search, classes: 'awesome', aria_hidden: true, label: false) }
28
24
 
29
25
  it 'does not add title' do
30
26
  expect(Capybara.string(subject.svg))
31
- .not_to have_css 'title', text: 'search icon'
27
+ .not_to have_css 'title', text: 'Search'
32
28
  end
33
- it 'does not add aria-labelledby' do
29
+ end
30
+
31
+ context ' with a label context' do
32
+ subject { described_class.new(:search, classes: 'awesome', aria_hidden: true, additional_options: { label_context: 'foo' }) }
33
+
34
+ it 'adds title' do
34
35
  expect(Capybara.string(subject.svg))
35
- .not_to have_css 'svg[aria-labelledby^="bl-icon-search-"]'
36
+ .to have_css 'title', text: 'Search'
36
37
  end
37
38
  end
38
39
  end
39
40
 
40
41
  describe '#options' do
41
42
  it 'applies options classes and default class' do
42
- expect(subject.options[:class]).to eq 'blacklight-icons awesome'
43
+ expect(subject.options[:class]).to eq 'blacklight-icons blacklight-icon-search awesome'
43
44
  end
44
45
  it 'applies options aria-hidden=true' do
45
46
  expect(subject.options[:'aria-hidden']).to be true
@@ -48,7 +49,7 @@ RSpec.describe Blacklight::Icon do
48
49
  subject { described_class.new(:view) }
49
50
 
50
51
  it 'applies default class with no options' do
51
- expect(subject.options[:class]).to eq 'blacklight-icons'
52
+ expect(subject.options[:class]).to eq 'blacklight-icons blacklight-icon-view'
52
53
  end
53
54
 
54
55
  it 'has no aria-hidden attribute with no options' do