Skip to content

Commit

Permalink
Merge pull request #2100 from samvera/coll-2073
Browse files Browse the repository at this point in the history
don't process banner and logo when adding work to collection
  • Loading branch information
elrayle authored Nov 3, 2017
2 parents 9f4340a + 774c95a commit f1b3742
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/controllers/hyrax/dashboard/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
17 changes: 15 additions & 2 deletions spec/controllers/hyrax/dashboard/collections_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit f1b3742

Please sign in to comment.