Skip to content

Commit

Permalink
Merge pull request #834 from projectblacklight/issue-833
Browse files Browse the repository at this point in the history
deep-merge context data attributes with link_to_document options; fixes #833
  • Loading branch information
jcoyne committed Mar 12, 2014
2 parents 49e53f4 + 0954083 commit a65fb7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/blacklight/url_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def link_to_document(doc, opts={:label=>nil, :counter => nil})
end

def document_link_params(doc, opts)
session_tracking_params(doc, opts[:counter]).merge(opts.reject { |k,v| [:label, :counter].include? k })
session_tracking_params(doc, opts[:counter]).deep_merge(opts.except(:label, :counter))
end
protected :document_link_params

Expand Down
8 changes: 8 additions & 0 deletions spec/helpers/url_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@
expect(helper.link_to_document(@document, { :label => :title_display, :counter => 5 })).to match /\/catalog\/123456\/track\?counter=5/
end

it "should merge the data- attributes from the options with the counter params" do
data = {'id'=>'123456','title_display'=>['654321']}
@document = SolrDocument.new(data)
link = helper.link_to_document @document, { data: { x: 1 } }
expect(link).to have_selector '[data-x]'
expect(link).to have_selector '[data-context-href]'
end

it "passes on the title attribute to the link_to_with_data method" do
@document = SolrDocument.new('id'=>'123456')
expect(helper.link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
Expand Down

0 comments on commit a65fb7d

Please sign in to comment.