Skip to content

Commit

Permalink
Allow partials to pass url options through to the document actions
Browse files Browse the repository at this point in the history
When rendering actions on the bookmarks page, the actions should assume the
current search context (page, per_page, etc).
  • Loading branch information
cbeer committed Nov 21, 2014
1 parent 13bec76 commit 22244dd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/bookmarks/_tools.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="<%= controller_name %>Tools nav nav-pills">
<%= render_show_doc_actions document_list do |config, inner| %>
<%= render_show_doc_actions document_list, document: nil, document_list: @document_list, url_opts: sanitize_search_params(params) do |config, inner| %>
<li>
<%= inner %>
</li>
Expand Down
5 changes: 4 additions & 1 deletion app/views/catalog/_document_action.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<%= link_to action_label(document_action_config.key, document_action_config), action_path(document_action_config, id: document), id: document_action_config.fetch(:id, "#{document_action_config.key}Link"), data: {}.merge(({ajax_modal: "trigger"} if document_action_config.modal != false) || {}) %>
<%= link_to action_label(document_action_config.key, document_action_config),
action_path(document_action_config, (respond_to?(:url_opts) ? url_opts : {}).merge(({id: document} if document) || {})),
id: document_action_config.fetch(:id, "#{document_action_config.key}Link"),
data: {}.merge(({ajax_modal: "trigger"} if document_action_config.modal != false) || {}) %>
25 changes: 25 additions & 0 deletions spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
expect(page).to have_content 'Cleared your bookmarks.'
expect(page).to have_content 'You have no bookmarks'
end

it "add and remove bookmarks from search results" do
sign_in 'user1'
visit root_path
Expand Down Expand Up @@ -56,6 +57,30 @@
expect(page).to have_content 'Strong Medicine speaks'
end

it "should cite items in current bookmarks page" do
visit catalog_path('2009373513')
click_button 'Bookmark'

visit catalog_path('2007020969')
click_button 'Bookmark'

visit "/bookmarks?per_page=1"
expect(page).to have_content 'Ci an zhou bian'
expect(page).not_to have_content 'Strong Medicine speaks'

click_link 'Cite'
expect(page).to have_content 'Ci an zhou bian'
expect(page).not_to have_content 'Strong Medicine speaks'

visit "/bookmarks?per_page=1"
click_link "2"
expect(page).to have_content 'Strong Medicine speaks'

click_link 'Cite'
expect(page).to have_content 'Strong Medicine speaks'
expect(page).not_to have_content 'Ci an zhou bian'
end

it "should have an endnote export" do
visit catalog_path('2007020969')
click_button 'Bookmark'
Expand Down

0 comments on commit 22244dd

Please sign in to comment.