From f155ff827064794059598cd52926a663a6205279 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 16 Oct 2015 17:08:16 -0400 Subject: [PATCH] FIX: Tests would fail if your test db's optimized image ids were high --- lib/file_store/base_store.rb | 6 +++++- spec/components/cooked_post_processor_spec.rb | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/file_store/base_store.rb b/lib/file_store/base_store.rb index 7e984a65288..275e78dff73 100644 --- a/lib/file_store/base_store.rb +++ b/lib/file_store/base_store.rb @@ -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 diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index e775d535424..1134278e227 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -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