Skip to content

Commit f8831fd

Browse files
committed
Merge pull request #1036 from projectblacklight/deprecation-warnings
Deprecation warnings
2 parents 727d5fa + a6b11b9 commit f8831fd

File tree

5 files changed

+71
-14
lines changed

5 files changed

+71
-14
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<% Deprecation.warn controller, "The template catalog/email_sent.html.erb is deprecated; use email_success instead" %>
2+
<%= render template: "catalog/email_success" %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<% Deprecation.warn controller, "The template catalog/sms_sent.html.erb is deprecated; use sms_success instead" %>
2+
<%= render template: "catalog/sms_success" %>

lib/blacklight/catalog/component_configuration.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ module ClassMethods
3434
# The proc will receive the action configuration and the document or documents for the action.
3535
def add_show_tools_partial name, opts = {}
3636
blacklight_config.add_show_tools_partial(name, opts)
37+
3738
define_method name do
3839
@response, @documents = action_documents
40+
3941
if request.post? and
4042
opts[:callback] and
4143
(opts[:validator].blank? || self.send(opts[:validator]))
@@ -54,7 +56,7 @@ def add_show_tools_partial name, opts = {}
5456
format.js { render :layout => false }
5557
end
5658
end
57-
end
59+
end unless method_defined? name
5860
end
5961

6062
##

lib/blacklight/solr_helper.rb

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,7 @@ def find *args
6767

6868
# returns a params hash for finding a single solr document (CatalogController #show action)
6969
def solr_doc_params(id=nil)
70-
id ||= params[:id]
71-
72-
# add our document id to the document_unique_id_param query parameter
73-
p = blacklight_config.default_document_solr_params.merge({
74-
# this assumes the request handler will map the unique id param
75-
# to the unique key field using either solr local params, the
76-
# real-time get handler, etc.
77-
blacklight_config.document_unique_id_param => id
78-
})
79-
80-
p[:qt] ||= blacklight_config.document_solr_request_handler
81-
82-
p
70+
default_solr_doc_params(id)
8371
end
8472
deprecation_deprecate :solr_doc_params
8573

@@ -116,6 +104,20 @@ def query_solr(user_params = params || {}, extra_controller_params = {})
116104
# retrieve a solr document, given the doc id
117105
# @return [Blacklight::SolrResponse, Blacklight::SolrDocument] the solr response object and the first document
118106
def get_solr_response_for_doc_id(id=nil, extra_controller_params={})
107+
if id.nil?
108+
Deprecation.warn Blacklight::SolrHelper, "Calling #get_solr_response_for_doc_id without an explicit id argument is deprecated"
109+
id ||= params[:id]
110+
end
111+
112+
old_solr_doc_params = Deprecation.silence(Blacklight::SolrHelper) do
113+
solr_doc_params(id)
114+
end
115+
116+
if default_solr_doc_params(id) != old_solr_doc_params
117+
Deprecation.warn Blacklight::SolrHelper, "The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering"
118+
extra_controller_params = extra_controller_params.merge(old_solr_doc_params)
119+
end
120+
119121
solr_response = solr_repository.find id, extra_controller_params
120122
[solr_response, solr_response.documents.first]
121123
end
@@ -234,4 +236,24 @@ def solr_repository
234236
@solr_repository ||= Blacklight::SolrRepository.new(blacklight_config)
235237
end
236238

239+
private
240+
241+
##
242+
# @deprecated
243+
def default_solr_doc_params(id=nil)
244+
id ||= params[:id]
245+
246+
# add our document id to the document_unique_id_param query parameter
247+
p = blacklight_config.default_document_solr_params.merge({
248+
# this assumes the request handler will map the unique id param
249+
# to the unique key field using either solr local params, the
250+
# real-time get handler, etc.
251+
blacklight_config.document_unique_id_param => id
252+
})
253+
254+
p[:qt] ||= blacklight_config.document_solr_request_handler
255+
256+
p
257+
end
258+
237259
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'spec_helper'
2+
3+
describe Blacklight::Catalog::ComponentConfiguration do
4+
subject do
5+
Class.new do
6+
include Blacklight::Configurable
7+
include Blacklight::Catalog::ComponentConfiguration
8+
9+
def some_existing_action
10+
1
11+
end
12+
end
13+
end
14+
15+
describe ".add_show_tools_partial" do
16+
it "should define an action method" do
17+
subject.add_show_tools_partial :xyz
18+
expect(subject.new).to respond_to :xyz
19+
end
20+
21+
it "should not replace an existing method" do
22+
subject.add_show_tools_partial :some_existing_action
23+
expect(subject.new.some_existing_action).to eq 1
24+
end
25+
end
26+
27+
28+
29+
end

0 commit comments

Comments
 (0)