blacklight-spotlight 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/spotlight/_bootstrap_overrides.scss +4 -2
  3. data/app/assets/stylesheets/spotlight/_footer.scss +1 -1
  4. data/app/assets/stylesheets/spotlight/_header.scss +0 -40
  5. data/app/controllers/spotlight/appearances_controller.rb +2 -2
  6. data/app/controllers/spotlight/custom_fields_controller.rb +1 -1
  7. data/app/controllers/spotlight/dashboards_controller.rb +11 -0
  8. data/app/controllers/spotlight/exhibits_controller.rb +2 -2
  9. data/app/controllers/spotlight/metadata_configurations_controller.rb +2 -2
  10. data/app/controllers/spotlight/roles_controller.rb +2 -2
  11. data/app/controllers/spotlight/search_configurations_controller.rb +2 -2
  12. data/app/helpers/spotlight/title_helper.rb +2 -2
  13. data/app/models/concerns/spotlight/solr_document.rb +10 -4
  14. data/app/models/concerns/spotlight/solr_document/finder.rb +14 -0
  15. data/app/models/spotlight/ability.rb +1 -3
  16. data/app/models/spotlight/blacklight_configuration.rb +2 -2
  17. data/app/models/spotlight/custom_field.rb +37 -15
  18. data/app/models/spotlight/solr_document_sidecar.rb +16 -1
  19. data/app/views/shared/_breadcrumbs.html.erb +5 -1
  20. data/app/views/shared/_exhibit_masthead.html.erb +0 -17
  21. data/app/views/shared/_footer.html.erb +1 -1
  22. data/app/views/spotlight/about_pages/index.html.erb +1 -1
  23. data/app/views/spotlight/appearances/edit.html.erb +2 -2
  24. data/app/views/spotlight/catalog/_edit_default.html.erb +1 -1
  25. data/app/views/spotlight/catalog/admin.html.erb +1 -1
  26. data/app/views/spotlight/catalog/new.html.erb +1 -1
  27. data/app/views/spotlight/contacts/edit.html.erb +1 -1
  28. data/app/views/spotlight/contacts/new.html.erb +1 -1
  29. data/app/views/spotlight/custom_fields/edit.html.erb +3 -3
  30. data/app/views/spotlight/custom_fields/new.html.erb +3 -4
  31. data/app/views/spotlight/dashboards/_analytics.html.erb +1 -3
  32. data/app/views/spotlight/dashboards/analytics.html.erb +15 -0
  33. data/app/views/spotlight/dashboards/show.html.erb +1 -3
  34. data/app/views/spotlight/exhibits/edit.html.erb +2 -2
  35. data/app/views/spotlight/exhibits/new.html.erb +1 -1
  36. data/app/views/spotlight/home_pages/_empty.html.erb +3 -3
  37. data/app/views/spotlight/metadata_configurations/edit.html.erb +2 -2
  38. data/app/views/spotlight/pages/index.html.erb +1 -1
  39. data/app/views/spotlight/resources/upload/new.html.erb +1 -1
  40. data/app/views/spotlight/roles/index.html.erb +2 -2
  41. data/app/views/spotlight/search_configurations/edit.html.erb +2 -2
  42. data/app/views/spotlight/searches/edit.html.erb +1 -1
  43. data/app/views/spotlight/searches/index.html.erb +4 -4
  44. data/app/views/spotlight/shared/_configuration_sidebar.html.erb +14 -0
  45. data/app/views/spotlight/shared/_curation_sidebar.html.erb +16 -26
  46. data/app/views/spotlight/shared/_exhibit_sidebar.html.erb +8 -0
  47. data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -1
  48. data/app/views/spotlight/tags/index.html.erb +1 -1
  49. data/config/locales/spotlight.en.yml +12 -16
  50. data/config/routes.rb +3 -1
  51. data/db/migrate/20151124101123_remove_default_from_spotlight_exhibit.rb +13 -0
  52. data/db/migrate/20151124105543_update_custom_field_names.rb +31 -0
  53. data/lib/generators/spotlight/templates/catalog_controller.rb +1 -1
  54. data/lib/spotlight/engine.rb +4 -0
  55. data/lib/spotlight/version.rb +1 -1
  56. data/spec/controllers/spotlight/appearances_controller_spec.rb +1 -1
  57. data/spec/controllers/spotlight/custom_fields_controller_spec.rb +4 -4
  58. data/spec/controllers/spotlight/dashboards_controller_spec.rb +15 -0
  59. data/spec/controllers/spotlight/exhibits_controller_spec.rb +2 -2
  60. data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +1 -1
  61. data/spec/controllers/spotlight/roles_controller_spec.rb +1 -1
  62. data/spec/controllers/spotlight/search_configurations_controller_spec.rb +2 -2
  63. data/spec/features/create_exhibit_spec.rb +1 -1
  64. data/spec/features/edit_search_fields_spec.rb +4 -4
  65. data/spec/features/exhibits/administration_spec.rb +1 -1
  66. data/spec/features/exhibits/custom_metadata_fields_spec.rb +1 -1
  67. data/spec/features/exhibits/edit_metadata_fields_spec.rb +1 -1
  68. data/spec/features/import_exhibit_spec.rb +2 -2
  69. data/spec/features/javascript/search_config_admin_spec.rb +7 -7
  70. data/spec/features/metadata_admin_spec.rb +2 -2
  71. data/spec/helpers/spotlight/title_helper_spec.rb +4 -4
  72. data/spec/lib/spotlight/catalog/access_controls_enforcement_spec.rb +1 -1
  73. data/spec/models/solr_document_spec.rb +29 -4
  74. data/spec/models/spotlight/blacklight_configuration_spec.rb +4 -4
  75. data/spec/models/spotlight/custom_field_spec.rb +48 -25
  76. data/spec/models/spotlight/resources/upload_spec.rb +1 -1
  77. data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -1
  78. data/spec/test_app_templates/catalog_controller.rb +1 -1
  79. data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +0 -1
  80. data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +33 -0
  81. data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +1 -1
  82. data/spec/views/spotlight/searches/index.html.erb_spec.rb +3 -3
  83. data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +20 -0
  84. metadata +11 -5
  85. data/app/views/spotlight/shared/_admin_sidebar.html.erb +0 -10
  86. data/spec/features/multiple_exhibits_spec.rb +0 -27
@@ -39,6 +39,10 @@ module Spotlight
39
39
  OEmbed::Providers.register_all
40
40
  end
41
41
 
42
+ initializer 'spotlight.factories', after: 'factory_girl.set_factory_paths' do
43
+ FactoryGirl.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryGirl)
44
+ end
45
+
42
46
  def self.catalog_controller
43
47
  Spotlight::Engine.config.catalog_controller_class.constantize
44
48
  end
@@ -1,4 +1,4 @@
1
1
  #
2
2
  module Spotlight
3
- VERSION = '0.8.2'
3
+ VERSION = '0.9.0'
4
4
  end
@@ -31,7 +31,7 @@ describe Spotlight::AppearancesController, type: :controller do
31
31
  describe '#edit' do
32
32
  it 'is successful' do
33
33
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
34
- expect(controller).to receive(:add_breadcrumb).with('Administration', exhibit_dashboard_path(exhibit))
34
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
35
35
  expect(controller).to receive(:add_breadcrumb).with('Appearance', edit_exhibit_appearance_path(exhibit))
36
36
  get :edit, exhibit_id: exhibit
37
37
  expect(response).to be_successful
@@ -3,14 +3,14 @@ describe Spotlight::CustomFieldsController, type: :controller do
3
3
  routes { Spotlight::Engine.routes }
4
4
  let(:exhibit) { FactoryGirl.create(:exhibit) }
5
5
 
6
- describe 'when signed in as a curator' do
7
- let(:user) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
6
+ describe 'when signed in as an exhibit admin' do
7
+ let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
8
8
  before { sign_in user }
9
9
 
10
10
  describe 'GET new' do
11
11
  it 'assigns a new custom field' do
12
12
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
13
- expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
13
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
14
14
  expect(controller).to receive(:add_breadcrumb).with('Metadata', edit_exhibit_metadata_configuration_path(exhibit))
15
15
  expect(controller).to receive(:add_breadcrumb).with('Add new field', new_exhibit_custom_field_path(exhibit))
16
16
  get :new, exhibit_id: exhibit
@@ -22,7 +22,7 @@ describe Spotlight::CustomFieldsController, type: :controller do
22
22
  let(:field) { FactoryGirl.create(:custom_field, exhibit: exhibit) }
23
23
  it 'assigns the requested custom_field' do
24
24
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
25
- expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
25
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
26
26
  expect(controller).to receive(:add_breadcrumb).with('Metadata', edit_exhibit_metadata_configuration_path(exhibit))
27
27
  expect(controller).to receive(:add_breadcrumb).with(field.label, edit_exhibit_custom_field_path(exhibit, field))
28
28
  get :edit, exhibit_id: exhibit, id: field
@@ -26,6 +26,16 @@ describe Spotlight::DashboardsController, type: :controller do
26
26
  expect(assigns[:solr_documents]).to have(1).item
27
27
  end
28
28
  end
29
+
30
+ describe 'GET analytics' do
31
+ it 'loads the exhibit' do
32
+ expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
33
+ expect(controller).to receive(:add_breadcrumb).with('Analytics', analytics_exhibit_dashboard_path(exhibit))
34
+ get :analytics, exhibit_id: exhibit.id
35
+ expect(response).to render_template 'spotlight/dashboards/analytics'
36
+ expect(assigns[:exhibit]).to eq exhibit
37
+ end
38
+ end
29
39
  end
30
40
 
31
41
  describe 'when user does not have access' do
@@ -34,6 +44,11 @@ describe Spotlight::DashboardsController, type: :controller do
34
44
  get :show, exhibit_id: exhibit.id
35
45
  expect(response).to redirect_to main_app.root_path
36
46
  end
47
+
48
+ it 'does not allow analytics' do
49
+ get :analytics, exhibit_id: exhibit.id
50
+ expect(response).to redirect_to main_app.root_path
51
+ end
37
52
  end
38
53
 
39
54
  describe 'when not logged in' do
@@ -126,8 +126,8 @@ describe Spotlight::ExhibitsController, type: :controller do
126
126
  describe '#edit' do
127
127
  it 'is successful' do
128
128
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
129
- expect(controller).to receive(:add_breadcrumb).with('Administration', exhibit_dashboard_path(exhibit))
130
- expect(controller).to receive(:add_breadcrumb).with('Settings', edit_exhibit_path(exhibit))
129
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
130
+ expect(controller).to receive(:add_breadcrumb).with('General', edit_exhibit_path(exhibit))
131
131
  get :edit, id: exhibit
132
132
  expect(response).to be_successful
133
133
  end
@@ -44,7 +44,7 @@ describe Spotlight::MetadataConfigurationsController, type: :controller do
44
44
  describe '#edit' do
45
45
  it 'is successful' do
46
46
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
47
- expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
47
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
48
48
  expect(controller).to receive(:add_breadcrumb).with('Metadata', edit_exhibit_metadata_configuration_path(exhibit))
49
49
  get :edit, exhibit_id: exhibit
50
50
  expect(response).to be_successful
@@ -18,7 +18,7 @@ describe Spotlight::RolesController, type: :controller do
18
18
  before { sign_in admin }
19
19
  it 'allows index' do
20
20
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
21
- expect(controller).to receive(:add_breadcrumb).with('Administration', exhibit_dashboard_path(exhibit))
21
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
22
22
  expect(controller).to receive(:add_breadcrumb).with('Users', exhibit_roles_path(exhibit))
23
23
  get :index, exhibit_id: exhibit
24
24
  expect(response).to be_successful
@@ -38,7 +38,7 @@ describe Spotlight::SearchConfigurationsController, type: :controller do
38
38
  describe '#edit' do
39
39
  it 'is successful' do
40
40
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
41
- expect(controller).to receive(:add_breadcrumb).with('Curation', exhibit_dashboard_path(exhibit))
41
+ expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
42
42
  expect(controller).to receive(:add_breadcrumb).with('Search', edit_exhibit_search_configuration_path(exhibit))
43
43
  get :edit, exhibit_id: exhibit
44
44
  expect(response).to be_successful
@@ -101,7 +101,7 @@ describe Spotlight::SearchConfigurationsController, type: :controller do
101
101
  expect(response).to redirect_to edit_exhibit_search_configuration_path(exhibit)
102
102
  assigns[:exhibit].tap do |saved|
103
103
  expect(saved.blacklight_configuration.search_fields).to eq(
104
- 'all_fields' => { 'label' => 'All fields', 'enabled' => true },
104
+ 'all_fields' => { 'label' => 'Everything', 'enabled' => true },
105
105
  'title' => { 'label' => 'Title', 'enabled' => false },
106
106
  'author' => { 'label' => 'Primary Author', 'enabled' => true }
107
107
  )
@@ -12,7 +12,7 @@ describe 'Create a new exhibit', type: :feature do
12
12
  within '.dropdown-menu' do
13
13
  click_link 'Create Exhibit'
14
14
  end
15
- expect(page).to have_selector 'h1', text: 'Administration'
15
+ expect(page).to have_selector 'h1', text: 'Configuration'
16
16
  expect(page).to have_selector 'h1 small', text: 'Create a new exhibit'
17
17
  end
18
18
 
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Search Administration', type: :feature do
4
4
  let(:exhibit) { FactoryGirl.create(:exhibit) }
5
- let(:exhibit_curator) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
6
- before { login_as exhibit_curator }
5
+ let(:exhibit_admin) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
6
+ before { login_as exhibit_admin }
7
7
 
8
8
  describe 'edit' do
9
9
  it 'displays the search configuration edit screen' do
@@ -13,7 +13,7 @@ describe 'Search Administration', type: :feature do
13
13
 
14
14
  it 'has breadcrumbs' do
15
15
  visit spotlight.edit_exhibit_search_configuration_path exhibit
16
- expect(page).to have_breadcrumbs 'Home', 'Curation', 'Search'
16
+ expect(page).to have_breadcrumbs 'Home', 'Configuration', 'Search'
17
17
  end
18
18
 
19
19
  describe 'facets' do
@@ -29,7 +29,7 @@ describe 'Search Administration', type: :feature do
29
29
  it 'allows curators to select and unselect facets for display' do
30
30
  visit spotlight.edit_exhibit_search_configuration_path exhibit
31
31
 
32
- expect(page).to have_content 'Curation Search Options Facets'
32
+ expect(page).to have_content 'Configuration Search Options Facets'
33
33
  expect(page).to have_button 'Save'
34
34
 
35
35
  uncheck 'blacklight_configuration_facet_fields_language_ssim_show' # Language
@@ -12,7 +12,7 @@ describe 'Exhibit Administration', type: :feature do
12
12
  describe 'Contact Emails' do
13
13
  it 'has breadcrumbs' do
14
14
  visit spotlight.edit_exhibit_path(exhibit)
15
- expect(page).to have_breadcrumbs 'Home', 'Administration', 'Settings'
15
+ expect(page).to have_breadcrumbs 'Home', 'Configuration', 'General'
16
16
  end
17
17
 
18
18
  it 'has a blank input field when there are no contacts yet' do
@@ -48,7 +48,7 @@ describe 'Adding custom metadata fields', type: :feature do
48
48
  it 'has breadcrumbs' do
49
49
  visit spotlight.edit_exhibit_metadata_configuration_path exhibit
50
50
  click_on 'Add new field'
51
- expect(page).to have_breadcrumbs 'Home', 'Curation', 'Metadata', 'Add new field'
51
+ expect(page).to have_breadcrumbs 'Home', 'Configuration', 'Metadata', 'Add new field'
52
52
  end
53
53
 
54
54
  it 'lets the curator choose the type of field on create' do
@@ -43,6 +43,6 @@ describe 'Editing metadata fields', type: :feature do
43
43
  it 'has breadcrumbs' do
44
44
  visit spotlight.edit_exhibit_metadata_configuration_path exhibit
45
45
 
46
- expect(page).to have_breadcrumbs 'Home', 'Curation', 'Metadata'
46
+ expect(page).to have_breadcrumbs 'Home', 'Configuration', 'Metadata'
47
47
  end
48
48
  end
@@ -17,7 +17,7 @@ the export option behind a bootstrap tab)))
17
17
  click_link 'Dashboard'
18
18
  end
19
19
 
20
- click_link 'Settings'
20
+ click_link 'General'
21
21
  within('.nav-tabs') do
22
22
  click_link 'Export data'
23
23
  end
@@ -38,7 +38,7 @@ the export option behind a bootstrap tab)))
38
38
  click_link 'Dashboard'
39
39
  end
40
40
 
41
- click_link 'Settings'
41
+ click_link 'General'
42
42
 
43
43
  within('.nav-tabs') do
44
44
  click_link 'Import data'
@@ -2,15 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  feature 'Search Configuration Administration', js: true do
4
4
  let(:exhibit) { FactoryGirl.create(:exhibit) }
5
- let(:exhibit_curator) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
6
- before { login_as exhibit_curator }
5
+ let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
6
+ before { login_as user }
7
7
 
8
8
  describe 'search fields' do
9
9
  it 'allows the curator to disable all search fields' do
10
10
  visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
11
11
  expect(page).to have_css 'select#search_field'
12
12
 
13
- click_link exhibit_curator.email
13
+ click_link user.email
14
14
  within '#user-util-collapse .dropdown' do
15
15
  click_link 'Dashboard'
16
16
  end
@@ -28,7 +28,7 @@ feature 'Search Configuration Administration', js: true do
28
28
 
29
29
  it 'allows the curator to update search field options' do
30
30
  visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
31
- click_link exhibit_curator.email
31
+ click_link user.email
32
32
  within '#user-util-collapse .dropdown' do
33
33
  click_link 'Dashboard'
34
34
  end
@@ -56,7 +56,7 @@ feature 'Search Configuration Administration', js: true do
56
56
  it 'allows us to update the label with edit-in-place' do
57
57
  input_id = 'blacklight_configuration_facet_fields_genre_ssim_label'
58
58
  visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
59
- click_link exhibit_curator.email
59
+ click_link user.email
60
60
  within '#user-util-collapse .dropdown' do
61
61
  click_link 'Dashboard'
62
62
  end
@@ -87,7 +87,7 @@ feature 'Search Configuration Administration', js: true do
87
87
  describe 'results' do
88
88
  it 'updates search result options' do
89
89
  visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
90
- click_link exhibit_curator.email
90
+ click_link user.email
91
91
  within '#user-util-collapse .dropdown' do
92
92
  click_link 'Dashboard'
93
93
  end
@@ -113,7 +113,7 @@ feature 'Search Configuration Administration', js: true do
113
113
  end
114
114
  it 'updates Sort field result options' do
115
115
  visit spotlight.exhibit_home_page_path(exhibit, exhibit.home_page)
116
- click_link exhibit_curator.email
116
+ click_link user.email
117
117
  within '#user-util-collapse .dropdown' do
118
118
  click_link 'Dashboard'
119
119
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Metadata Administration', type: :feature do
4
4
  let(:exhibit) { FactoryGirl.create(:exhibit) }
5
- let(:exhibit_curator) { FactoryGirl.create(:exhibit_curator, exhibit: exhibit) }
6
- before { login_as exhibit_curator }
5
+ let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
6
+ before { login_as user }
7
7
 
8
8
  describe 'edit' do
9
9
  it 'displays the metadata edit page' do
@@ -40,10 +40,10 @@ describe Spotlight::TitleHelper, type: :helper do
40
40
  end
41
41
  end
42
42
 
43
- describe '#administration_page_title' do
44
- it 'renders a page title in the administration section' do
45
- title = helper.administration_page_title 'Some title'
46
- expect(title).to have_selector 'h1', text: 'Administration'
43
+ describe '#configuration_page_title' do
44
+ it 'renders a page title in the configuration section' do
45
+ title = helper.configuration_page_title 'Some title'
46
+ expect(title).to have_selector 'h1', text: 'Configuration'
47
47
  expect(title).to have_selector 'h1 small', text: 'Some title'
48
48
  end
49
49
  end
@@ -46,7 +46,7 @@ describe Spotlight::Catalog::AccessControlsEnforcement do
46
46
 
47
47
  subject.apply_permissive_visibility_filter(solr_request)
48
48
  expect(solr_request).to include :fq
49
- expect(solr_request[:fq]).to include '-exhibit_1_public_bsi:false'
49
+ expect(solr_request[:fq]).to include "-exhibit_#{exhibit.slug}_public_bsi:false"
50
50
  end
51
51
 
52
52
  it 'does not filter resources to just those created by the exhibit' do
@@ -80,13 +80,13 @@ describe SolrDocument, type: :model do
80
80
  it 'includes exhibit-specific tags' do
81
81
  exhibit.tag(subject, with: 'paris', on: :tags)
82
82
 
83
- expect(subject.to_solr).to include :exhibit_1_tags_ssim
84
- expect(subject.to_solr[:exhibit_1_tags_ssim]).to include 'paris'
83
+ expect(subject.to_solr).to include :"exhibit_#{exhibit.slug}_tags_ssim"
84
+ expect(subject.to_solr[:"exhibit_#{exhibit.slug}_tags_ssim"]).to include 'paris'
85
85
  end
86
86
 
87
87
  it "includes placeholders for all exhibits' tags" do
88
- expect(subject.to_solr).to include :exhibit_1_tags_ssim
89
- expect(subject.to_solr[:exhibit_1_tags_ssim]).to eq nil
88
+ expect(subject.to_solr).to include :"exhibit_#{exhibit.slug}_tags_ssim"
89
+ expect(subject.to_solr[:"exhibit_#{exhibit.slug}_tags_ssim"]).to eq nil
90
90
  end
91
91
 
92
92
  it 'includes sidecar fields' do
@@ -151,4 +151,29 @@ describe SolrDocument, type: :model do
151
151
  end
152
152
  end
153
153
  end
154
+
155
+ describe '.find_each' do
156
+ it 'enumerates the documents in the exhibit' do
157
+ expect(described_class.find_each).to be_a Enumerable
158
+ end
159
+
160
+ it 'pages through the index' do
161
+ allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 0)).and_return(double(documents: [1, 2, 3]))
162
+ allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 3)).and_return(double(documents: [4, 5, 6]))
163
+ allow_any_instance_of(Blacklight::Solr::Repository).to receive(:search).with(hash_including(start: 6)).and_return(double(documents: []))
164
+
165
+ expect(described_class.find_each.to_a).to match_array [1, 2, 3, 4, 5, 6]
166
+ end
167
+ end
168
+
169
+ describe '.reindex_all' do
170
+ let(:doc) { described_class.new id: 1 }
171
+
172
+ it 'reindexes all solr documents' do
173
+ expect(described_class).to receive(:find_each).and_yield(doc)
174
+ expect(doc).to receive(:reindex)
175
+
176
+ described_class.reindex_all
177
+ end
178
+ end
154
179
  end
@@ -440,10 +440,10 @@ describe Spotlight::BlacklightConfiguration, type: :model do
440
440
 
441
441
  describe '#custom_index_fields' do
442
442
  it 'converts exhibit-specific fields to Blacklight configurations' do
443
- allow(subject).to receive_messages(exhibit: double(custom_fields: [
444
- stub_model(Spotlight::CustomField, field: 'abc', configuration: { a: 1 }),
445
- stub_model(Spotlight::CustomField, field: 'xyz', configuration: { x: 2 })
446
- ]))
443
+ allow(subject.exhibit).to receive_messages(custom_fields: [
444
+ stub_model(Spotlight::CustomField, field: 'abc', configuration: { a: 1 }, exhibit: subject.exhibit),
445
+ stub_model(Spotlight::CustomField, field: 'xyz', configuration: { x: 2 }, exhibit: subject.exhibit)
446
+ ])
447
447
 
448
448
  expect(subject.custom_index_fields).to include 'abc', 'xyz'
449
449
  expect(subject.custom_index_fields['abc']).to be_a_kind_of Blacklight::Configuration::Field
@@ -45,22 +45,63 @@ describe Spotlight::CustomField, type: :model do
45
45
  end
46
46
 
47
47
  describe '#field' do
48
- let(:exhibit) { FactoryGirl.create(:exhibit) }
48
+ let(:exhibit) { double(to_param: 'a', solr_document_sidecars: Spotlight::SolrDocumentSidecar.none) }
49
+
50
+ before do
51
+ subject.label = 'xyz'
52
+ subject.save
53
+
54
+ allow(Spotlight::RenameSidecarFieldJob).to receive(:perform_later)
55
+ end
56
+
49
57
  it 'is auto-generated from the field label' do
50
- subject.configuration['label'] = 'xyz'
51
- subject.exhibit = exhibit
58
+ expect(subject.field).to start_with 'xyz'
59
+ end
60
+
61
+ it 'ends in the text suffix if it is a text field' do
62
+ subject.field_type = 'text'
52
63
  subject.save
64
+ expect(subject.field).to end_with Spotlight::Engine.config.solr_fields.text_suffix
65
+ end
53
66
 
54
- expect(subject.field).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
67
+ it 'ends in a string suffix if it is a vocab field' do
68
+ subject.field_type = 'vocab'
69
+ subject.save
70
+ expect(subject.field).to end_with Spotlight::Engine.config.solr_fields.string_suffix
55
71
  end
72
+ end
73
+
74
+ describe '#solr_field' do
75
+ let(:exhibit) { FactoryGirl.create(:exhibit) }
56
76
 
57
- it 'uses the solr field prefix' do
58
- allow(Spotlight::Engine.config.solr_fields).to receive(:prefix).and_return 'prefix_'
77
+ before do
59
78
  subject.configuration['label'] = 'xyz'
60
79
  subject.exhibit = exhibit
61
80
  subject.save
81
+ end
82
+
83
+ it 'is auto-generated from the field label' do
84
+ expect(subject.solr_field).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
85
+ end
86
+
87
+ context 'with a solr field prefix configured' do
88
+ before do
89
+ allow(Spotlight::Engine.config.solr_fields).to receive(:prefix).and_return 'prefix_'
90
+ end
91
+
92
+ it 'uses the solr field prefix' do
93
+ expect(subject.solr_field).to eq "prefix_exhibit_#{exhibit.to_param}_xyz_tesim"
94
+ end
95
+ end
96
+
97
+ context 'for a legacy solr field name' do
98
+ before do
99
+ subject.field = "exhibit_#{exhibit.to_param}_xyz_tesim"
100
+ end
62
101
 
63
- expect(subject.field).to eq "prefix_exhibit_#{exhibit.to_param}_xyz_tesim"
102
+ it 'returns the original field name' do
103
+ expect(subject.solr_field).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
104
+ end
64
105
  end
65
106
  end
66
107
 
@@ -101,24 +142,6 @@ describe Spotlight::CustomField, type: :model do
101
142
  end
102
143
  end
103
144
 
104
- describe '#field_name' do
105
- let(:exhibit) { double(to_param: 'a') }
106
-
107
- before do
108
- subject.label = 'xyz'
109
- end
110
-
111
- it 'ends in the text suffix if it is a text field' do
112
- subject.field_type = 'text'
113
- expect(subject.send(:field_name)).to end_with Spotlight::Engine.config.solr_fields.text_suffix
114
- end
115
-
116
- it 'ends in a string suffix if it is a vocab field' do
117
- subject.field_type = 'vocab'
118
- expect(subject.send(:field_name)).to end_with Spotlight::Engine.config.solr_fields.string_suffix
119
- end
120
- end
121
-
122
145
  describe 'changing the field type' do
123
146
  let(:exhibit) { FactoryGirl.create(:exhibit) }
124
147
  before do