From 774c95a23b876e7491cff8e0181d2a6a86b2e941 Mon Sep 17 00:00:00 2001 From: Blanco Date: Thu, 2 Nov 2017 15:15:46 -0400 Subject: [PATCH] don't process banner and logo when adding work to collection --- .../hyrax/dashboard/collections_controller.rb | 7 +++++-- .../dashboard/collections_controller_spec.rb | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/controllers/hyrax/dashboard/collections_controller.rb b/app/controllers/hyrax/dashboard/collections_controller.rb index c4c0897ee7..703ca61973 100644 --- a/app/controllers/hyrax/dashboard/collections_controller.rb +++ b/app/controllers/hyrax/dashboard/collections_controller.rb @@ -148,8 +148,11 @@ def after_update_error end def update - process_banner_input - process_logo_input + unless params[:update_collection].nil? + process_banner_input + process_logo_input + end + process_member_changes @collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable? visiblity_updated = (@collection.visibility != collection_params[:visibility]) diff --git a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb index 9c3e33dec5..70406e0cb2 100644 --- a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb @@ -250,11 +250,24 @@ allow(File).to receive(:split).with(any_args).and_return(["banner.gif"]) allow(FileUtils).to receive(:cp).with(any_args).and_return(nil) - put :update, params: { id: collection, banner_files: [1], collection: { creator: ['Emily'] } } + put :update, params: { id: collection, banner_files: [1], collection: { creator: ['Emily'] }, update_collection: true } collection.reload expect(CollectionBrandingInfo.where(collection_id: collection.id, role: "banner").where("local_path LIKE '%banner.gif'")).to exist end + it "don't save banner metadata" do + val = double("/public/banner.gif") + allow(val).to receive(:file_url).and_return("/public/banner.gif") + allow(Hyrax::UploadedFile).to receive(:find).with(["1"]).and_return([val]) + + allow(File).to receive(:split).with(any_args).and_return(["banner.gif"]) + allow(FileUtils).to receive(:cp).with(any_args).and_return(nil) + + put :update, params: { id: collection, banner_files: [1], collection: { creator: ['Emily'] } } + collection.reload + expect(CollectionBrandingInfo.where(collection_id: collection.id, role: "banner").where("local_path LIKE '%banner.gif'")).not_to exist + end + it "saves logo metadata" do val = double(["/public/logo.gif"]) allow(val).to receive(:file_url).and_return("/public/logo.gif") @@ -263,7 +276,7 @@ allow(File).to receive(:split).with(any_args).and_return(["logo.gif"]) allow(FileUtils).to receive(:cp).with(any_args).and_return(nil) - put :update, params: { id: collection, logo_files: [1], alttext: ["Logo alt Text"], linkurl: ["http://abc.com"], collection: { creator: ['Emily'] } } + put :update, params: { id: collection, logo_files: [1], alttext: ["Logo alt Text"], linkurl: ["http://abc.com"], collection: { creator: ['Emily'] }, update_collection: true } collection.reload expect(CollectionBrandingInfo.where(collection_id: collection.id, role: "logo", alt_text: "Logo alt Text", target_url: "http://abc.com").where("local_path LIKE '%logo.gif'")).to exist