Skip to content

Commit

Permalink
Pass locals from render_document_index to the index partial; fixes #872
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 8, 2014
1 parent 82870a7 commit 697bfd2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/blacklight/blacklight_helper_behavior.rb
Expand Up @@ -386,7 +386,7 @@ def document_index_view_type query_params=params
# @return [String]
def render_document_index documents = nil, locals = {}
documents ||= @document_list
render_document_index_with_view(document_index_view_type, documents)
render_document_index_with_view(document_index_view_type, documents, locals)
end

##
Expand Down
23 changes: 23 additions & 0 deletions spec/helpers/blacklight_helper_spec.rb
Expand Up @@ -570,4 +570,27 @@ def mock_document_app_helper_url *args
expect(subject).to have_selector "link[href='href']", visible: false
end
end

describe "#render_document_index" do
it "should render the document index with the current view type" do
helper.stub(document_index_view_type: :current_view)
helper.should_receive(:render_document_index_with_view).with(:current_view, [], a: 1, b: 2)
helper.render_document_index [], a: 1, b: 2
end
end

describe "#render_document_index_with_view" do
it "should ignore missing templates" do
helper.stub(:render) do |options|
if options[:partial] == "document_view_type"
raise ActionView::MissingTemplate.new [], '', '', '', ''
else
options[:partial]
end
end

response = helper.render_document_index_with_view :view_type, [double, double]
expect(response).to eq "catalog/document_view_type"
end
end
end

0 comments on commit 697bfd2

Please sign in to comment.