Skip to content

Commit 5e89dd3

Browse files
authored
Merge pull request #2120 from projectblacklight/functional
Make render_document_sidebar_partial functional
2 parents 7391a74 + 0307a29 commit 5e89dd3

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

app/helpers/blacklight/catalog_helper_behavior.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,13 @@ def document_class_prefix
153153
#
154154
# @param [SolrDocument] document
155155
# @return [String]
156-
def render_document_sidebar_partial(_document = @document)
157-
render partial: 'show_sidebar'
156+
def render_document_sidebar_partial(document = nil)
157+
unless document
158+
Deprecation.warn(self, 'render_document_sidebar_partial expects one argument ' /
159+
'(@document) and you passed none. This behavior will be removed in version 8')
160+
document = @document
161+
end
162+
render 'show_sidebar', document: document
158163
end
159164

160165
##
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<%= render :partial => 'show_tools' %>
2-
3-
<% unless @document.more_like_this.empty? %>
1+
<%= render 'show_tools' %>
2+
3+
<% unless document.more_like_this.empty? %>
44
<div class="card">
55
<div class="card-header">More Like This</div>
66
<div class="card-body">
7-
<%= render :collection => @document.more_like_this, :partial => 'show_more_like_this', :as => :document %>
7+
<%= render collection: document.more_like_this,
8+
partial: 'show_more_like_this',
9+
as: :document %>
810
</div>
911
</div>
10-
<% end %>
12+
<% end %>

app/views/catalog/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
<%= render_document_main_content_partial %>
99

1010
<% content_for(:sidebar) do %>
11-
<%= render_document_sidebar_partial %>
11+
<%= render_document_sidebar_partial @document %>
1212
<% end %>

spec/views/catalog/_show_sidebar.erb_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
end
1818

1919
it "shows more-like-this titles in the sidebar" do
20-
@document = SolrDocument.new id: 1, title_s: 'abc', format: 'default'
21-
allow(@document).to receive(:more_like_this).and_return([SolrDocument.new('id' => '2', 'title_tsim' => 'Title of MLT Document')])
22-
render
20+
document = SolrDocument.new id: 1, title_s: 'abc', format: 'default'
21+
allow(document).to receive(:more_like_this).and_return([SolrDocument.new('id' => '2', 'title_tsim' => 'Title of MLT Document')])
22+
render 'catalog/show_sidebar', document: document
2323
expect(rendered).to include("More Like This")
2424
expect(rendered).to include("Title of MLT Document")
2525
end

0 commit comments

Comments
 (0)