Skip to content

Commit

Permalink
add deprecation warnings from #751
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Feb 5, 2014
1 parent 577a3dd commit cda9ec4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def extra_body_classes
def render_document_list_partial options={}
render :partial=>'catalog/document_list'
end
deprecation_deprecate :render_document_list_partial

# Save function area for search results 'index' view, normally
# renders next to title.
Expand All @@ -103,6 +104,10 @@ def render_index_doc_actions(document, options={})
def render_show_doc_actions(document=@document, options={})
# I'm not sure why this key is documentFunctions and #render_index_doc_actions uses wrapping_class.
# TODO: remove documentFunctions key in Blacklight 5.x
if options.has_key? :documentFunctions
Deprecation.warn(Blacklight::BlacklightHelperBehavior, "Calling #render_show_doc_actions with the :documentFunctions option is deprecated; use :wrapping_class instead")
end

wrapping_class = options.delete(:documentFunctions) || options.delete(:wrapping_class) || "documentFunctions"

content = []
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/blacklight/render_constraints_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def render_filter_element(facet, values, localized_params)
# [:escape_value]
# default true, HTML escape.
def render_constraint_element(label, value, options = {})
if (options[:escape_label] and !label.html_safe?) or (options.has_key?(:escape_value) and !value.html_safe?)
Deprecation.warn(Blacklight::RenderConstraintsHelperBehavior, "Calling #render_constraint_element with :escape_label or :escape_value parameters is deprecated; make sure your values are #html_safe instead")
end

render(:partial => "catalog/constraints_element", :locals => {:label => label, :value => value, :options => options})
end

Expand Down
10 changes: 9 additions & 1 deletion spec/helpers/blacklight_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def blacklight_config
def current_search_session

end

describe "deprecated methods" do
describe "#index_field_names" do
it "should warn" do
Expand All @@ -113,6 +113,14 @@ def current_search_session
helper.document_show_field_labels
end
end

describe "#render_document_list_partial" do
it "should warn" do
expect(Blacklight::BlacklightHelperBehavior.deprecation_behavior.first).to receive(:call)
helper.stub(:render)
helper.render_document_list_partial
end
end
end

describe "#application_name", :test => true do
Expand Down

0 comments on commit cda9ec4

Please sign in to comment.