diff --git a/app/models/upload.rb b/app/models/upload.rb index bfb3fd2eddb..5244d1e9496 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -138,7 +138,7 @@ class Upload < ActiveRecord::Base end def base62_sha1 - Upload.base62_sha1(upload.sha1) + Upload.base62_sha1(self.sha1) end def local? diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 9a62b088d09..44ff1f1fd2d 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -253,6 +253,13 @@ describe Upload do end end + describe '#base62_sha1' do + it 'should return the right value' do + upload.update!(sha1: "0000c513e1da04f7b4e99230851ea2aafeb8cc4e") + expect(upload.base62_sha1).to eq("1Eg9p8rrCURq4T3a6iJUk0ri6") + end + end + describe '.sha1_from_short_path' do it "should be able to lookup sha1" do path = "/uploads/short-url/3UjQ4jHoyeoQndk5y3qHzm3QVTQ.png"