Skip to content

Commit

Permalink
Merge pull request #6231 from samvera/banner-info-deprecation
Browse files Browse the repository at this point in the history
remove deprecated argument from CollectionBrandingInfo#delete
  • Loading branch information
dlpierce authored Sep 11, 2023
2 parents 53fffda + bfe5096 commit 1fd0c32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
11 changes: 2 additions & 9 deletions app/models/collection_branding_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ def save(file_location, upload_file = true)
super()
end

def delete(location_path = nil)
id = if location_path
Deprecation.warn('Passing an explict location path is ' \
'deprecated. Call without arguments instead.')
location_path
else
local_path
end
storage.delete(id: id)
def delete(_location_path = nil)
storage.delete(id: local_path)
end

def find_local_filename(collection_id, role, filename)
Expand Down
22 changes: 9 additions & 13 deletions spec/models/collection_branding_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,16 @@
end

describe '#delete' do
it "removes banner file from public directory" do
banner_info.save(file.path)
banner_info.delete(banner_info.find_local_dir_name('123', 'banner') + "/banner.gif")

expect { storage_adapter.find_by(id: banner_info.local_path) }
.to raise_error Valkyrie::StorageAdapter::FileNotFound
end

it "removes logo file from public directory" do
logo_info.save(file.path)
logo_info.delete(logo_info.find_local_dir_name('123', 'logo') + "/logo.gif")
before { banner_info.save(file.path) }

expect { storage_adapter.find_by(id: logo_info.local_path) }
.to raise_error Valkyrie::StorageAdapter::FileNotFound
it "removes banner file" do
expect { banner_info.delete }.to change {
begin
storage_adapter.find_by(id: banner_info.local_path)
rescue Valkyrie::StorageAdapter::FileNotFound
'Raised FileNotFound' # Convert the raised error so change can detect it
end
}.from(be_a(Valkyrie::StorageAdapter::File)).to(eq 'Raised FileNotFound')
end
end
end

0 comments on commit 1fd0c32

Please sign in to comment.