Skip to content

Commit

Permalink
Blacklight::Solr::Document#to_param should return a string to work wi…
Browse files Browse the repository at this point in the history
…th rails routing.

Fixes #638
  • Loading branch information
cbeer committed Feb 5, 2014
1 parent 486d8a2 commit 67c3df9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/blacklight/solr/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def id
end

def to_param
id
id.to_s
end

def as_json(options = nil)
Expand Down
7 changes: 7 additions & 0 deletions spec/helpers/url_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def params
@document = SolrDocument.new('id'=>'123456')
expect(link_to_document(@document,:label=>"Some crazy long label...")).to_not match(/title=/)
end

it "should work with integer ids" do
data = {'id'=> 123456 }
@document = SolrDocument.new(data)
expect(link_to_document(@document)).to have_selector("a")
end

end

describe "link_to_previous_search" do
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/blacklight/solr/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def my_extension_method
@document = MockDocument.new :id => 'asdf', :my_unique_key => '1234'
expect(@document.id).to eq '1234'
end

end

describe "#to_param" do
it "should be a string" do
@document = MockDocument.new :id => 1234
expect(@document.to_param).to eq '1234'
end
end

context "Extendability" do
Expand Down

0 comments on commit 67c3df9

Please sign in to comment.