From 23c1bc62ea3644636c0edce8ccee39f2094db190 Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Sat, 14 Feb 2015 18:46:14 -0500 Subject: [PATCH] 5096: if only collection name or description is being updated, do not include manifest_text in the request. --- .../app/controllers/collections_controller.rb | 15 +++++++++++++++ .../controllers/collections_controller_test.rb | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index 3ef46887d8..d9bf3a96cc 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -266,6 +266,21 @@ class CollectionsController < ApplicationController sharing_popup end + def update + @updates ||= params[@object.resource_param_name.to_sym] + if @updates && (@updates.keys - ["name", "description"]).empty? + # exclude manifest_text since only name or description is being updated + @object.manifest_text = nil + if @object.update_attributes @updates + show + else + self.render_error status: 422 + end + else + super + end + end + protected def find_usable_token(token_list) diff --git a/apps/workbench/test/controllers/collections_controller_test.rb b/apps/workbench/test/controllers/collections_controller_test.rb index 45124f7a9e..8518378097 100644 --- a/apps/workbench/test/controllers/collections_controller_test.rb +++ b/apps/workbench/test/controllers/collections_controller_test.rb @@ -355,4 +355,19 @@ class CollectionsControllerTest < ActionController::TestCase assert /#{stage3_id}->#{stage3_out}/.match(used_by_svg) end + + test "update description and check manifest_text is not lost" do + collection = api_fixture("collections")["multilevel_collection_1"] + post :update, { + id: collection["uuid"], + collection: { + description: 'test description update' + }, + format: :json + }, session_for(:active) + assert_response :success + assert_not_nil assigns(:object) + assert_equal 'test description update', assigns(:object).description + assert_equal collection['manifest_text'], assigns(:object).manifest_text + end end -- 2.30.2