blacklight-spotlight 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/app/assets/javascripts/spotlight/blocks/link_to_search_block.js +16 -0
- data/app/assets/javascripts/spotlight/exhibits.js +16 -5
- data/app/assets/javascripts/spotlight/form_observer.js +2 -2
- data/app/assets/javascripts/spotlight/pages.js.erb +3 -2
- data/app/assets/javascripts/spotlight/sir-trevor/locales.js +6 -0
- data/app/controllers/spotlight/concerns/application_controller.rb +4 -8
- data/app/controllers/spotlight/contact_email_controller.rb +22 -0
- data/app/controllers/spotlight/searches_controller.rb +3 -1
- data/app/models/concerns/spotlight/blacklight_configuration_defaults.rb +4 -4
- data/app/models/sir_trevor_rails/blocks/browse_block.rb +7 -1
- data/app/models/sir_trevor_rails/blocks/featured_pages_block.rb +3 -1
- data/app/models/sir_trevor_rails/blocks/link_to_search_block.rb +15 -0
- data/app/models/spotlight/ability.rb +1 -1
- data/app/models/spotlight/blacklight_configuration.rb +8 -7
- data/app/models/spotlight/exhibit.rb +2 -0
- data/app/models/spotlight/resource.rb +8 -2
- data/app/services/spotlight/carrierwave_file_resolver.rb +5 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +2 -2
- data/app/views/spotlight/appearances/edit.html.erb +1 -1
- data/app/views/spotlight/exhibits/_confirmation_status.html.erb +1 -1
- data/app/views/spotlight/exhibits/_contact.html.erb +15 -10
- data/app/views/spotlight/exhibits/_exhibit_card_back.html.erb +2 -2
- data/app/views/spotlight/exhibits/_form.html.erb +7 -6
- data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
- data/app/views/spotlight/pages/_form.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_facets.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
- data/app/views/spotlight/search_configurations/_sort.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +23 -0
- data/config/locales/spotlight.en.yml +9 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20171005231502_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb +23 -0
- data/lib/spotlight/engine.rb +4 -3
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/about_pages_controller_spec.rb +15 -15
- data/spec/controllers/spotlight/admin_users_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/appearances_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/application_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/attachments_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/browse_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/catalog_controller_spec.rb +15 -15
- data/spec/controllers/spotlight/confirmations_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/contact_email_controller_spec.rb +63 -0
- data/spec/controllers/spotlight/contact_forms_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/contacts_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/custom_fields_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/dashboards_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/exhibits_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/feature_pages_controller_spec.rb +12 -12
- data/spec/controllers/spotlight/featured_images_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/filters_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/home_pages_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/resources_controller_spec.rb +2 -2
- data/spec/controllers/spotlight/roles_controller_spec.rb +4 -4
- data/spec/controllers/spotlight/search_configurations_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/searches_controller_spec.rb +10 -11
- data/spec/controllers/spotlight/sites_controller_spec.rb +5 -5
- data/spec/controllers/spotlight/solr_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/tags_controller_spec.rb +3 -3
- data/spec/controllers/spotlight/versions_controller_spec.rb +7 -7
- data/spec/controllers/spotlight/view_configurations_controller_spec.rb +3 -3
- data/spec/examples.txt +1154 -1136
- data/spec/factories/contact_emails.rb +6 -0
- data/spec/factories/contact_images.rb +1 -1
- data/spec/factories/contacts.rb +1 -1
- data/spec/factories/custom_fields.rb +1 -1
- data/spec/factories/exhibit_thumbnails.rb +1 -1
- data/spec/factories/exhibits.rb +2 -2
- data/spec/factories/featured_images.rb +1 -1
- data/spec/factories/pages.rb +2 -2
- data/spec/factories/reindexing_log_entries.rb +1 -1
- data/spec/factories/resources.rb +1 -1
- data/spec/factories/roles.rb +2 -2
- data/spec/factories/searches.rb +3 -3
- data/spec/factories/tags.rb +3 -3
- data/spec/factories/users.rb +2 -2
- data/spec/features/about_page_spec.rb +6 -6
- data/spec/features/add_contacts_spec.rb +3 -3
- data/spec/features/add_custom_field_metadata_spec.rb +4 -4
- data/spec/features/add_iiif_manifest_spec.rb +2 -2
- data/spec/features/add_items_spec.rb +4 -4
- data/spec/features/autocomplete_typeahead_spec.rb +3 -4
- data/spec/features/browse_category_admin_spec.rb +3 -3
- data/spec/features/browse_category_spec.rb +3 -3
- data/spec/features/catalog_spec.rb +3 -3
- data/spec/features/confirm_email_spec.rb +1 -1
- data/spec/features/create_exhibit_spec.rb +1 -1
- data/spec/features/create_page_spec.rb +5 -5
- data/spec/features/curator_items.rb +2 -2
- data/spec/features/dashboard_spec.rb +4 -4
- data/spec/features/edit_contact_spec.rb +4 -4
- data/spec/features/edit_search_fields_spec.rb +2 -2
- data/spec/features/exhibit_masthead_spec.rb +2 -2
- data/spec/features/exhibit_themes_spec.rb +2 -2
- data/spec/features/exhibits/add_tags_spec.rb +3 -3
- data/spec/features/exhibits/administration_spec.rb +78 -4
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +2 -2
- data/spec/features/exhibits/edit_metadata_fields_spec.rb +2 -2
- data/spec/features/exhibits_index_spec.rb +3 -3
- data/spec/features/feature_page_spec.rb +9 -9
- data/spec/features/home_page_spec.rb +4 -4
- data/spec/features/import_exhibit_spec.rb +2 -2
- data/spec/features/item_admin_spec.rb +2 -2
- data/spec/features/javascript/about_page_admin_spec.rb +2 -2
- data/spec/features/javascript/block_controls_spec.rb +2 -2
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +5 -5
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +4 -4
- data/spec/features/javascript/blocks/link_to_search_block_spec.rb +44 -0
- data/spec/features/javascript/{rule_block_spec.rb → blocks/rule_block_spec.rb} +4 -4
- data/spec/features/javascript/blocks/search_result_block_spec.rb +4 -4
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +5 -6
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +3 -4
- data/spec/features/javascript/edit_in_place_spec.rb +2 -2
- data/spec/features/javascript/feature_page_admin_spec.rb +26 -7
- data/spec/features/javascript/home_page_edit_spec.rb +3 -3
- data/spec/features/javascript/metadata_admin_spec.rb +2 -2
- data/spec/features/javascript/multi_image_select_spec.rb +6 -6
- data/spec/features/javascript/reindex_monitor_spec.rb +4 -4
- data/spec/features/javascript/roles_admin_spec.rb +3 -3
- data/spec/features/javascript/search_config_admin_spec.rb +2 -3
- data/spec/features/javascript/search_context_spec.rb +6 -6
- data/spec/features/main_navigation_spec.rb +2 -2
- data/spec/features/metadata_admin_spec.rb +2 -2
- data/spec/features/report_a_problem_spec.rb +2 -2
- data/spec/features/site_admin_management_spec.rb +4 -4
- data/spec/features/site_masthead_spec.rb +1 -1
- data/spec/features/slideshow_spec.rb +4 -3
- data/spec/features/tags_admin_spec.rb +3 -3
- data/spec/features/user_admin_spec.rb +2 -2
- data/spec/helpers/spotlight/application_helper_spec.rb +2 -2
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +1 -1
- data/spec/helpers/spotlight/main_app_helpers_spec.rb +3 -3
- data/spec/helpers/spotlight/meta_helper_spec.rb +1 -1
- data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +3 -3
- data/spec/jobs/spotlight/reindex_job_spec.rb +3 -3
- data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +1 -1
- data/spec/lib/migration/iiif_spec.rb +3 -3
- data/spec/lib/spotlight/controller_spec.rb +3 -3
- data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +19 -1
- data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +9 -1
- data/spec/models/sir_trevor_rails/blocks/search_results_block_spec.rb +1 -1
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +2 -2
- data/spec/models/spotlight/ability_spec.rb +9 -9
- data/spec/models/spotlight/about_page_spec.rb +1 -1
- data/spec/models/spotlight/access_controls_enforcement_search_builder_spec.rb +1 -1
- data/spec/models/spotlight/blacklight_configuration_spec.rb +15 -1
- data/spec/models/spotlight/contact_email_spec.rb +1 -1
- data/spec/models/spotlight/contact_form_spec.rb +1 -1
- data/spec/models/spotlight/contact_spec.rb +1 -1
- data/spec/models/spotlight/custom_field_spec.rb +5 -5
- data/spec/models/spotlight/exhibit_spec.rb +20 -16
- data/spec/models/spotlight/feature_page_spec.rb +14 -14
- data/spec/models/spotlight/field_metadata_spec.rb +1 -1
- data/spec/models/spotlight/home_page_spec.rb +1 -1
- data/spec/models/spotlight/main_navigation_spec.rb +1 -1
- data/spec/models/spotlight/page_spec.rb +12 -8
- data/spec/models/spotlight/reindex_progress_spec.rb +4 -4
- data/spec/models/spotlight/reindexing_log_entry_spec.rb +8 -8
- data/spec/models/spotlight/resource_spec.rb +12 -1
- data/spec/models/spotlight/resources/iiif_harvester_spec.rb +1 -1
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +1 -1
- data/spec/models/spotlight/resources/upload_spec.rb +3 -3
- data/spec/models/spotlight/role_spec.rb +3 -3
- data/spec/models/spotlight/search_spec.rb +7 -7
- data/spec/models/spotlight/sitemap_spec.rb +6 -6
- data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -1
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +1 -1
- data/spec/serializers/spotlight/exhibit_export_serializer_spec.rb +20 -20
- data/spec/services/spotlight/carrierwave_file_resolver_spec.rb +1 -1
- data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -1
- data/spec/services/spotlight/solr_document_builder_spec.rb +3 -3
- data/spec/spec_helper.rb +4 -5
- data/spec/support/features/test_features_helpers.rb +2 -2
- data/spec/uploaders/spotlight/featured_image_uploader_spec.rb +1 -1
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/shared/_exhibit_navbar.html.erb_spec.rb +9 -9
- data/spec/views/shared/_masthead.html.erb_spec.rb +3 -3
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +4 -4
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/_exhibit_card_front.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +6 -6
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +8 -8
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/pages/_form.html.erb_spec.rb +18 -0
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/search_configurations/_facets.html.erb_spec.rb +14 -2
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +9 -2
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +10 -1
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +8 -8
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +1 -1
- data/spec/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb_spec.rb +18 -0
- data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +2 -2
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +3 -3
- metadata +226 -200
- data/app/assets/stylesheets/spotlight/application.scss +0 -5
- data/vendor/assets/javascripts/leaflet.js +0 -9
- data/vendor/assets/stylesheets/leaflet.css +0 -624
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::AboutPage, type: :model do
|
2
|
-
let(:page) { described_class.create! exhibit:
|
2
|
+
let(:page) { described_class.create! exhibit: FactoryBot.create(:exhibit) }
|
3
3
|
it { is_expected.not_to be_feature_page }
|
4
4
|
it { is_expected.to be_about_page }
|
5
5
|
it 'displays the sidebar' do
|
@@ -14,7 +14,7 @@ describe Spotlight::AccessControlsEnforcementSearchBuilder do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
subject { MockSearchBuilder.new blacklight_params, scope }
|
17
|
-
let(:exhibit) {
|
17
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
18
18
|
let(:scope) { double(current_exhibit: exhibit) }
|
19
19
|
let(:solr_request) { Blacklight::Solr::Request.new }
|
20
20
|
let(:blacklight_params) { Hash.new }
|
@@ -12,7 +12,11 @@ describe Spotlight::BlacklightConfiguration, type: :model do
|
|
12
12
|
config.add_sort_field 'identifier', sort: 'id asc', label: 'Identifier'
|
13
13
|
end
|
14
14
|
allow(subject).to receive_messages default_blacklight_config: blacklight_config
|
15
|
-
subject.exhibit =
|
15
|
+
subject.exhibit = FactoryBot.create(:exhibit)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is expected to be versioned' do
|
19
|
+
is_expected.to be_versioned
|
16
20
|
end
|
17
21
|
|
18
22
|
it 'touches the exhibit' do
|
@@ -336,6 +340,11 @@ describe Spotlight::BlacklightConfiguration, type: :model do
|
|
336
340
|
expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).to include('a', 'c')
|
337
341
|
expect(subject.blacklight_config.sort_fields.select { |_k, v| v.enabled == true }).not_to include('b', 'd')
|
338
342
|
end
|
343
|
+
|
344
|
+
it 'is disabled when enabled = false' do
|
345
|
+
blacklight_config.add_sort_field 'a', enabled: false
|
346
|
+
expect(subject.blacklight_config.sort_fields['a'].enabled).to eq false
|
347
|
+
end
|
339
348
|
end
|
340
349
|
|
341
350
|
describe 'search fields' do
|
@@ -369,6 +378,11 @@ describe Spotlight::BlacklightConfiguration, type: :model do
|
|
369
378
|
blacklight_config.add_search_field 'a', if: false
|
370
379
|
expect(subject.blacklight_config.search_fields['a'].if).to eq false
|
371
380
|
end
|
381
|
+
|
382
|
+
it 'is disabled when enabled = false' do
|
383
|
+
blacklight_config.add_search_field 'a', enabled: false
|
384
|
+
expect(subject.blacklight_config.search_fields['a'].enabled).to eq false
|
385
|
+
end
|
372
386
|
end
|
373
387
|
|
374
388
|
describe 'per page' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Spotlight::ContactForm do
|
2
2
|
subject { described_class.new(name: 'Root', email: 'user@example.com').tap { |c| c.current_exhibit = exhibit } }
|
3
|
-
let(:exhibit) {
|
3
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
4
4
|
let(:honeypot_field_name) { Spotlight::Engine.config.spambot_honeypot_email_field }
|
5
5
|
|
6
6
|
context 'with a site-wide contact email' do
|
@@ -7,7 +7,7 @@ describe Spotlight::CustomField, type: :model do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe 'when the exhibit has a config' do
|
10
|
-
let(:exhibit) {
|
10
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
11
11
|
before { subject.exhibit = exhibit }
|
12
12
|
describe 'that overrides the label' do
|
13
13
|
before do
|
@@ -29,7 +29,7 @@ describe Spotlight::CustomField, type: :model do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'when the exhibit has a config' do
|
32
|
-
let(:exhibit) {
|
32
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
33
33
|
before { subject.exhibit = exhibit }
|
34
34
|
describe 'that overrides the label' do
|
35
35
|
before do
|
@@ -77,7 +77,7 @@ describe Spotlight::CustomField, type: :model do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe '#solr_field' do
|
80
|
-
let(:exhibit) {
|
80
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
81
81
|
let(:custom_field) do
|
82
82
|
described_class.create(exhibit: exhibit, configuration: { 'label' => 'xyz' })
|
83
83
|
end
|
@@ -110,7 +110,7 @@ describe Spotlight::CustomField, type: :model do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
describe '#configured_to_display?' do
|
113
|
-
let(:exhibit) {
|
113
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
114
114
|
before do
|
115
115
|
exhibit.blacklight_configuration.blacklight_config.view = { view_name: {} }
|
116
116
|
subject.exhibit = exhibit
|
@@ -147,7 +147,7 @@ describe Spotlight::CustomField, type: :model do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
describe 'changing the field type' do
|
150
|
-
let(:exhibit) {
|
150
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
151
151
|
before do
|
152
152
|
subject.label = 'xyz'
|
153
153
|
subject.exhibit = exhibit
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::Exhibit, type: :model do
|
2
|
-
subject(:exhibit) {
|
2
|
+
subject(:exhibit) { FactoryBot.build(:exhibit, title: 'Sample') }
|
3
3
|
|
4
4
|
it 'has a title' do
|
5
5
|
subject.title = 'Test title'
|
@@ -46,7 +46,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
describe '#main_navigations' do
|
49
|
-
subject {
|
49
|
+
subject { FactoryBot.create(:exhibit, title: 'Sample') }
|
50
50
|
it 'has main navigations' do
|
51
51
|
expect(subject.main_navigations).to have(3).main_navigations
|
52
52
|
expect(subject.main_navigations.map(&:label).compact).to be_blank
|
@@ -86,7 +86,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
describe '#blacklight_config' do
|
89
|
-
subject {
|
89
|
+
subject { FactoryBot.create(:exhibit) }
|
90
90
|
before do
|
91
91
|
subject.blacklight_configuration.index = { timestamp_field: 'timestamp_field' }
|
92
92
|
subject.save!
|
@@ -99,7 +99,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
describe '#solr_data' do
|
102
|
-
let(:exhibit) {
|
102
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
103
103
|
subject { exhibit.solr_data }
|
104
104
|
|
105
105
|
context 'when not filtering by exhibit' do
|
@@ -133,7 +133,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
describe '#analytics' do
|
136
|
-
subject {
|
136
|
+
subject { FactoryBot.create(:exhibit) }
|
137
137
|
let(:ga_data) { OpenStruct.new(pageviews: 123) }
|
138
138
|
|
139
139
|
before do
|
@@ -147,7 +147,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
describe '#page_analytics' do
|
150
|
-
subject {
|
150
|
+
subject { FactoryBot.create(:exhibit) }
|
151
151
|
let(:ga_data) { [OpenStruct.new(pageviews: 123)] }
|
152
152
|
|
153
153
|
before do
|
@@ -162,7 +162,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
describe '#reindex_later' do
|
165
|
-
subject {
|
165
|
+
subject { FactoryBot.create(:exhibit) }
|
166
166
|
let(:log_entry) { Spotlight::ReindexingLogEntry.new(exhibit: subject, user: user, items_reindexed_count: 0) }
|
167
167
|
|
168
168
|
context 'user is omitted' do
|
@@ -177,7 +177,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
177
177
|
end
|
178
178
|
|
179
179
|
context 'non-nil user is provided' do
|
180
|
-
let(:user) {
|
180
|
+
let(:user) { FactoryBot.build(:user) }
|
181
181
|
|
182
182
|
it 'queues a reindex job for the exhibit, with actual user for the log entry' do
|
183
183
|
expect(subject).to receive(:new_reindexing_log_entry).with(user).and_return(log_entry)
|
@@ -189,7 +189,7 @@ describe Spotlight::Exhibit, type: :model do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
describe '#new_reindexing_log_entry' do
|
192
|
-
let(:user) {
|
192
|
+
let(:user) { FactoryBot.build(:user) }
|
193
193
|
it 'returns a properly configured Spotlight::ReindexingLogEntry instance' do
|
194
194
|
reindexing_log_entry = subject.send(:new_reindexing_log_entry, user)
|
195
195
|
expect(reindexing_log_entry.exhibit).to eq subject
|
@@ -259,8 +259,8 @@ describe Spotlight::Exhibit, type: :model do
|
|
259
259
|
|
260
260
|
describe '#requested_by' do
|
261
261
|
context 'with multiple exhibit users' do
|
262
|
-
let!(:exhibit_admin) {
|
263
|
-
let!(:another_exhibit_admin) {
|
262
|
+
let!(:exhibit_admin) { FactoryBot.create(:exhibit_admin, exhibit: subject) }
|
263
|
+
let!(:another_exhibit_admin) { FactoryBot.create(:exhibit_admin, exhibit: subject) }
|
264
264
|
|
265
265
|
it 'is the first listed user' do
|
266
266
|
expect(subject.requested_by).to eq exhibit_admin
|
@@ -277,16 +277,16 @@ describe Spotlight::Exhibit, type: :model do
|
|
277
277
|
describe '#reindex_progress' do
|
278
278
|
let!(:reindexing_log_entries) do
|
279
279
|
[
|
280
|
-
|
281
|
-
|
280
|
+
FactoryBot.create(:unstarted_reindexing_log_entry, exhibit: exhibit),
|
281
|
+
FactoryBot.create(:reindexing_log_entry, exhibit: exhibit),
|
282
282
|
in_progress_entry,
|
283
|
-
|
284
|
-
|
283
|
+
FactoryBot.create(:failed_reindexing_log_entry, exhibit: exhibit),
|
284
|
+
FactoryBot.create(:unstarted_reindexing_log_entry, exhibit: exhibit)
|
285
285
|
]
|
286
286
|
end
|
287
287
|
|
288
288
|
let(:in_progress_entry) do
|
289
|
-
|
289
|
+
FactoryBot.create(:in_progress_reindexing_log_entry, exhibit: exhibit)
|
290
290
|
end
|
291
291
|
|
292
292
|
it 'returns the latest log entry that is not unstarted' do
|
@@ -295,4 +295,8 @@ describe Spotlight::Exhibit, type: :model do
|
|
295
295
|
expect(reindex_progress.current_log_entry).to eq in_progress_entry
|
296
296
|
end
|
297
297
|
end
|
298
|
+
|
299
|
+
it 'is expected to be versioned' do
|
300
|
+
is_expected.to be_versioned
|
301
|
+
end
|
298
302
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
describe Spotlight::FeaturePage, type: :model do
|
2
|
-
let(:exhibit) {
|
2
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
describe 'default_scope' do
|
4
|
-
let!(:page1) {
|
5
|
-
let!(:page2) {
|
6
|
-
let!(:page3) {
|
4
|
+
let!(:page1) { FactoryBot.create(:feature_page, weight: 5, exhibit: exhibit) }
|
5
|
+
let!(:page2) { FactoryBot.create(:feature_page, weight: 1, exhibit: exhibit) }
|
6
|
+
let!(:page3) { FactoryBot.create(:feature_page, weight: 10, exhibit: exhibit) }
|
7
7
|
it 'orders by weight' do
|
8
8
|
expect(described_class.all.map(&:weight)).to eq [1, 5, 10]
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe 'display_sidebar?' do
|
13
|
-
let(:parent) {
|
14
|
-
let!(:child) {
|
15
|
-
let!(:unpublished_parent) {
|
16
|
-
let!(:unpublished_child) {
|
13
|
+
let(:parent) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
14
|
+
let!(:child) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
15
|
+
let!(:unpublished_parent) { FactoryBot.create(:feature_page, published: false, exhibit: exhibit) }
|
16
|
+
let!(:unpublished_child) { FactoryBot.create(:feature_page, parent_page: unpublished_parent, published: false, exhibit: exhibit) }
|
17
17
|
before { unpublished_parent.display_sidebar = false }
|
18
18
|
it 'is set to true if the page has a published child' do
|
19
19
|
expect(parent.display_sidebar?).to be_truthy
|
@@ -32,9 +32,9 @@ describe Spotlight::FeaturePage, type: :model do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe 'weight' do
|
35
|
-
let(:good_weight) {
|
36
|
-
let(:low_weight) {
|
37
|
-
let(:high_weight) {
|
35
|
+
let(:good_weight) { FactoryBot.build(:feature_page, weight: 10, exhibit: exhibit) }
|
36
|
+
let(:low_weight) { FactoryBot.build(:feature_page, weight: -1, exhibit: exhibit) }
|
37
|
+
let(:high_weight) { FactoryBot.build(:feature_page, weight: 51, exhibit: exhibit) }
|
38
38
|
it 'defaults to 50' do
|
39
39
|
expect(described_class.new.weight).to eq 50
|
40
40
|
end
|
@@ -56,9 +56,9 @@ describe Spotlight::FeaturePage, type: :model do
|
|
56
56
|
it { is_expected.not_to be_about_page }
|
57
57
|
|
58
58
|
describe 'relationships' do
|
59
|
-
let(:parent) {
|
60
|
-
let!(:child1) {
|
61
|
-
let!(:child2) {
|
59
|
+
let(:parent) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
60
|
+
let!(:child1) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
61
|
+
let!(:child2) { FactoryBot.create(:feature_page, parent_page: parent, exhibit: exhibit) }
|
62
62
|
it 'child pages should have a parent_page' do
|
63
63
|
[child1, child2].each do |child|
|
64
64
|
expect(child.parent_page).to eq parent
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::Page, type: :model do
|
2
|
-
let(:exhibit) {
|
2
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
let!(:parent_page) { Spotlight::FeaturePage.create! exhibit: exhibit, published: true }
|
4
4
|
let!(:child_page) { Spotlight::FeaturePage.create! exhibit: exhibit, published: false, parent_page: parent_page }
|
5
5
|
|
@@ -15,6 +15,10 @@ describe Spotlight::Page, type: :model do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'is expected to be versioned' do
|
19
|
+
is_expected.to be_versioned
|
20
|
+
end
|
21
|
+
|
18
22
|
describe '#top_level_page?' do
|
19
23
|
it 'checks if the page is a top-level page' do
|
20
24
|
expect(parent_page).to be_a_top_level_page
|
@@ -37,7 +41,7 @@ describe Spotlight::Page, type: :model do
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
describe 'should_display_title?' do
|
40
|
-
let(:page) {
|
44
|
+
let(:page) { FactoryBot.create(:feature_page) }
|
41
45
|
it 'returns if the title is present or not' do
|
42
46
|
expect(page.title).not_to be_blank
|
43
47
|
expect(page.should_display_title?).to be_truthy
|
@@ -47,7 +51,7 @@ describe Spotlight::Page, type: :model do
|
|
47
51
|
end
|
48
52
|
|
49
53
|
describe '#content=' do
|
50
|
-
let(:page) {
|
54
|
+
let(:page) { FactoryBot.create(:feature_page) }
|
51
55
|
|
52
56
|
it 'works with a serialized JSON array' do
|
53
57
|
page.content = [].to_json
|
@@ -60,7 +64,7 @@ describe Spotlight::Page, type: :model do
|
|
60
64
|
end
|
61
65
|
|
62
66
|
describe '#content?' do
|
63
|
-
let(:page) {
|
67
|
+
let(:page) { FactoryBot.create(:feature_page) }
|
64
68
|
|
65
69
|
it 'does not have content when the page is empty' do
|
66
70
|
page.content = []
|
@@ -74,7 +78,7 @@ describe Spotlight::Page, type: :model do
|
|
74
78
|
end
|
75
79
|
|
76
80
|
describe '#slug' do
|
77
|
-
let(:page) {
|
81
|
+
let(:page) { FactoryBot.create(:feature_page) }
|
78
82
|
|
79
83
|
it 'gets a default slug' do
|
80
84
|
expect(page.slug).not_to be_blank
|
@@ -86,7 +90,7 @@ describe Spotlight::Page, type: :model do
|
|
86
90
|
end
|
87
91
|
|
88
92
|
context 'with a custom slug' do
|
89
|
-
let(:page) {
|
93
|
+
let(:page) { FactoryBot.create(:feature_page, slug: 'xyz') }
|
90
94
|
|
91
95
|
it 'gets a default slug' do
|
92
96
|
expect(page.slug).to eq 'xyz'
|
@@ -95,8 +99,8 @@ describe Spotlight::Page, type: :model do
|
|
95
99
|
end
|
96
100
|
|
97
101
|
describe 'thumbnail_image_url' do
|
98
|
-
subject(:thumbnail) {
|
99
|
-
subject(:page) {
|
102
|
+
subject(:thumbnail) { FactoryBot.create(:featured_image) }
|
103
|
+
subject(:page) { FactoryBot.create(:feature_page, exhibit: exhibit) }
|
100
104
|
|
101
105
|
it 'is nil when there is no thumbnail' do
|
102
106
|
expect(page.thumbnail_image_url).to be_nil
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Spotlight::ReindexProgress, type: :model do
|
2
2
|
let(:reindexing_log_entry) do
|
3
|
-
|
3
|
+
FactoryBot.create(:failed_reindexing_log_entry, items_reindexed_estimate: 12)
|
4
4
|
end
|
5
5
|
|
6
6
|
let(:subject) { described_class.new(reindexing_log_entry) }
|
@@ -64,7 +64,7 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
64
64
|
|
65
65
|
describe '#recently_in_progress?' do
|
66
66
|
context 'there is no end_time for current_log_entry' do
|
67
|
-
let(:reindexing_log_entry) {
|
67
|
+
let(:reindexing_log_entry) { FactoryBot.create(:in_progress_reindexing_log_entry) }
|
68
68
|
|
69
69
|
it 'returns true' do
|
70
70
|
expect(subject).to be_recently_in_progress
|
@@ -72,7 +72,7 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context 'current_log_entry has an end_time less than Spotlight::Engine.config.reindex_progress_window.minutes.ago' do
|
75
|
-
let(:reindexing_log_entry) {
|
75
|
+
let(:reindexing_log_entry) { FactoryBot.create(:recent_reindexing_log_entry, end_time: Time.zone.now) }
|
76
76
|
|
77
77
|
it 'returns true' do
|
78
78
|
expect(subject).to be_recently_in_progress
|
@@ -80,7 +80,7 @@ describe Spotlight::ReindexProgress, type: :model do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'current_log_entry is unstarted ' do
|
83
|
-
let(:reindexing_log_entry) {
|
83
|
+
let(:reindexing_log_entry) { FactoryBot.create(:unstarted_reindexing_log_entry) }
|
84
84
|
|
85
85
|
it 'returns false' do
|
86
86
|
expect(subject).not_to be_recently_in_progress
|
@@ -1,11 +1,11 @@
|
|
1
1
|
describe Spotlight::ReindexingLogEntry, type: :model do
|
2
|
-
subject {
|
2
|
+
subject { FactoryBot.build(:reindexing_log_entry) }
|
3
3
|
|
4
4
|
describe 'scope' do
|
5
5
|
before do
|
6
|
-
(0..10).to_a.each {
|
7
|
-
|
8
|
-
(0..10).to_a.each {
|
6
|
+
(0..10).to_a.each { FactoryBot.create(:recent_reindexing_log_entry) }
|
7
|
+
FactoryBot.create(:unstarted_reindexing_log_entry)
|
8
|
+
(0..10).to_a.each { FactoryBot.create(:recent_reindexing_log_entry) }
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:sorted_log_entry_list) do
|
@@ -37,7 +37,7 @@ describe Spotlight::ReindexingLogEntry, type: :model do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'when end_time is not present' do
|
40
|
-
subject {
|
40
|
+
subject { FactoryBot.build(:in_progress_reindexing_log_entry) }
|
41
41
|
|
42
42
|
it 'is nil' do
|
43
43
|
expect(subject.duration).to be nil
|
@@ -47,7 +47,7 @@ describe Spotlight::ReindexingLogEntry, type: :model do
|
|
47
47
|
|
48
48
|
describe 'state updating methods' do
|
49
49
|
describe '#in_progress!' do
|
50
|
-
subject {
|
50
|
+
subject { FactoryBot.build(:unstarted_reindexing_log_entry) }
|
51
51
|
|
52
52
|
context 'executes normally' do
|
53
53
|
it 'sets start_time and job_status' do
|
@@ -73,7 +73,7 @@ describe Spotlight::ReindexingLogEntry, type: :model do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
describe '#succeeded!' do
|
76
|
-
subject {
|
76
|
+
subject { FactoryBot.build(:in_progress_reindexing_log_entry) }
|
77
77
|
|
78
78
|
context 'executes normally' do
|
79
79
|
it 'sets end_time and job_status' do
|
@@ -99,7 +99,7 @@ describe Spotlight::ReindexingLogEntry, type: :model do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
describe '#failed!' do
|
102
|
-
subject {
|
102
|
+
subject { FactoryBot.build(:in_progress_reindexing_log_entry) }
|
103
103
|
|
104
104
|
context 'executes normally' do
|
105
105
|
it 'sets end_time and job_status' do
|