FIX: Tests would fail if your test db's optimized image ids were high

This commit is contained in:
Robin Ward 2015-10-16 17:08:16 -04:00
parent 9e01a7d834
commit f155ff8270
2 changed files with 8 additions and 1 deletions

View File

@ -71,8 +71,12 @@ module FileStore
def purge_tombstone(grace_period)
end
def get_depth_for(id)
[0, Math.log(id / 1_000.0, 16).ceil].max
end
def get_path_for(type, id, sha, extension)
depth = [0, Math.log(id / 1_000.0, 16).ceil].max
depth = get_depth_for(id)
tree = File.join(*sha[0, depth].split(""), "")
"#{type}/#{depth + 1}X/#{tree}#{sha}#{extension}"
end

View File

@ -114,6 +114,8 @@ describe CookedPostProcessor do
# hmmm this should be done in a cleaner way
OptimizedImage.expects(:resize).returns(true)
FileStore::BaseStore.any_instance.expects(:get_depth_for).returns(0)
end
it "generates overlay information" do
@ -141,6 +143,7 @@ describe CookedPostProcessor do
# hmmm this should be done in a cleaner way
OptimizedImage.expects(:resize).returns(true)
FileStore::BaseStore.any_instance.expects(:get_depth_for).returns(0)
end
it "generates overlay information" do