geoblacklight 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/app/controllers/download_controller.rb +5 -0
- data/app/helpers/arcgis_helper.rb +3 -0
- data/app/helpers/blacklight_helper.rb +4 -0
- data/app/helpers/carto_helper.rb +5 -0
- data/app/helpers/geoblacklight/geoblacklight_helper_behavior.rb +7 -1
- data/app/helpers/geoblacklight_helper.rb +74 -21
- data/app/models/concerns/geoblacklight/solr_document/carto.rb +7 -0
- data/app/models/concerns/geoblacklight/solr_document/citation.rb +7 -0
- data/app/models/concerns/geoblacklight/solr_document/inspection.rb +1 -1
- data/app/models/concerns/geoblacklight/solr_document.rb +30 -2
- data/app/presenters/geoblacklight/document_presenter.rb +8 -0
- data/app/views/catalog/_arcgis.html.erb +1 -1
- data/app/views/catalog/_carto.html.erb +1 -1
- data/app/views/catalog/_downloads_collapse.html.erb +3 -0
- data/app/views/catalog/_index_split_default.html.erb +1 -1
- data/app/views/catalog/_show_default_attribute_table.html.erb +1 -1
- data/app/views/catalog/_show_default_viewer_container.html.erb +3 -3
- data/app/views/catalog/_show_downloads.html.erb +3 -0
- data/app/views/catalog/_show_sidebar.html.erb +1 -1
- data/app/views/catalog/_show_sidebar_static_map.html.erb +3 -0
- data/app/views/catalog/_web_services.html.erb +1 -1
- data/geoblacklight.gemspec +2 -2
- data/lib/geoblacklight/deprecated_configuration.rb +519 -0
- data/lib/geoblacklight/download/hgl_download.rb +5 -0
- data/lib/geoblacklight/engine.rb +14 -0
- data/lib/geoblacklight/geometry.rb +7 -0
- data/lib/geoblacklight/item_viewer.rb +8 -1
- data/lib/geoblacklight/references.rb +15 -0
- data/lib/geoblacklight/version.rb +1 -1
- data/lib/geoblacklight/view_helper_override.rb +12 -1
- data/lib/geoblacklight.rb +17 -0
- data/lib/tasks/geoblacklight.rake +17 -0
- data/package.json +3 -2
- data/spec/lib/geoblacklight/deprecated_configuration_spec.rb +597 -0
- data/spec/lib/geoblacklight/geometry_spec.rb +15 -0
- data/spec/lib/geoblacklight/references_spec.rb +24 -0
- data/spec/models/concerns/geoblacklight/solr_document/citation_spec.rb +16 -0
- data/spec/models/concerns/geoblacklight/solr_document_spec.rb +48 -0
- data/spec/spec_helper.rb +14 -11
- metadata +7 -5
|
@@ -24,6 +24,9 @@ namespace :geoblacklight do
|
|
|
24
24
|
|
|
25
25
|
desc "Run Solr and GeoBlacklight for interactive development with Webpack enabled"
|
|
26
26
|
task :webpack do |_t|
|
|
27
|
+
Geoblacklight.deprecation.warn(
|
|
28
|
+
"The geoblacklight:webpack rake task is deprecated and will be removed without replacement in GeoBlacklight 5"
|
|
29
|
+
)
|
|
27
30
|
require "solr_wrapper"
|
|
28
31
|
SolrWrapper.wrap(port: "8983") do |solr|
|
|
29
32
|
solr.with_collection(name: "blacklight-core", dir: File.join(File.expand_path("../../", File.dirname(__FILE__)), "solr", "conf")) do
|
|
@@ -48,6 +51,11 @@ namespace :geoblacklight do
|
|
|
48
51
|
docs = []
|
|
49
52
|
|
|
50
53
|
if args.remote
|
|
54
|
+
Geoblacklight.deprecation.warn(
|
|
55
|
+
"The [:remote] argument to geoblacklight:index:seed is deprecated and will be " \
|
|
56
|
+
"removed in GeoBlacklight 5; the task always indexes the fixtures bundled with " \
|
|
57
|
+
"the installed gem"
|
|
58
|
+
)
|
|
51
59
|
puts "Indexing - Remote test fixtures"
|
|
52
60
|
JSON.parse(
|
|
53
61
|
URI.parse("https://api.github.com/repos/geoblacklight/geoblacklight/contents/spec/fixtures/solr_documents").open.read
|
|
@@ -67,6 +75,9 @@ namespace :geoblacklight do
|
|
|
67
75
|
|
|
68
76
|
desc "Ingests a GeoHydra transformed.json"
|
|
69
77
|
task ingest_all: :environment do
|
|
78
|
+
Geoblacklight.deprecation.warn(
|
|
79
|
+
"The geoblacklight:index:ingest_all rake task is deprecated and will be removed without replacement in GeoBlacklight 5"
|
|
80
|
+
)
|
|
70
81
|
docs = JSON.parse(File.read(Rails.root.join("tmp", "transformed.json")))
|
|
71
82
|
docs.each do |doc|
|
|
72
83
|
Blacklight.default_index.connection.add doc
|
|
@@ -76,6 +87,9 @@ namespace :geoblacklight do
|
|
|
76
87
|
|
|
77
88
|
desc "Ingests a directory of geoblacklight.json files"
|
|
78
89
|
task :ingest, [:directory] => :environment do |_t, args|
|
|
90
|
+
Geoblacklight.deprecation.warn(
|
|
91
|
+
"The geoblacklight:index:ingest rake task is deprecated and will be removed without replacement in GeoBlacklight 5"
|
|
92
|
+
)
|
|
79
93
|
args.with_defaults(directory: "data")
|
|
80
94
|
Dir.glob(File.join(args[:directory], "**", "geoblacklight.json")).each do |fn|
|
|
81
95
|
puts "Ingesting #{fn}"
|
|
@@ -121,6 +135,9 @@ namespace :geoblacklight do
|
|
|
121
135
|
namespace :solr do
|
|
122
136
|
desc "Put sample data into solr"
|
|
123
137
|
task seed: :environment do
|
|
138
|
+
Geoblacklight.deprecation.warn(
|
|
139
|
+
"The geoblacklight:solr:seed rake task is deprecated and will be removed in GeoBlacklight 5; use geoblacklight:index:seed instead"
|
|
140
|
+
)
|
|
124
141
|
Rake::Task["geoblacklight:index:seed"].invoke
|
|
125
142
|
end
|
|
126
143
|
end
|
data/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geoblacklight/frontend",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.6.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@samvera/clover-iiif": "^2.3.2",
|
|
29
29
|
"ol": "8.1.0",
|
|
30
30
|
"ol-pmtiles": "^0.3.0",
|
|
31
|
-
"react": "^18.2.0"
|
|
31
|
+
"react": "^18.2.0",
|
|
32
|
+
"react-dom": "^18.2.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"vite": "^5.0.0"
|
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe Geoblacklight::DeprecatedConfiguration do
|
|
6
|
+
let(:root) { Pathname.new(Dir.mktmpdir) }
|
|
7
|
+
|
|
8
|
+
after { FileUtils.remove_entry(root) }
|
|
9
|
+
|
|
10
|
+
def write_view(path, contents = "")
|
|
11
|
+
full = root.join("app", "views", path)
|
|
12
|
+
FileUtils.mkdir_p(full.dirname)
|
|
13
|
+
File.write(full, contents)
|
|
14
|
+
full.to_s
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe ".warn_about_templates" do
|
|
18
|
+
it "warns about an overridden template, naming the file and its replacement" do
|
|
19
|
+
write_view("catalog/_show_sidebar.html.erb")
|
|
20
|
+
|
|
21
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
22
|
+
"app/views/catalog/_show_sidebar.html.erb overrides catalog/_show_sidebar, which is " \
|
|
23
|
+
"removed in GeoBlacklight 5; use Geoblacklight::Document::SidebarComponent instead"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
described_class.warn_about_templates(root)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "warns about a template with no replacement" do
|
|
30
|
+
write_view("catalog/_show_default_viewer_information.html.erb")
|
|
31
|
+
|
|
32
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(/it is removed without replacement/)
|
|
33
|
+
|
|
34
|
+
described_class.warn_about_templates(root)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The masthead moves to a component, and Blacklight has no shared/_header_navbar
|
|
38
|
+
# of its own, so there is no upstream copy for an application to override.
|
|
39
|
+
it "points the site masthead at config.header_component" do
|
|
40
|
+
write_view("shared/_header_navbar.html.erb")
|
|
41
|
+
|
|
42
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
43
|
+
"app/views/shared/_header_navbar.html.erb overrides shared/_header_navbar, which is " \
|
|
44
|
+
"removed in GeoBlacklight 5; set config.header_component to a subclass of " \
|
|
45
|
+
"Geoblacklight::HeaderComponent instead"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
described_class.warn_about_templates(root)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Geoblacklight::HeaderComponent is the site masthead; this partial is the
|
|
52
|
+
# document heading, which GeoBlacklight 5 renders from a slot instead.
|
|
53
|
+
it "points the document heading at the DocumentComponent title slot" do
|
|
54
|
+
write_view("catalog/_show_header_default.html.erb")
|
|
55
|
+
|
|
56
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
57
|
+
/use the title slot of Geoblacklight::DocumentComponent instead/
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
described_class.warn_about_templates(root)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# The partial's only job is to render a DisplayNoteComponent per note, and that
|
|
64
|
+
# component still exists, so it is the unit an application should override.
|
|
65
|
+
it "points the display note at the component the partial already rendered" do
|
|
66
|
+
write_view("catalog/_show_default_display_note.html.erb")
|
|
67
|
+
|
|
68
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
69
|
+
/use Geoblacklight::DisplayNoteComponent instead/
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
described_class.warn_about_templates(root)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "does not warn when the application has no overrides" do
|
|
76
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
77
|
+
|
|
78
|
+
described_class.warn_about_templates(root)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "does not warn about templates GeoBlacklight 5 keeps" do
|
|
82
|
+
write_view("catalog/_home_text.html.erb")
|
|
83
|
+
|
|
84
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
85
|
+
|
|
86
|
+
described_class.warn_about_templates(root)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "does not mistake a similarly named template for an override" do
|
|
90
|
+
write_view("catalog/_show_sidebar_extra.html.erb")
|
|
91
|
+
|
|
92
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
93
|
+
|
|
94
|
+
described_class.warn_about_templates(root)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "finds overrides regardless of template handler" do
|
|
98
|
+
write_view("relation/_relations.html.haml")
|
|
99
|
+
|
|
100
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
101
|
+
/_relations\.html\.haml overrides relation\/_relations/
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
described_class.warn_about_templates(root)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe ".warn_about_locale_keys" do
|
|
109
|
+
def write_locale(contents, name: "geoblacklight.en.yml")
|
|
110
|
+
full = root.join("config", "locales", name)
|
|
111
|
+
FileUtils.mkdir_p(full.dirname)
|
|
112
|
+
File.write(full, contents)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "warns about a translation GeoBlacklight 5 stops looking up" do
|
|
116
|
+
write_locale(<<~YAML)
|
|
117
|
+
en:
|
|
118
|
+
geoblacklight:
|
|
119
|
+
citation:
|
|
120
|
+
retrieved_from: "Downloaded from %{document_url}"
|
|
121
|
+
YAML
|
|
122
|
+
|
|
123
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
124
|
+
"config/locales/geoblacklight.en.yml defines geoblacklight.citation.retrieved_from, which " \
|
|
125
|
+
"GeoBlacklight 5 no longer looks up; GeoBlacklight 5 ends a citation with the document's " \
|
|
126
|
+
"identifier URL, its schema.org/url reference or the catalog URL, rather than with a translated suffix"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
described_class.warn_about_locale_keys(root)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "names the replacement key for a renamed provider icon" do
|
|
133
|
+
write_locale("en:\n blacklight:\n icon:\n chicago: The University of Chicago\n")
|
|
134
|
+
|
|
135
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
136
|
+
/blacklight\.icon\.chicago.*looks up blacklight\.icon\.university-of-chicago instead/
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
described_class.warn_about_locale_keys(root)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "matches a translation into any locale, not just English" do
|
|
143
|
+
write_locale("de:\n geoblacklight:\n tools:\n open_carto: In Carto oeffnen\n")
|
|
144
|
+
|
|
145
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(/defines geoblacklight\.tools\.open_carto/)
|
|
146
|
+
|
|
147
|
+
described_class.warn_about_locale_keys(root)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it "does not warn about translations GeoBlacklight 5 keeps" do
|
|
151
|
+
write_locale("en:\n geoblacklight:\n home:\n title: My Portal\n")
|
|
152
|
+
|
|
153
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
154
|
+
|
|
155
|
+
described_class.warn_about_locale_keys(root)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "does not warn when the application has no locale files of its own" do
|
|
159
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
160
|
+
|
|
161
|
+
described_class.warn_about_locale_keys(root)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "ignores a locale file it cannot parse" do
|
|
165
|
+
write_locale("en:\n geoblacklight:\n : not valid: [\n")
|
|
166
|
+
|
|
167
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
168
|
+
expect { described_class.warn_about_locale_keys(root) }.not_to raise_error
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "ignores a locale file that is not a mapping" do
|
|
172
|
+
write_locale("--- just a string\n")
|
|
173
|
+
|
|
174
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
175
|
+
|
|
176
|
+
described_class.warn_about_locale_keys(root)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe ".warn_about_jquery_animations" do
|
|
181
|
+
it "warns about the line the 4.x install generator injected" do
|
|
182
|
+
write_view("layouts/application.html.erb",
|
|
183
|
+
"<head>\n <%= javascript_tag '$.fx.off = true;' if Rails.env.test? %>\n</head>")
|
|
184
|
+
|
|
185
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
186
|
+
"app/views/layouts/application.html.erb turns jQuery animations off with $.fx.off, which the " \
|
|
187
|
+
"GeoBlacklight 4 install generator added; GeoBlacklight 5 does not ship jQuery, so remove that " \
|
|
188
|
+
'javascript_tag line or the test environment raises "$ is not defined"'
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
described_class.warn_about_jquery_animations(root)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it "finds the line in any layout, not just the application layout" do
|
|
195
|
+
write_view("layouts/blacklight/base.html.erb", "<%= javascript_tag '$.fx.off = true;' %>")
|
|
196
|
+
|
|
197
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
198
|
+
%r{layouts/blacklight/base\.html\.erb turns jQuery animations off}
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
described_class.warn_about_jquery_animations(root)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "does not warn about a layout that does not mention jQuery" do
|
|
205
|
+
write_view("layouts/application.html.erb", "<head><%= csrf_meta_tags %></head>")
|
|
206
|
+
|
|
207
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
208
|
+
|
|
209
|
+
described_class.warn_about_jquery_animations(root)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "does not warn when the application has no layouts" do
|
|
213
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
214
|
+
|
|
215
|
+
described_class.warn_about_jquery_animations(root)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "never lets an unreadable layout stop the application booting" do
|
|
219
|
+
layout = write_view("layouts/application.html.erb", "<%= javascript_tag '$.fx.off = true;' %>")
|
|
220
|
+
allow(File).to receive(:read).and_call_original
|
|
221
|
+
allow(File).to receive(:read).with(layout).and_raise(Errno::EACCES)
|
|
222
|
+
|
|
223
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
224
|
+
|
|
225
|
+
expect { described_class.warn_about_jquery_animations(root) }.not_to raise_error
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
describe ".warn_about_relationship_keys" do
|
|
230
|
+
it "names the stale keys and their replacements in a single warning" do
|
|
231
|
+
allow(described_class).to receive(:setting_present?).and_return(false)
|
|
232
|
+
allow(described_class).to receive(:setting_present?).with("RELATIONSHIPS_SHOWN.MEMBER_OF").and_return(true)
|
|
233
|
+
allow(described_class).to receive(:setting_present?).with("RELATIONSHIPS_SHOWN.REPLACED_BY").and_return(true)
|
|
234
|
+
|
|
235
|
+
expect(Geoblacklight.deprecation).to receive(:warn).once.with(
|
|
236
|
+
/Settings\.RELATIONSHIPS_SHOWN defines MEMBER_OF, REPLACED_BY, which GeoBlacklight 4\.1 replaced/
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
described_class.warn_about_relationship_keys
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it "maps REPLACED_BY onto REPLACES_DESCENDANTS rather than a key of its own" do
|
|
243
|
+
allow(described_class).to receive(:setting_present?).and_return(false)
|
|
244
|
+
allow(described_class).to receive(:setting_present?).with("RELATIONSHIPS_SHOWN.REPLACED_BY").and_return(true)
|
|
245
|
+
|
|
246
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
247
|
+
/Rename to REPLACES_DESCENDANTS/
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
described_class.warn_about_relationship_keys
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it "stays quiet for a settings file on the current shape" do
|
|
254
|
+
allow(described_class).to receive(:setting_present?).and_return(false)
|
|
255
|
+
|
|
256
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
257
|
+
|
|
258
|
+
described_class.warn_about_relationship_keys
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
describe ".warn_about_settings" do
|
|
263
|
+
it "warns about a removed setting that the application has set" do
|
|
264
|
+
allow(described_class).to receive(:setting_present?).and_return(false)
|
|
265
|
+
allow(described_class).to receive(:setting_present?).with("CARTO_ONECLICK_LINK").and_return(true)
|
|
266
|
+
|
|
267
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
268
|
+
"Settings.CARTO_ONECLICK_LINK is deprecated and will be removed in GeoBlacklight 5; " \
|
|
269
|
+
"the Carto OneClick integration is removed without replacement"
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
described_class.warn_about_settings
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "does not warn about a removed setting the application has not set" do
|
|
276
|
+
allow(described_class).to receive(:setting_present?).and_return(false)
|
|
277
|
+
|
|
278
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
279
|
+
|
|
280
|
+
described_class.warn_about_settings
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe ".warn_about_changed_settings" do
|
|
285
|
+
it "warns when a setting still holds the GeoBlacklight 4 default" do
|
|
286
|
+
allow(described_class).to receive(:setting_value).and_return(:something_else)
|
|
287
|
+
allow(described_class).to receive(:setting_value).with("TIMEOUT_DOWNLOAD").and_return(16)
|
|
288
|
+
|
|
289
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
290
|
+
"Settings.TIMEOUT_DOWNLOAD is set to the GeoBlacklight 4 default 16, which is deprecated; " \
|
|
291
|
+
"GeoBlacklight 5 uses 180 because 16 seconds is too short for many generated downloads"
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
described_class.warn_about_changed_settings
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it "leaves a setting alone once the application has chosen its own value" do
|
|
298
|
+
allow(described_class).to receive(:setting_value).and_return("a deliberate choice")
|
|
299
|
+
|
|
300
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
301
|
+
|
|
302
|
+
described_class.warn_about_changed_settings
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
it "does not confuse a nil setting with the old default" do
|
|
306
|
+
allow(described_class).to receive(:setting_value).and_return(nil)
|
|
307
|
+
|
|
308
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
309
|
+
|
|
310
|
+
described_class.warn_about_changed_settings
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
describe ".warn_about_required_settings" do
|
|
315
|
+
it "warns when a setting GeoBlacklight 5 requires is missing" do
|
|
316
|
+
allow(described_class).to receive(:setting_value).and_return(nil)
|
|
317
|
+
|
|
318
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
319
|
+
/Settings\.DOWNLOAD_FORMATS\.VECTOR is not set; GeoBlacklight 5 requires it/
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
described_class.warn_about_required_settings
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "stays quiet once the setting is supplied" do
|
|
326
|
+
allow(described_class).to receive(:setting_value).and_return(["Shapefile"])
|
|
327
|
+
|
|
328
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
329
|
+
|
|
330
|
+
described_class.warn_about_required_settings
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
describe ".setting_value" do
|
|
335
|
+
it "returns the value of a top level setting" do
|
|
336
|
+
expect(described_class.setting_value("TIMEOUT_DOWNLOAD")).to eq Settings.TIMEOUT_DOWNLOAD
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
it "walks a dotted path, including symbol-keyed settings" do
|
|
340
|
+
expect(described_class.setting_value("WMS_PARAMS.INFO_FORMAT")).to eq Settings.WMS_PARAMS.INFO_FORMAT
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
it "is nil when the setting is absent" do
|
|
344
|
+
expect(described_class.setting_value("NO_SUCH_SETTING")).to be_nil
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it "is nil when an ancestor of the path is absent" do
|
|
348
|
+
expect(described_class.setting_value("NO_SUCH_SETTING.NOR_THIS_ONE")).to be_nil
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
describe ".setting_present?" do
|
|
353
|
+
it "is true for a setting that is present" do
|
|
354
|
+
expect(described_class.setting_present?("CARTO_ONECLICK_LINK")).to be true
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
it "is true for a nested setting that is present" do
|
|
358
|
+
expect(described_class.setting_present?("LEAFLET.VIEWERS")).to be true
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
it "is false for a setting that is absent" do
|
|
362
|
+
expect(described_class.setting_present?("NO_SUCH_SETTING")).to be false
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
it "is false when an ancestor of a nested setting is absent" do
|
|
366
|
+
expect(described_class.setting_present?("NO_SUCH_SETTING.NOR_THIS_ONE")).to be false
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
describe ".warn_about_helper_override" do
|
|
371
|
+
it "warns when the application has copied GeoblacklightHelper into app/helpers" do
|
|
372
|
+
FileUtils.mkdir_p(root.join("app", "helpers"))
|
|
373
|
+
File.write(root.join("app", "helpers", "geoblacklight_helper.rb"), "")
|
|
374
|
+
|
|
375
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
376
|
+
/app\/helpers\/geoblacklight_helper\.rb overrides GeoblacklightHelper, which shadows GeoBlacklight's own copy/
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
described_class.warn_about_helper_override(root)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it "stays quiet when the application uses GeoBlacklight's helper" do
|
|
383
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
384
|
+
|
|
385
|
+
described_class.warn_about_helper_override(root)
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
describe ".warn_about_stale_setting_values" do
|
|
390
|
+
it "warns when a setting lists a value that stops matching in GeoBlacklight 5" do
|
|
391
|
+
allow(described_class).to receive(:setting_value).and_return([])
|
|
392
|
+
allow(described_class).to receive(:setting_value).with("SIDEBAR_STATIC_MAP").and_return(["iiif", "map"])
|
|
393
|
+
|
|
394
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
395
|
+
/Settings\.SIDEBAR_STATIC_MAP lists "map", which never matches in GeoBlacklight 5/
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
described_class.warn_about_stale_setting_values
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
it "stays quiet for the default setting values" do
|
|
402
|
+
allow(described_class).to receive(:setting_value).and_return(["iiif", "iiif_manifest"])
|
|
403
|
+
|
|
404
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
405
|
+
|
|
406
|
+
described_class.warn_about_stale_setting_values
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
it "tolerates a setting that is absent" do
|
|
410
|
+
allow(described_class).to receive(:setting_value).and_return(nil)
|
|
411
|
+
|
|
412
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
413
|
+
|
|
414
|
+
described_class.warn_about_stale_setting_values
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
describe ".warn_about_document_overrides" do
|
|
419
|
+
def only_defines(reader, owner, source: "/my/app/app/models/concerns/overrides.rb")
|
|
420
|
+
allow(SolrDocument).to receive(:method_defined?).and_return(false)
|
|
421
|
+
allow(SolrDocument).to receive(:private_method_defined?).and_return(false)
|
|
422
|
+
allow(SolrDocument).to receive(:method_defined?).with(reader).and_return(true)
|
|
423
|
+
allow(SolrDocument).to receive(:instance_method).with(reader)
|
|
424
|
+
.and_return(instance_double(UnboundMethod, owner: owner, source_location: source && [source, 1]))
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it "stays quiet for a stock SolrDocument" do
|
|
428
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
429
|
+
|
|
430
|
+
described_class.warn_about_document_overrides
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
it "warns when an application module overrides a reader" do
|
|
434
|
+
stub_const("MyDocumentOverrides", Module.new)
|
|
435
|
+
only_defines("display_note", MyDocumentOverrides)
|
|
436
|
+
|
|
437
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
438
|
+
/MyDocumentOverrides#display_note overrides Geoblacklight::SolrDocument#display_note/
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
described_class.warn_about_document_overrides
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
it "stays quiet when the reader is defined in the SolrDocument class body" do
|
|
445
|
+
only_defines("title", SolrDocument)
|
|
446
|
+
|
|
447
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
448
|
+
|
|
449
|
+
described_class.warn_about_document_overrides
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
it "stays quiet when GeoBlacklight itself owns the reader" do
|
|
453
|
+
only_defines("display_note", Geoblacklight::SolrDocument)
|
|
454
|
+
|
|
455
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
456
|
+
|
|
457
|
+
described_class.warn_about_document_overrides
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
it "ignores a reader that is implemented in C, such as Kernel#format" do
|
|
461
|
+
only_defines("format", Kernel, source: nil)
|
|
462
|
+
|
|
463
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
464
|
+
|
|
465
|
+
described_class.warn_about_document_overrides
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
it "tolerates a reader that cannot be resolved" do
|
|
469
|
+
allow(SolrDocument).to receive(:method_defined?).and_return(true)
|
|
470
|
+
allow(SolrDocument).to receive(:instance_method).and_raise(NameError)
|
|
471
|
+
|
|
472
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
473
|
+
|
|
474
|
+
described_class.warn_about_document_overrides
|
|
475
|
+
end
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
describe ".warn_about_catalog_controller" do
|
|
479
|
+
it "reports everything the application's CatalogController needs, as one warning" do
|
|
480
|
+
expect(Geoblacklight.deprecation).to receive(:warn).once.with(
|
|
481
|
+
/\Aapp\/controllers\/catalog_controller\.rb needs these changes before GeoBlacklight 5: /
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
described_class.warn_about_catalog_controller
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
it "stays quiet once there is nothing left to change" do
|
|
488
|
+
allow(described_class).to receive(:catalog_controller_problems).and_return([])
|
|
489
|
+
|
|
490
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
491
|
+
|
|
492
|
+
described_class.warn_about_catalog_controller
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
it "never lets a broken controller stop the application booting" do
|
|
496
|
+
allow(described_class).to receive(:catalog_controller_problems).and_raise("boom")
|
|
497
|
+
|
|
498
|
+
expect { described_class.warn_about_catalog_controller }.not_to raise_error
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
describe ".catalog_controller_problems" do
|
|
503
|
+
subject(:problems) { described_class.catalog_controller_problems(CatalogController) }
|
|
504
|
+
|
|
505
|
+
it "flags the removed document presenter" do
|
|
506
|
+
expect(problems).to include(/config\.index\.document_presenter_class = Geoblacklight::DocumentPresenter/)
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
it "flags every removed show partial the controller still lists" do
|
|
510
|
+
expect(problems).to include(
|
|
511
|
+
/remove show_default_display_note, show_default_viewer_container, show_default_attribute_table, show_default_viewer_information/
|
|
512
|
+
)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
it "flags each show tool that is still registered with a partial" do
|
|
516
|
+
expect(problems).to include(/register the :arcgis show tool with a `component:`/)
|
|
517
|
+
expect(problems).to include(/register the :data_dictionary show tool with a `component:`/)
|
|
518
|
+
expect(problems).to include(/register the :carto show tool with a `component:`/)
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
it "flags the components the controller has to start setting" do
|
|
522
|
+
expect(problems).to include(/config\.show\.document_component = Geoblacklight::DocumentComponent/)
|
|
523
|
+
expect(problems).to include(/config\.index\.document_component = Geoblacklight::SearchResultComponent/)
|
|
524
|
+
expect(problems).to include(/config\.header_component = Geoblacklight::HeaderComponent/)
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
it "flags the web_services destructuring" do
|
|
528
|
+
expect(problems).to include(/@response, @documents = action_documents/)
|
|
529
|
+
end
|
|
530
|
+
|
|
531
|
+
it "is empty for a controller that has already been migrated" do
|
|
532
|
+
config = CatalogController.blacklight_config.deep_copy
|
|
533
|
+
config.index.document_presenter_class = Blacklight::IndexPresenter
|
|
534
|
+
config.show.partials = [:show_header, :show]
|
|
535
|
+
config.show.document_component = Blacklight::DocumentComponent
|
|
536
|
+
config.index.document_component = Blacklight::DocumentComponent
|
|
537
|
+
config.header_component = Class.new
|
|
538
|
+
described_class::SHOW_TOOL_PARTIALS.each { |tool| config.show.document_actions.delete(tool.to_sym) }
|
|
539
|
+
controller = class_double(CatalogController, blacklight_config: config)
|
|
540
|
+
allow(described_class).to receive(:web_services_problem).with(controller).and_return(nil)
|
|
541
|
+
|
|
542
|
+
expect(described_class.catalog_controller_problems(controller)).to be_empty
|
|
543
|
+
end
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
describe ".web_services_problem" do
|
|
547
|
+
it "is nil when the controller source cannot be located" do
|
|
548
|
+
controller = class_double(
|
|
549
|
+
CatalogController,
|
|
550
|
+
instance_method: instance_double(UnboundMethod, source_location: nil)
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
expect(described_class.web_services_problem(controller)).to be_nil
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
it "is nil rather than raising when the source cannot be read" do
|
|
557
|
+
controller = class_double(CatalogController)
|
|
558
|
+
allow(controller).to receive(:instance_method).and_raise("boom")
|
|
559
|
+
|
|
560
|
+
expect(described_class.web_services_problem(controller)).to be_nil
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
describe ".warn!" do
|
|
565
|
+
it "checks templates, removed settings, changed defaults and required settings" do
|
|
566
|
+
expect(described_class).to receive(:warn_about_templates).with(root)
|
|
567
|
+
expect(described_class).to receive(:warn_about_settings)
|
|
568
|
+
expect(described_class).to receive(:warn_about_changed_settings)
|
|
569
|
+
expect(described_class).to receive(:warn_about_required_settings)
|
|
570
|
+
expect(described_class).to receive(:warn_about_stale_setting_values)
|
|
571
|
+
expect(described_class).to receive(:warn_about_helper_override).with(root)
|
|
572
|
+
expect(described_class).to receive(:warn_about_locale_keys).with(root)
|
|
573
|
+
expect(described_class).to receive(:warn_about_jquery_animations).with(root)
|
|
574
|
+
expect(described_class).to receive(:warn_about_relationship_keys)
|
|
575
|
+
expect(described_class).to receive(:warn_about_document_overrides)
|
|
576
|
+
expect(described_class).to receive(:warn_about_catalog_controller)
|
|
577
|
+
|
|
578
|
+
described_class.warn!(root)
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
it "skips the template check when there is no application root" do
|
|
582
|
+
expect(described_class).not_to receive(:warn_about_templates)
|
|
583
|
+
allow(described_class).to receive(:warn_about_settings)
|
|
584
|
+
allow(described_class).to receive(:warn_about_changed_settings)
|
|
585
|
+
allow(described_class).to receive(:warn_about_required_settings)
|
|
586
|
+
allow(described_class).to receive(:warn_about_stale_setting_values)
|
|
587
|
+
expect(described_class).not_to receive(:warn_about_helper_override)
|
|
588
|
+
expect(described_class).not_to receive(:warn_about_locale_keys)
|
|
589
|
+
expect(described_class).not_to receive(:warn_about_jquery_animations)
|
|
590
|
+
allow(described_class).to receive(:warn_about_relationship_keys)
|
|
591
|
+
allow(described_class).to receive(:warn_about_document_overrides)
|
|
592
|
+
allow(described_class).to receive(:warn_about_catalog_controller)
|
|
593
|
+
|
|
594
|
+
described_class.warn!(nil)
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
end
|
|
@@ -57,4 +57,19 @@ describe Geoblacklight::Geometry do
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
+
describe "#bounding_box for a document with no geometry" do
|
|
61
|
+
it "warns that GeoBlacklight 5 raises instead of falling back to the whole world" do
|
|
62
|
+
expect(Geoblacklight.deprecation).to receive(:warn).with(
|
|
63
|
+
/#bounding_box falls back to the whole world extent/
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
expect(described_class.new("").bounding_box).to be_a String
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "does not warn for a document that has geometry" do
|
|
70
|
+
expect(Geoblacklight.deprecation).not_to receive(:warn)
|
|
71
|
+
|
|
72
|
+
described_class.new("ENVELOPE(-1,1,1,-1)").bounding_box
|
|
73
|
+
end
|
|
74
|
+
end
|
|
60
75
|
end
|