Remove unnecessary class method Upload.exist?

parent 04147857
......@@ -28,15 +28,11 @@ class Upload < ActiveRecord::Base
end
def self.hexdigest(absolute_path)
return unless exist?(absolute_path)
return unless File.exist?(absolute_path)
Digest::SHA256.file(absolute_path).hexdigest
end
def self.exist?(absolute_path)
File.exist?(absolute_path)
end
def absolute_path
return path unless relative_path?
......@@ -50,7 +46,7 @@ class Upload < ActiveRecord::Base
end
def exist?
self.class.exist?(absolute_path)
File.exist?(absolute_path)
end
private
......
......@@ -102,16 +102,6 @@ describe Upload, type: :model do
end
end
describe '.exist?' do
it 'returns true when the file exists' do
expect(described_class.exist?(__FILE__)).to eq true
end
it 'returns false when the file does not exist' do
expect(described_class.exist?("#{__FILE__}-nope")).to eq false
end
end
describe '#absolute_path' do
it 'returns the path directly when already absolute' do
path = '/path/to/namespace/project/secret/file.jpg'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment