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
@@ -2,7 +2,7 @@ describe Spotlight::Resource, type: :model do
|
|
2
2
|
before do
|
3
3
|
allow_any_instance_of(described_class).to receive(:update_index)
|
4
4
|
end
|
5
|
-
let(:exhibit) {
|
5
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
6
6
|
|
7
7
|
describe '#reindex' do
|
8
8
|
context 'with a provider that generates ids' do
|
@@ -34,6 +34,17 @@ describe Spotlight::Resource, type: :model do
|
|
34
34
|
subject.reindex
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'when a document does not have an identifier' do
|
38
|
+
let(:solr_response) { { other_field: 'Content' } }
|
39
|
+
|
40
|
+
it 'is not indexed (but a commit can be sent)' do
|
41
|
+
allow(subject.send(:blacklight_solr)).to receive(:commit)
|
42
|
+
expect(subject.send(:blacklight_solr)).not_to receive(:update)
|
43
|
+
|
44
|
+
subject.reindex
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
37
48
|
context 'reindexing_log_entry is provided' do
|
38
49
|
before do
|
39
50
|
allow(subject.send(:blacklight_solr)).to receive(:update)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spotlight::Resources::IiifHarvester do
|
4
|
-
let(:exhibit) {
|
4
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
5
5
|
let(:harvester) { described_class.create(exhibit_id: exhibit.id, url: url) }
|
6
6
|
|
7
7
|
describe 'Validation' do
|
@@ -20,7 +20,7 @@ describe Spotlight::Resources::IiifManifest do
|
|
20
20
|
|
21
21
|
describe '#to_solr' do
|
22
22
|
let(:manifest) { Spotlight::Resources::IiifService.new(url).send(:object) }
|
23
|
-
let(:exhibit) {
|
23
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
24
24
|
describe 'id' do
|
25
25
|
it 'is an MD5 hexdigest of the exhibit id and the and the url' do
|
26
26
|
expected = Digest::MD5.hexdigest("#{exhibit.id}-#{url}")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
describe Spotlight::Resources::Upload, type: :model do
|
3
|
-
let!(:exhibit) {
|
4
|
-
let!(:custom_field) {
|
3
|
+
let!(:exhibit) { FactoryBot.create :exhibit }
|
4
|
+
let!(:custom_field) { FactoryBot.create :custom_field, exhibit: exhibit }
|
5
5
|
let(:resource) { described_class.new(exhibit: exhibit) }
|
6
6
|
let(:doc_builder) { resource.document_builder }
|
7
7
|
|
@@ -16,7 +16,7 @@ describe Spotlight::Resources::Upload, type: :model do
|
|
16
16
|
custom_field.field => 'Custom Field Data'
|
17
17
|
}
|
18
18
|
end
|
19
|
-
let(:featured_image) {
|
19
|
+
let(:featured_image) { FactoryBot.create(:featured_image, image: File.open(File.join(FIXTURES_PATH, '800x600.png'))) }
|
20
20
|
|
21
21
|
before do
|
22
22
|
Rails.cache.clear # wipes out any cached image info.
|
@@ -10,7 +10,7 @@ describe Spotlight::Role, type: :model do
|
|
10
10
|
end
|
11
11
|
describe 'with user_key' do
|
12
12
|
describe "that doesn't point at a user" do
|
13
|
-
let(:user) {
|
13
|
+
let(:user) { FactoryBot.build(:user) }
|
14
14
|
let(:args) { { role: 'curator', user_key: user.email } }
|
15
15
|
it 'does not be valid' do
|
16
16
|
expect(subject).to be_valid
|
@@ -19,7 +19,7 @@ describe Spotlight::Role, type: :model do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
describe 'that points at a user' do
|
22
|
-
let(:user) {
|
22
|
+
let(:user) { FactoryBot.create(:user) }
|
23
23
|
let(:args) { { role: 'curator', user_key: user.email } }
|
24
24
|
it 'is valid' do
|
25
25
|
expect(subject).to be_valid
|
@@ -27,7 +27,7 @@ describe Spotlight::Role, type: :model do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
describe 'that points at a user with an existing role' do
|
30
|
-
let(:user) {
|
30
|
+
let(:user) { FactoryBot.create(:user) }
|
31
31
|
before { described_class.create!(role: 'curator', user: user) }
|
32
32
|
let(:args) { { role: 'curator', user_key: user.email } }
|
33
33
|
it 'is valid' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::Search, type: :model do
|
2
|
-
let(:exhibit) {
|
2
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
|
4
4
|
let(:query_params) { { 'f' => { 'genre_sim' => ['map'] } } }
|
5
5
|
subject { exhibit.searches.build(title: 'Search', query_params: query_params) }
|
@@ -19,16 +19,16 @@ describe Spotlight::Search, type: :model do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'default_scope' do
|
22
|
-
let!(:page1) {
|
23
|
-
let!(:page2) {
|
24
|
-
let!(:page3) {
|
22
|
+
let!(:page1) { FactoryBot.create(:search, weight: 5, published: true) }
|
23
|
+
let!(:page2) { FactoryBot.create(:search, weight: 1, published: true) }
|
24
|
+
let!(:page3) { FactoryBot.create(:search, weight: 10, published: true) }
|
25
25
|
it 'orders by weight' do
|
26
26
|
expect(described_class.published.map(&:weight)).to eq [1, 5, 10]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#slug' do
|
31
|
-
let(:search) {
|
31
|
+
let(:search) { FactoryBot.create(:search) }
|
32
32
|
|
33
33
|
it 'gets a default slug' do
|
34
34
|
expect(search.slug).not_to be_blank
|
@@ -40,7 +40,7 @@ describe Spotlight::Search, type: :model do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with a custom slug' do
|
43
|
-
let(:search) {
|
43
|
+
let(:search) { FactoryBot.create(:search, slug: 'xyz') }
|
44
44
|
|
45
45
|
it 'gets a default slug' do
|
46
46
|
expect(search.slug).to eq 'xyz'
|
@@ -65,7 +65,7 @@ describe Spotlight::Search, type: :model do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#repository' do
|
68
|
-
let(:search) {
|
68
|
+
let(:search) { FactoryBot.create(:search) }
|
69
69
|
before do
|
70
70
|
allow(search).to receive(:blacklight_config).and_return blacklight_config
|
71
71
|
end
|
@@ -2,7 +2,7 @@ require 'sitemap_generator'
|
|
2
2
|
|
3
3
|
describe Spotlight::Sitemap do
|
4
4
|
let(:sitemap) { SitemapGenerator::Interpreter.new }
|
5
|
-
let(:exhibit) {
|
5
|
+
let(:exhibit) { FactoryBot.create(:exhibit, published: true) }
|
6
6
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
7
7
|
let(:sitemap_content) { sitemap.sitemap.sitemap.instance_variable_get(:@xml_content) }
|
8
8
|
let(:url_helpers) { Spotlight::Engine.routes.url_helpers }
|
@@ -18,8 +18,8 @@ describe Spotlight::Sitemap do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '.add_all_exhibits' do
|
21
|
-
let!(:second_exhibit) {
|
22
|
-
let!(:unpublished_exhibit) {
|
21
|
+
let!(:second_exhibit) { FactoryBot.create(:exhibit, published: true) }
|
22
|
+
let!(:unpublished_exhibit) { FactoryBot.create(:exhibit, published: false) }
|
23
23
|
|
24
24
|
it 'builds a sitemap for all published exhibits' do
|
25
25
|
sitemaps = []
|
@@ -73,8 +73,8 @@ describe Spotlight::Sitemap do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
describe '#add_pages' do
|
76
|
-
let!(:feature_page) {
|
77
|
-
let!(:about_page) {
|
76
|
+
let!(:feature_page) { FactoryBot.create(:feature_page, exhibit: exhibit, published: true) }
|
77
|
+
let!(:about_page) { FactoryBot.create(:about_page, exhibit: exhibit, published: true) }
|
78
78
|
|
79
79
|
it 'adds feature pages' do
|
80
80
|
subject.add_pages
|
@@ -101,7 +101,7 @@ describe Spotlight::Sitemap do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
describe '#add_browse_categories' do
|
104
|
-
let!(:search) {
|
104
|
+
let!(:search) { FactoryBot.create(:published_search, exhibit: exhibit) }
|
105
105
|
|
106
106
|
it 'adds browse categories to the sitemap' do
|
107
107
|
subject.add_browse_categories
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::SolrDocumentSidecar, type: :model do
|
2
|
-
let(:exhibit) {
|
2
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
before do
|
4
4
|
allow(subject).to receive_messages exhibit: exhibit
|
5
5
|
allow(subject).to receive_messages document: SolrDocument.new(id: 'doc_id')
|
@@ -2,7 +2,7 @@ describe Spotlight::IiifManifestPresenter do
|
|
2
2
|
require 'iiif_manifest'
|
3
3
|
|
4
4
|
let(:resource) { SolrDocument.new(id: '1-1') }
|
5
|
-
let(:uploaded_resource) {
|
5
|
+
let(:uploaded_resource) { FactoryBot.build(:uploaded_resource) }
|
6
6
|
let(:controller) { double(Spotlight::CatalogController) }
|
7
7
|
|
8
8
|
let(:subject) { described_class.new(resource, controller) }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::ExhibitExportSerializer do
|
2
|
-
let!(:source_exhibit) {
|
2
|
+
let!(:source_exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
|
4
4
|
before do
|
5
5
|
allow_any_instance_of(Spotlight::Search).to receive(:set_default_featured_image)
|
@@ -82,7 +82,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
subject do
|
85
|
-
e =
|
85
|
+
e = FactoryBot.create(:exhibit)
|
86
86
|
e.import(export).tap(&:save)
|
87
87
|
end
|
88
88
|
|
@@ -124,9 +124,9 @@ describe Spotlight::ExhibitExportSerializer do
|
|
124
124
|
context 'for an exhibit with contacts' do
|
125
125
|
context 'for a contact with an avatar' do
|
126
126
|
let!(:curator) do
|
127
|
-
|
128
|
-
|
129
|
-
|
127
|
+
FactoryBot.create(:contact, :with_avatar,
|
128
|
+
exhibit: source_exhibit,
|
129
|
+
contact_info: { title: 'xyz' })
|
130
130
|
end
|
131
131
|
it 'has contacts' do
|
132
132
|
expect(subject.contacts.count).to eq 1
|
@@ -138,7 +138,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
138
138
|
|
139
139
|
context 'for a contact without an avatar' do
|
140
140
|
let!(:curator) do
|
141
|
-
|
141
|
+
FactoryBot.create(:contact, exhibit: source_exhibit, avatar: nil)
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'has contacts' do
|
@@ -166,13 +166,13 @@ describe Spotlight::ExhibitExportSerializer do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'deals with nested feature pages' do
|
169
|
-
|
169
|
+
FactoryBot.create :feature_subpage, exhibit: source_exhibit
|
170
170
|
expect(subject.feature_pages.at_top_level.length).to eq 1
|
171
171
|
expect(subject.feature_pages.first.child_pages.length).to eq 1
|
172
172
|
end
|
173
173
|
|
174
174
|
context 'page slugs' do
|
175
|
-
let!(:feature_page) {
|
175
|
+
let!(:feature_page) { FactoryBot.create(:feature_page, exhibit: source_exhibit, slug: 'xyz') }
|
176
176
|
|
177
177
|
it 'uses the existing slug for the page' do
|
178
178
|
expect(subject.feature_pages.find('xyz')).to be_persisted
|
@@ -180,8 +180,8 @@ describe Spotlight::ExhibitExportSerializer do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
context 'with a feature page' do
|
183
|
-
let(:feature_page) {
|
184
|
-
let(:thumbnail) {
|
183
|
+
let(:feature_page) { FactoryBot.create(:feature_page, exhibit: source_exhibit) }
|
184
|
+
let(:thumbnail) { FactoryBot.create(:featured_image) }
|
185
185
|
|
186
186
|
before do
|
187
187
|
feature_page.content = { data: [{ type: 'text', data: { text: 'xyz' } }] }.to_json
|
@@ -207,23 +207,23 @@ describe Spotlight::ExhibitExportSerializer do
|
|
207
207
|
end
|
208
208
|
|
209
209
|
it 'assigns STI resources the correct class' do
|
210
|
-
resource =
|
210
|
+
resource = FactoryBot.create :uploaded_resource, exhibit: source_exhibit
|
211
211
|
expect(subject.resources.length).to eq 1
|
212
212
|
expect(subject.resources.first.class).to eq Spotlight::Resources::Upload
|
213
213
|
expect(subject.resources.first.upload.image.path).not_to eq resource.upload.image.path
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'assigns normal resources the correct class' do
|
217
|
-
resource =
|
217
|
+
resource = FactoryBot.create :resource, exhibit: source_exhibit
|
218
218
|
expect(subject.resources.length).to eq 1
|
219
219
|
expect(subject.resources.first.class).to eq Spotlight::Resource
|
220
220
|
expect(subject.resources.first.url).to eq resource.url
|
221
221
|
end
|
222
222
|
|
223
223
|
context 'with a browse category' do
|
224
|
-
let(:masthead) {
|
225
|
-
let(:thumbnail) {
|
226
|
-
let!(:search) {
|
224
|
+
let(:masthead) { FactoryBot.create(:masthead) }
|
225
|
+
let(:thumbnail) { FactoryBot.create(:featured_image) }
|
226
|
+
let!(:search) { FactoryBot.create(:search, exhibit: source_exhibit, masthead: masthead, thumbnail: thumbnail) }
|
227
227
|
|
228
228
|
before do
|
229
229
|
source_exhibit.reload
|
@@ -267,7 +267,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
267
267
|
end
|
268
268
|
|
269
269
|
context 'with a masthead' do
|
270
|
-
let!(:masthead) {
|
270
|
+
let!(:masthead) { FactoryBot.create(:masthead) }
|
271
271
|
|
272
272
|
before do
|
273
273
|
source_exhibit.masthead = masthead
|
@@ -280,7 +280,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
280
280
|
end
|
281
281
|
|
282
282
|
context 'with a thumbnail' do
|
283
|
-
let!(:thumbnail) {
|
283
|
+
let!(:thumbnail) { FactoryBot.create(:exhibit_thumbnail) }
|
284
284
|
|
285
285
|
before do
|
286
286
|
source_exhibit.thumbnail = thumbnail
|
@@ -294,9 +294,9 @@ describe Spotlight::ExhibitExportSerializer do
|
|
294
294
|
end
|
295
295
|
|
296
296
|
it 'is idempotent-ish' do
|
297
|
-
|
297
|
+
FactoryBot.create :feature_subpage, exhibit: source_exhibit
|
298
298
|
export = described_class.new(source_exhibit).as_json
|
299
|
-
e =
|
299
|
+
e = FactoryBot.create(:exhibit)
|
300
300
|
e.import(export).tap(&:save)
|
301
301
|
e.import(export).tap(&:save)
|
302
302
|
end
|
@@ -315,7 +315,7 @@ describe Spotlight::ExhibitExportSerializer do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
subject do
|
318
|
-
e =
|
318
|
+
e = FactoryBot.create(:exhibit)
|
319
319
|
e.import(export).tap(&:save)
|
320
320
|
end
|
321
321
|
|
@@ -6,7 +6,7 @@ describe Spotlight::IiifResourceResolver do
|
|
6
6
|
end
|
7
7
|
let(:iiif_manifest_url) { 'https://purl.stanford.edu/gk446cj2442/manifest.json' }
|
8
8
|
let(:resource) do
|
9
|
-
|
9
|
+
FactoryBot.create(
|
10
10
|
:featured_image,
|
11
11
|
iiif_manifest_url: iiif_manifest_url,
|
12
12
|
iiif_image_id: 'https://purl.stanford.edu/gk446cj2442/iiif/annotation/gk446cj2442_1',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::SolrDocumentBuilder do
|
2
|
-
let(:exhibit) {
|
2
|
+
let(:exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
let(:doc_builder) { described_class.new(resource) }
|
4
4
|
let(:resource) { Spotlight::Resource.new }
|
5
5
|
|
@@ -18,8 +18,8 @@ describe Spotlight::SolrDocumentBuilder do
|
|
18
18
|
describe '#documents_to_index' do
|
19
19
|
context 'when the document belongs to more than one exhibit' do
|
20
20
|
let(:doc) { SolrDocument.new(id: 'abc123') }
|
21
|
-
let(:resource) {
|
22
|
-
let(:resource_alt) {
|
21
|
+
let(:resource) { FactoryBot.create(:resource) }
|
22
|
+
let(:resource_alt) { FactoryBot.create(:resource) }
|
23
23
|
subject { resource.document_builder }
|
24
24
|
|
25
25
|
before do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
require '
|
2
|
+
require 'factory_bot'
|
3
3
|
require 'database_cleaner'
|
4
4
|
require 'devise'
|
5
5
|
require 'engine_cart'
|
@@ -12,6 +12,7 @@ require 'rspec/collection_matchers'
|
|
12
12
|
require 'rspec/its'
|
13
13
|
require 'rspec/rails'
|
14
14
|
require 'rspec/active_model/mocks'
|
15
|
+
require 'paper_trail/frameworks/rspec'
|
15
16
|
|
16
17
|
require 'selenium-webdriver'
|
17
18
|
|
@@ -45,8 +46,8 @@ Spotlight::Engine.config.exhibit_themes = %w(default modern)
|
|
45
46
|
|
46
47
|
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
FactoryBot.definition_file_paths = [File.expand_path('../factories', __FILE__)]
|
50
|
+
FactoryBot.find_definitions
|
50
51
|
|
51
52
|
FIXTURES_PATH = File.expand_path('../fixtures', __FILE__)
|
52
53
|
|
@@ -72,8 +73,6 @@ RSpec.configure do |config|
|
|
72
73
|
DatabaseCleaner.clean
|
73
74
|
end
|
74
75
|
|
75
|
-
config.filter_run_excluding js: true if ENV['CI']
|
76
|
-
|
77
76
|
if defined? Devise::Test::ControllerHelpers
|
78
77
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
79
78
|
config.include Devise::Test::ControllerHelpers, type: :view
|
@@ -24,10 +24,10 @@ module Spotlight
|
|
24
24
|
def click_add_widget
|
25
25
|
unless all('.st-block-replacer').present?
|
26
26
|
expect(page).to have_css('.st-block-addition')
|
27
|
-
first('.st-block-addition').
|
27
|
+
first('.st-block-addition').click
|
28
28
|
end
|
29
29
|
expect(page).to have_css('.st-block-replacer')
|
30
|
-
first('.st-block-replacer').
|
30
|
+
first('.st-block-replacer').click
|
31
31
|
end
|
32
32
|
|
33
33
|
def save_page
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Spotlight::FeaturedImageUploader do
|
2
|
-
let(:mounter) {
|
2
|
+
let(:mounter) { FactoryBot.create(:featured_image) }
|
3
3
|
subject(:featured_image_uploader) { described_class.new(mounter, 'mounted_as') }
|
4
4
|
|
5
5
|
describe '#extension_whitelist' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe '_user_util_links', type: :view do
|
2
|
-
let(:current_exhibit) {
|
2
|
+
let(:current_exhibit) { FactoryBot.create(:exhibit) }
|
3
3
|
before do
|
4
4
|
allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
|
5
5
|
allow(view).to receive(:current_user).and_return(current_user)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
describe 'shared/_exhibit_navbar', type: :view do
|
2
|
-
let(:current_exhibit) {
|
3
|
-
let(:feature_page) {
|
4
|
-
let(:unpublished_feature_page) {
|
5
|
-
let(:about_page) {
|
6
|
-
let(:unpublished_about_page) {
|
2
|
+
let(:current_exhibit) { FactoryBot.create(:exhibit) }
|
3
|
+
let(:feature_page) { FactoryBot.create(:feature_page, exhibit: current_exhibit) }
|
4
|
+
let(:unpublished_feature_page) { FactoryBot.create(:feature_page, published: false, exhibit: current_exhibit) }
|
5
|
+
let(:about_page) { FactoryBot.create(:about_page, exhibit: current_exhibit) }
|
6
|
+
let(:unpublished_about_page) { FactoryBot.create(:about_page, published: false, exhibit: current_exhibit) }
|
7
7
|
|
8
8
|
before do
|
9
9
|
allow(view).to receive_messages(resource_masthead?: false)
|
@@ -38,7 +38,7 @@ describe 'shared/_exhibit_navbar', type: :view do
|
|
38
38
|
|
39
39
|
it 'provides a dropdown of multiple feature pages' do
|
40
40
|
feature_page
|
41
|
-
another_page =
|
41
|
+
another_page = FactoryBot.create(:feature_page, exhibit: current_exhibit)
|
42
42
|
render
|
43
43
|
expect(response).to have_selector '.dropdown .dropdown-toggle', text: 'Curated Features'
|
44
44
|
expect(response).to have_link feature_page.title, visible: false, href: spotlight.exhibit_feature_page_path(current_exhibit, feature_page)
|
@@ -57,13 +57,13 @@ describe 'shared/_exhibit_navbar', type: :view do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "links to the browse index if there's a published search" do
|
60
|
-
|
60
|
+
FactoryBot.create :published_search, exhibit: current_exhibit
|
61
61
|
render
|
62
62
|
expect(response).to have_link 'Browse', href: spotlight.exhibit_browse_index_path(current_exhibit)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "marks the browse button as active if we're on a browse page" do
|
66
|
-
|
66
|
+
FactoryBot.create :published_search, exhibit: current_exhibit
|
67
67
|
allow(view).to receive_messages(on_browse_page?: true)
|
68
68
|
render
|
69
69
|
expect(response).to have_selector 'li.active', text: 'Browse'
|
@@ -75,7 +75,7 @@ describe 'shared/_exhibit_navbar', type: :view do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'does not link to the browse index if only private categories are defined' do
|
78
|
-
|
78
|
+
FactoryBot.create :search, exhibit: current_exhibit
|
79
79
|
render
|
80
80
|
expect(response).not_to have_link 'Browse'
|
81
81
|
end
|