Skip to content

Commit

Permalink
Merge pull request #1837 from samvera/fix-add_works_forward
Browse files Browse the repository at this point in the history
Adding works to collection forwards to collection admin show
  • Loading branch information
elrayle authored Oct 11, 2017
2 parents 8d35226 + 7949bb9 commit 7e17f2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/hyrax/dashboard/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def uploaded_files(uploaded_file_ids)
end

def update_referer
edit_dashboard_collection_path(@collection) + (params[:referer_anchor] || '')
return edit_dashboard_collection_path(@collection) + (params[:referer_anchor] || '') if params[:stay_on_edit]
dashboard_collection_path(@collection)
end

def determine_banner_data
Expand Down
1 change: 1 addition & 0 deletions app/views/hyrax/dashboard/collections/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</div>
<% end %>
<%= hidden_field_tag :type, params[:type] %>
<%= hidden_field_tag :stay_on_edit, true %>
<%= hidden_field_tag :collection_type_gid, @collection.collection_type_gid %>
<% if params[:batch_document_ids].present? %>
<% params[:batch_document_ids].each do |batch_item| %>
Expand Down
15 changes: 13 additions & 2 deletions spec/controllers/hyrax/dashboard/collections_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,27 @@
end
end

it "adds members to the collection" do
it "adds members to the collection from edit form" do
expect do
put :update, params: { id: collection,
collection: { members: 'add' },
batch_document_ids: [asset3.id] }
batch_document_ids: [asset3.id],
stay_on_edit: true }
end.to change { collection.reload.member_objects.size }.by(1)
expect(response).to redirect_to routes.url_helpers.edit_dashboard_collection_path(collection, locale: 'en')
expect(assigns[:collection].member_objects).to match_array [asset1, asset2, asset3]
end

it "adds members to the collection from other than the edit form" do
expect do
put :update, params: { id: collection,
collection: { members: 'add' },
batch_document_ids: [asset3.id] }
end.to change { collection.reload.member_objects.size }.by(1)
expect(response).to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en')
expect(assigns[:collection].member_objects).to match_array [asset1, asset2, asset3]
end

it "removes members from the collection" do
# TODO: Using size until count is fixed https://github.com/projecthydra-labs/activefedora-aggregation/issues/78
expect do
Expand Down

0 comments on commit 7e17f2f

Please sign in to comment.