blacklight-spotlight 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/edit_in_place.js +8 -1
  3. data/app/helpers/spotlight/pages_helper.rb +4 -0
  4. data/app/models/spotlight/blacklight_configuration.rb +12 -9
  5. data/app/models/spotlight/page_configurations.rb +93 -0
  6. data/app/services/spotlight/clone_translated_page_from_locale.rb +2 -4
  7. data/app/views/spotlight/pages/_form.html.erb +1 -12
  8. data/lib/generators/spotlight/install_generator.rb +1 -11
  9. data/lib/generators/spotlight/scaffold_resource_generator.rb +1 -1
  10. data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +5 -0
  11. data/lib/spotlight/engine.rb +4 -0
  12. data/lib/spotlight/version.rb +1 -1
  13. data/spec/controllers/spotlight/about_pages_controller_spec.rb +6 -0
  14. data/spec/controllers/spotlight/admin_users_controller_spec.rb +2 -0
  15. data/spec/controllers/spotlight/browse_controller_spec.rb +2 -0
  16. data/spec/controllers/spotlight/catalog_controller_spec.rb +5 -0
  17. data/spec/controllers/spotlight/confirmations_controller_spec.rb +1 -0
  18. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +1 -0
  19. data/spec/controllers/spotlight/contacts_controller_spec.rb +4 -0
  20. data/spec/controllers/spotlight/dashboards_controller_spec.rb +2 -1
  21. data/spec/controllers/spotlight/feature_pages_controller_spec.rb +2 -0
  22. data/spec/controllers/spotlight/filters_controller_spec.rb +2 -0
  23. data/spec/controllers/spotlight/home_pages_controller_spec.rb +2 -0
  24. data/spec/controllers/spotlight/languages_controller_spec.rb +2 -0
  25. data/spec/controllers/spotlight/pages_controller_spec.rb +1 -0
  26. data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +1 -1
  27. data/spec/controllers/spotlight/resources/upload_controller_spec.rb +1 -1
  28. data/spec/controllers/spotlight/roles_controller_spec.rb +2 -0
  29. data/spec/controllers/spotlight/searches_controller_spec.rb +2 -0
  30. data/spec/controllers/spotlight/sites_controller_spec.rb +1 -0
  31. data/spec/controllers/spotlight/solr_controller_spec.rb +1 -0
  32. data/spec/controllers/spotlight/tags_controller_spec.rb +2 -0
  33. data/spec/controllers/spotlight/translations_controller_spec.rb +2 -0
  34. data/spec/examples.txt +1228 -1291
  35. data/spec/features/about_page_spec.rb +2 -0
  36. data/spec/features/add_contacts_spec.rb +1 -0
  37. data/spec/features/browse_category_admin_spec.rb +4 -0
  38. data/spec/features/edit_contact_spec.rb +1 -0
  39. data/spec/features/exhibit_masthead_spec.rb +1 -0
  40. data/spec/features/exhibit_themes_spec.rb +1 -0
  41. data/spec/features/exhibits/add_tags_spec.rb +0 -1
  42. data/spec/features/exhibits/custom_metadata_fields_spec.rb +0 -1
  43. data/spec/features/exhibits/edit_metadata_fields_spec.rb +0 -1
  44. data/spec/features/exhibits/language_create_edit_spec.rb +3 -0
  45. data/spec/features/exhibits/translation_editing_spec.rb +6 -0
  46. data/spec/features/feature_page_spec.rb +9 -0
  47. data/spec/features/home_page_spec.rb +2 -0
  48. data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +0 -1
  49. data/spec/features/javascript/blocks/featured_pages_block_spec.rb +0 -1
  50. data/spec/features/javascript/blocks/search_result_block_spec.rb +0 -1
  51. data/spec/features/javascript/edit_in_place_spec.rb +28 -0
  52. data/spec/features/javascript/metadata_admin_spec.rb +1 -0
  53. data/spec/features/slideshow_spec.rb +1 -0
  54. data/spec/features/translation_scope_spec.rb +1 -0
  55. data/spec/helpers/spotlight/application_helper_spec.rb +3 -0
  56. data/spec/helpers/spotlight/languages_helper_spec.rb +1 -0
  57. data/spec/helpers/spotlight/main_app_helpers_spec.rb +8 -1
  58. data/spec/helpers/spotlight/navbar_helper_spec.rb +1 -0
  59. data/spec/helpers/spotlight/pages_helper_spec.rb +1 -0
  60. data/spec/jobs/spotlight/default_thumbnail_job_spec.rb +0 -1
  61. data/spec/jobs/spotlight/reindex_job_spec.rb +0 -1
  62. data/spec/jobs/spotlight/rename_sidecar_field_job_spec.rb +0 -1
  63. data/spec/lib/migration/page_language_spec.rb +1 -0
  64. data/spec/lib/spotlight/controller_spec.rb +1 -1
  65. data/spec/mailers/spotlight/indexing_complete_mailer_spec.rb +0 -1
  66. data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +1 -1
  67. data/spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb +1 -0
  68. data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +0 -1
  69. data/spec/models/sir_trevor_rails/blocks/textable_spec.rb +2 -1
  70. data/spec/models/spotlight/ability_spec.rb +1 -0
  71. data/spec/models/spotlight/analytics/ga_spec.rb +0 -1
  72. data/spec/models/spotlight/blacklight_configuration_spec.rb +17 -5
  73. data/spec/models/spotlight/contact_email_spec.rb +2 -0
  74. data/spec/models/spotlight/contact_form_spec.rb +1 -0
  75. data/spec/models/spotlight/contact_spec.rb +1 -0
  76. data/spec/models/spotlight/custom_field_spec.rb +7 -1
  77. data/spec/models/spotlight/exhibit_spec.rb +6 -0
  78. data/spec/models/spotlight/feature_page_spec.rb +1 -0
  79. data/spec/models/spotlight/featured_image_spec.rb +2 -0
  80. data/spec/models/spotlight/home_page_spec.rb +2 -0
  81. data/spec/models/spotlight/masthead_spec.rb +2 -0
  82. data/spec/models/spotlight/page_configurations_spec.rb +44 -0
  83. data/spec/models/spotlight/page_spec.rb +2 -0
  84. data/spec/models/spotlight/resource_spec.rb +1 -0
  85. data/spec/models/spotlight/resources/iiif_harvester_spec.rb +4 -0
  86. data/spec/models/spotlight/resources/upload_spec.rb +0 -1
  87. data/spec/models/spotlight/role_spec.rb +4 -0
  88. data/spec/models/spotlight/search_spec.rb +1 -0
  89. data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +0 -1
  90. data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +1 -0
  91. data/spec/services/spotlight/clone_translated_page_from_locale_spec.rb +4 -4
  92. data/spec/services/spotlight/iiif_resource_resolver_spec.rb +1 -0
  93. data/spec/services/spotlight/solr_document_builder_spec.rb +1 -0
  94. data/spec/test_app_templates/Gemfile.extra +0 -4
  95. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  96. data/spec/views/_user_util_links.html.erb_spec.rb +4 -0
  97. data/spec/views/shared/_header_navbar.html.erb_spec.rb +1 -0
  98. data/spec/views/shared/_masthead.html.erb_spec.rb +1 -0
  99. data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +2 -1
  100. data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +0 -1
  101. data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +0 -1
  102. data/spec/views/spotlight/browse/_search.html.erb_spec.rb +0 -1
  103. data/spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb +0 -1
  104. data/spec/views/spotlight/browse/index.html.erb_spec.rb +0 -1
  105. data/spec/views/spotlight/browse/show.html.erb_spec.rb +0 -1
  106. data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +0 -1
  107. data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +1 -0
  108. data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +0 -1
  109. data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +0 -1
  110. data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +0 -1
  111. data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +0 -1
  112. data/spec/views/spotlight/exhibits/_exhibit_card_front.html.erb_spec.rb +0 -1
  113. data/spec/views/spotlight/exhibits/_form.html.erb_spec.rb +2 -0
  114. data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +2 -1
  115. data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +0 -1
  116. data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +1 -1
  117. data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +0 -1
  118. data/spec/views/spotlight/pages/_form.html.erb_spec.rb +2 -3
  119. data/spec/views/spotlight/pages/edit.html.erb_spec.rb +2 -3
  120. data/spec/views/spotlight/pages/index.html.erb_spec.rb +0 -1
  121. data/spec/views/spotlight/pages/new.html.erb_spec.rb +2 -3
  122. data/spec/views/spotlight/resources/_external_resources_form.html.erb_spec.rb +0 -1
  123. data/spec/views/spotlight/resources/new.html.erb_spec.rb +0 -1
  124. data/spec/views/spotlight/searches/_search.html.erb_spec.rb +0 -1
  125. data/spec/views/spotlight/searches/index.html.erb_spec.rb +0 -1
  126. data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +0 -1
  127. data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +0 -1
  128. data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +0 -1
  129. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +0 -1
  130. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +0 -1
  131. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +0 -1
  132. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +0 -1
  133. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +0 -1
  134. data/spec/views/spotlight/tags/index.html.erb_spec.rb +1 -1
  135. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c0fb43a8a3a60dd1e31fde7e191562200b1148d
4
- data.tar.gz: 4c26246903d9d70696b89766028a164061962bae
3
+ metadata.gz: f7c4a7bf6db4fd61a7e41fdc1dd1fe6893ef2ce0
4
+ data.tar.gz: 6c51f46a9d55b5168a13634f4fabb88963ac7402
5
5
  SHA512:
6
- metadata.gz: 7e3c2f5dac310fd1282fe465f927494aaee51b0fb3686cde48fbd347b4f77072cdb1f0d1052ad603eaca82cf8782f7f9c53f8a8625cb1e050e67e4c5e6f1bd78
7
- data.tar.gz: de18c76cddbda5fec50711cdb3e677c8a01d15cd5b54bc8df07539c7b8bf118ed4c8b90c8e7d7c7f38d34efad26db3034fb9684b6ca05f715ac90ebbd21ddaef
6
+ metadata.gz: 1462c3e39927121d923fae715aa7d33fa0adc1637876471396d5aa06f9b274b42b076dd982ac60a00e9ccf8c4fd1fbc737c24074c61fa35dfeea522e4f730ed1
7
+ data.tar.gz: 7bd822f149c8c47af86cc28d6b6df759dc6e98f7e55396a426b731d55b93cadc3b8347933ad38b502e0a6a327c098267ecaf976395d9ff8350655056a312785e
@@ -29,7 +29,14 @@ Spotlight.onLoad(function() {
29
29
  });
30
30
 
31
31
  $input.on('blur.inplaceedit', function() {
32
- $label.text($input.val());
32
+ var value = $input.val();
33
+
34
+ if ($.trim(value).length == 0) {
35
+ $input.val($label.text());
36
+ } else {
37
+ $label.text(value);
38
+ }
39
+
33
40
  $label.show();
34
41
  $input.attr('type', 'hidden');
35
42
  // when leaving edit mode, should no longer hide edit-in-place affordance icon
@@ -58,5 +58,9 @@ module Spotlight
58
58
  def render_contact_email_address(address)
59
59
  mail_to address, address
60
60
  end
61
+
62
+ def configurations_for_current_page
63
+ Spotlight::PageConfigurations.new(context: self, page: @page).as_json
64
+ end
61
65
  end
62
66
  end
@@ -84,7 +84,7 @@ module Spotlight
84
84
  config.view.embed.locals ||= { osd_container_class: '' }
85
85
 
86
86
  # Add any custom fields
87
- config.index_fields.merge! custom_index_fields
87
+ config.index_fields.merge! custom_index_fields(config)
88
88
  config.index_fields = Hash[config.index_fields.sort_by { |k, _v| field_weight(index_fields, k) }]
89
89
  config.index_fields.reject! { |_k, v| v.if == false }
90
90
 
@@ -93,7 +93,7 @@ module Spotlight
93
93
  v.original = v.dup
94
94
  if index_fields[k]
95
95
  v.merge! index_fields[k].symbolize_keys
96
- elsif custom_index_fields[k]
96
+ elsif v.custom_field
97
97
  set_custom_field_defaults(v)
98
98
  else
99
99
  set_index_field_defaults(v)
@@ -198,12 +198,15 @@ module Spotlight
198
198
  end
199
199
  # rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
200
200
 
201
- def custom_index_fields
202
- Hash[exhibit.custom_fields.reject(&:new_record?).map do |x|
203
- field = Blacklight::Configuration::IndexField.new x.configuration.merge(
204
- key: x.field, field: x.solr_field, custom_field: true
201
+ def custom_index_fields(blacklight_config)
202
+ Hash[exhibit.custom_fields.reject(&:new_record?).map do |custom_field|
203
+ original_config = blacklight_config.index_fields[custom_field.field] || {}
204
+ field = Blacklight::Configuration::IndexField.new original_config.merge(
205
+ custom_field.configuration.merge(
206
+ key: custom_field.field, field: custom_field.solr_field, custom_field: true
207
+ )
205
208
  )
206
- [x.field, field]
209
+ [custom_field.field, field]
207
210
  end]
208
211
  end
209
212
 
@@ -338,8 +341,8 @@ module Spotlight
338
341
  end
339
342
 
340
343
  def set_custom_field_defaults(field)
341
- field.show = true
342
- field.enabled = true
344
+ field.show = true if field.show.nil?
345
+ field.enabled = true if field.enabled.nil?
343
346
  end
344
347
  # rubocop:enable Naming/AccessorMethodName
345
348
 
@@ -0,0 +1,93 @@
1
+ module Spotlight
2
+ ##
3
+ # PageConfigurations is a simple class to gather and return all
4
+ # configurations needed for the various SirTrevor widgets.
5
+ # A downstream application (or gem) can inject its own data through the Spotlight's engine config like so
6
+ # Spotlight::Engine.config.page_configurations = {
7
+ # 'my-key': 'my_val'
8
+ # }
9
+ # You can also pass anything that responds to #call (eg. a lambda or custom ruby class)
10
+ # as the value and it will be evaluted within the PageConfiguration context
11
+ # (which has access to the view context).
12
+ # Spotlight::Engine.config.page_configurations = {
13
+ # 'exhibit-path': ->(context) { context.spotlight.exhibit_path(context.current_exhibit) }
14
+ # }
15
+ class PageConfigurations
16
+ delegate :available_view_fields,
17
+ :blacklight_config,
18
+ :current_exhibit,
19
+ :document_show_link_field,
20
+ :index_fields,
21
+ :index_field_label,
22
+ :spotlight,
23
+ :t,
24
+ :view_label,
25
+ to: :context
26
+
27
+ attr_reader :context, :page
28
+ def initialize(context:, page:)
29
+ @context = context
30
+ @page = page
31
+ end
32
+
33
+ def as_json(*)
34
+ {
35
+ 'blacklight-configuration-index-fields': available_index_fields,
36
+ 'blacklight-configuration-search-views': available_view_configs,
37
+ 'attachment-endpoint': attachment_endpoint,
38
+ 'autocomplete-exhibit-catalog-path': exhibit_autocomplete_endpoint,
39
+ 'autocomplete-exhibit-pages-path': page_autocomplete_endpoint,
40
+ 'autocomplete-exhibit-searches-path': search_autocomplete_endpoint,
41
+ 'preview-url': page_preview_url
42
+ }.merge(downstream_parameters)
43
+ end
44
+
45
+ private
46
+
47
+ def available_index_fields
48
+ fields = blacklight_config.index_fields.map { |k, _v| { key: k, label: index_field_label(nil, k) } }
49
+ fields.unshift(key: document_show_link_field, label: t(:'spotlight.pages.form.title_placeholder')) unless index_fields.include? document_show_link_field
50
+
51
+ fields
52
+ end
53
+
54
+ def available_view_configs
55
+ available_view_fields.map { |k, _| { key: k, label: view_label(k) } }
56
+ end
57
+
58
+ def attachment_endpoint
59
+ spotlight.exhibit_attachments_path(current_exhibit)
60
+ end
61
+
62
+ def exhibit_autocomplete_endpoint
63
+ spotlight.autocomplete_exhibit_catalog_path(current_exhibit, q: '%QUERY', format: 'json')
64
+ end
65
+
66
+ def page_autocomplete_endpoint
67
+ spotlight.exhibit_pages_path(current_exhibit, format: 'json')
68
+ end
69
+
70
+ def search_autocomplete_endpoint
71
+ spotlight.exhibit_searches_path(current_exhibit, format: 'json')
72
+ end
73
+
74
+ def page_preview_url
75
+ return unless page.persisted?
76
+ spotlight.exhibit_preview_block_path(current_exhibit, page)
77
+ end
78
+
79
+ def downstream_parameters
80
+ configured_params.each_with_object({}) do |(key, value), hsh|
81
+ hsh[key] = if value.respond_to?(:call)
82
+ value.call(self)
83
+ else
84
+ value
85
+ end
86
+ end
87
+ end
88
+
89
+ def configured_params
90
+ Spotlight::Engine.config.page_configurations || {}
91
+ end
92
+ end
93
+ end
@@ -17,10 +17,8 @@ module Spotlight
17
17
  end
18
18
 
19
19
  def clone
20
- @clone ||= begin
21
- destroy
22
- page.clone_for_locale(locale)
23
- end
20
+ destroy
21
+ page.clone_for_locale(locale)
24
22
  end
25
23
 
26
24
  private
@@ -2,18 +2,7 @@
2
2
  # TODO: the "if @page.persisted?" business below could possibly be done w/ some clever polymorphic routing.
3
3
  # Leaving as-is for now since technically you can't get to the new page form anyway.
4
4
  %>
5
- <%= bootstrap_form_for([spotlight, @page.exhibit, @page], role: 'form', html: {
6
- data: {
7
- :'form-observer' => true,
8
- :'blacklight-configuration-index-fields' => available_index_fields,
9
- :'blacklight-configuration-search-views' => available_view_fields.map { |k,v| { key: k, label: view_label(k) }},
10
- :'attachment-endpoint' => spotlight.exhibit_attachments_path(@page.exhibit),
11
- :'autocomplete-exhibit-catalog-path'=> spotlight.autocomplete_exhibit_catalog_path(@page.exhibit, q: "%QUERY", format: "json"),
12
- :'autocomplete-exhibit-pages-path' => spotlight.exhibit_pages_path(@page.exhibit, format: "json"),
13
- :'autocomplete-exhibit-searches-path' => spotlight.exhibit_searches_path(@page.exhibit, format: "json"),
14
- :'preview-url' => (spotlight.exhibit_preview_block_url(@page.exhibit, @page) if @page.persisted?)
15
- }
16
- }) do |f| %>
5
+ <%= bootstrap_form_for([spotlight, @page.exhibit, @page], role: 'form', html: { data: configurations_for_current_page.merge('form-observer': true)}) do |f| %>
17
6
  <%= render @page.lock if @page.lock and not @page.lock.stale? and not @page.lock.current_session? %>
18
7
  <% if @page.errors.any? %>
19
8
  <div id="error_explanation">
@@ -33,16 +33,6 @@ module Spotlight
33
33
  generate 'paper_trail:install'
34
34
  end
35
35
 
36
- # Overriding paper trail initializer to turn track_associations off
37
- # This was off by default prior to paper trail 9.1.0 but is now generated as on
38
- def override_paper_trail_initializer
39
- gsub_file(
40
- 'config/initializers/paper_trail.rb',
41
- 'PaperTrail.config.track_associations = true',
42
- 'PaperTrail.config.track_associations = false'
43
- )
44
- end
45
-
46
36
  def sitemaps
47
37
  gem 'sitemap_generator'
48
38
 
@@ -126,7 +116,7 @@ module Spotlight
126
116
  insert_into_file 'config/application.rb', after: "< Rails::Application\n" do
127
117
  <<-EOF
128
118
  config.action_mailer.default_url_options = { host: "#{options[:mailer_default_url_host]}", from: "noreply@example.com" }
129
- EOF
119
+ EOF
130
120
  end
131
121
  else
132
122
  say 'Please add a default configuration config.action_mailer.default_url_options for your environment', :red
@@ -15,7 +15,7 @@ module Spotlight
15
15
  # yield { id: resource.id }
16
16
  end
17
17
  end
18
- FILE
18
+ FILE
19
19
  end
20
20
 
21
21
  def create_model
@@ -72,3 +72,8 @@
72
72
  # FeaturedPages SolrDocuments SolrDocumentsCarousel SolrDocumentsEmbed
73
73
  # SolrDocumentsFeatures SolrDocumentsGrid SearchResults
74
74
  # )
75
+ #
76
+ # Page configurations made available to widgets
77
+ # Spotlight::Engine.config.page_configurations = {
78
+ # 'my-local-config': ->(context) { context.my_custom_data_path(context.current_exhibit) }
79
+ # }
@@ -161,6 +161,10 @@ module Spotlight
161
161
  config.featured_image_square_size = [400, 400]
162
162
  config.contact_square_size = [70, 70]
163
163
 
164
+ # Additional page configurations to be made available to page editing widgets
165
+ # See Spotlight::PageConfigurations
166
+ config.page_configurations = {}
167
+
164
168
  # To present curators with analytics reports on the exhibit dashboard, you need to configure
165
169
  # an Analytics provider. Google Analytics support is provided out-of-the-box.
166
170
  config.analytics_provider = nil
@@ -1,3 +1,3 @@
1
1
  module Spotlight
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -42,6 +42,7 @@ describe Spotlight::AboutPagesController, type: :controller, versioning: true do
42
42
  expect(assigns(:exhibit)).to eq exhibit
43
43
  end
44
44
  end
45
+
45
46
  describe 'on a different about page' do
46
47
  it 'is successful' do
47
48
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit_root_path(exhibit))
@@ -110,6 +111,7 @@ describe Spotlight::AboutPagesController, type: :controller, versioning: true do
110
111
  expect(assigns(:exhibit)).to eq exhibit
111
112
  end
112
113
  end
114
+
113
115
  describe 'on a different about page' do
114
116
  it 'is successful' do
115
117
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit_root_path(exhibit))
@@ -135,12 +137,14 @@ describe Spotlight::AboutPagesController, type: :controller, versioning: true do
135
137
  expect(assigns(:exhibit)).to eq exhibit
136
138
  end
137
139
  end
140
+
138
141
  describe 'POST create' do
139
142
  it 'redirects to the about page index' do
140
143
  post :create, params: { about_page: { title: 'MyString' }, exhibit_id: exhibit }
141
144
  expect(response).to redirect_to(exhibit_about_pages_path(exhibit))
142
145
  end
143
146
  end
147
+
144
148
  describe 'PUT update' do
145
149
  let!(:page) { FactoryBot.create(:about_page, exhibit: exhibit) }
146
150
  it 'redirects to the about page' do
@@ -150,11 +154,13 @@ describe Spotlight::AboutPagesController, type: :controller, versioning: true do
150
154
  expect(flash[:notice]).to have_link 'Undo changes'
151
155
  end
152
156
  end
157
+
153
158
  describe 'POST update_all' do
154
159
  let!(:page1) { FactoryBot.create(:about_page, exhibit: exhibit) }
155
160
  let!(:page2) { FactoryBot.create(:about_page, exhibit: exhibit, published: true) }
156
161
  let!(:page3) { FactoryBot.create(:about_page, exhibit: exhibit, published: true) }
157
162
  before { request.env['HTTP_REFERER'] = 'http://example.com' }
163
+
158
164
  it 'updates whether they are on the landing page' do
159
165
  post :update_all, params: {
160
166
  exhibit_id: page1.exhibit,
@@ -2,6 +2,7 @@ describe Spotlight::AdminUsersController, type: :controller do
2
2
  routes { Spotlight::Engine.routes }
3
3
 
4
4
  before { sign_in(user) }
5
+
5
6
  context 'by a non-admin' do
6
7
  let(:user) { FactoryBot.create(:exhibit_visitor) }
7
8
  it 'redirects with an error message' do
@@ -13,6 +14,7 @@ describe Spotlight::AdminUsersController, type: :controller do
13
14
 
14
15
  context 'by an admin user' do
15
16
  before { request.env['HTTP_REFERER'] = 'http://example.com' }
17
+
16
18
  let(:user) { FactoryBot.create(:site_admin) }
17
19
  describe 'GET index' do
18
20
  it 'is successful' do
@@ -39,6 +39,7 @@ describe Spotlight::BrowseController, type: :controller do
39
39
 
40
40
  describe 'when authenticated as an admin' do
41
41
  before { sign_in admin }
42
+
42
43
  describe 'GET index' do
43
44
  it 'does not show unpublished categories' do
44
45
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
@@ -73,6 +74,7 @@ describe Spotlight::BrowseController, type: :controller do
73
74
  before do
74
75
  allow(controller).to receive_messages(search_results: [mock_response, document_list])
75
76
  end
77
+
76
78
  it 'shows the items in the category' do
77
79
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
78
80
  expect(controller).to receive(:add_breadcrumb).with('Browse', exhibit_browse_index_path(exhibit))
@@ -146,6 +146,7 @@ describe Spotlight::CatalogController, type: :controller do
146
146
  Blacklight.default_index.connection.commit
147
147
  end
148
148
  end
149
+
149
150
  context 'document is not an uploaded resource' do
150
151
  it 'returns a 404 when called on something other than an uploaded resource' do
151
152
  get :manifest, params: { exhibit_id: exhibit, id: 'dx157dh4345' }
@@ -234,6 +235,7 @@ describe Spotlight::CatalogController, type: :controller do
234
235
  expect(assigns[:document]).to be_kind_of SolrDocument
235
236
  end
236
237
  end
238
+
237
239
  describe 'PATCH update' do
238
240
  it 'is successful' do
239
241
  expect do
@@ -417,6 +419,7 @@ describe Spotlight::CatalogController, type: :controller do
417
419
  allow(controller).to receive(:document_index_view_type).and_return(nil)
418
420
  allow(field).to receive(:enabled).and_return(true)
419
421
  end
422
+
420
423
  context 'for sort fields' do
421
424
  let(:field) { Blacklight::Configuration::SortField.new enabled: true }
422
425
  it 'uses the enabled property for sort fields' do
@@ -473,6 +476,7 @@ describe Spotlight::CatalogController, type: :controller do
473
476
  describe 'save_search rendering' do
474
477
  let(:current_exhibit) { FactoryBot.create(:exhibit) }
475
478
  before { allow(controller).to receive_messages(current_exhibit: current_exhibit) }
479
+
476
480
  describe 'render_save_this_search?' do
477
481
  it 'returns false if we are on the items admin screen' do
478
482
  allow(controller).to receive(:can?).with(:curate, current_exhibit).and_return(true)
@@ -490,6 +494,7 @@ describe Spotlight::CatalogController, type: :controller do
490
494
  end
491
495
  end
492
496
  end
497
+
493
498
  describe '#setup_next_and_previous_documents_from_browse_category' do
494
499
  let(:search_session) { { 'counter' => '1' } }
495
500
  let(:current_browse_category) { FactoryBot.create(:search, exhibit: exhibit, query_params: { q: 'Search String' }) }
@@ -23,6 +23,7 @@ describe Spotlight::ConfirmationsController, type: :controller do
23
23
  expect(response).to be_successful
24
24
  end
25
25
  end
26
+
26
27
  describe 'when the token is valid' do
27
28
  it 'updates the user' do
28
29
  get :show, params: { confirmation_token: raw_token }
@@ -15,6 +15,7 @@ describe Spotlight::ContactFormsController, type: :controller do
15
15
  end
16
16
  end
17
17
  end
18
+
18
19
  describe 'POST create' do
19
20
  it 'sends an email' do
20
21
  expect do
@@ -26,6 +26,7 @@ describe Spotlight::ContactsController, type: :controller do
26
26
  expect(response).to be_successful
27
27
  end
28
28
  end
29
+
29
30
  describe 'PATCH update' do
30
31
  it 'is successful' do
31
32
  patch :update, params: { id: contact, contact: { name: 'Chester' }, exhibit_id: contact.exhibit }
@@ -56,6 +57,7 @@ describe Spotlight::ContactsController, type: :controller do
56
57
  expect(response).to render_template 'edit'
57
58
  end
58
59
  end
60
+
59
61
  describe 'DELETE destroy' do
60
62
  it 'is successful' do
61
63
  contact # force contact to be created
@@ -65,6 +67,7 @@ describe Spotlight::ContactsController, type: :controller do
65
67
  expect(response).to redirect_to exhibit_about_pages_path(exhibit)
66
68
  end
67
69
  end
70
+
68
71
  describe 'GET new' do
69
72
  it 'is successful' do
70
73
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
@@ -75,6 +78,7 @@ describe Spotlight::ContactsController, type: :controller do
75
78
  expect(response).to be_successful
76
79
  end
77
80
  end
81
+
78
82
  describe 'POST create' do
79
83
  it 'fails by rendering new' do
80
84
  expect_any_instance_of(Spotlight::Contact).to receive(:update).and_return(false)
@@ -1,4 +1,3 @@
1
-
2
1
  describe Spotlight::DashboardsController, type: :controller do
3
2
  routes { Spotlight::Engine.routes }
4
3
  let(:exhibit) { FactoryBot.create(:exhibit) }
@@ -11,6 +10,7 @@ describe Spotlight::DashboardsController, type: :controller do
11
10
  describe 'when logged in' do
12
11
  let(:curator) { FactoryBot.create(:exhibit_curator, exhibit: exhibit) }
13
12
  before { sign_in curator }
13
+
14
14
  describe 'GET show' do
15
15
  it 'loads the exhibit' do
16
16
  exhibit.blacklight_configuration.index = { timestamp_field: 'timestamp_field' }
@@ -39,6 +39,7 @@ describe Spotlight::DashboardsController, type: :controller do
39
39
 
40
40
  describe 'when user does not have access' do
41
41
  before { sign_in FactoryBot.create(:exhibit_visitor) }
42
+
42
43
  it 'does not allow show' do
43
44
  get :show, params: { exhibit_id: exhibit.id }
44
45
  expect(response).to redirect_to main_app.root_path