From bee68bba2e2a354fd79178c6a08bc90cf419f5cd Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 16 Jan 2019 15:01:50 -0500 Subject: [PATCH] FIX: Heisentest We use the `id` of the upload to calculate a `depth` partition in the filename. This test would fail if your database had a higher seed because the depth it was looking for was hard coded to 1. The solution was to not save the records (which is faster anyway) and specify the `id` of the upload to make the hash deterministic. --- spec/components/file_store/base_store_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/components/file_store/base_store_spec.rb b/spec/components/file_store/base_store_spec.rb index 3de0ff2948..623b164478 100644 --- a/spec/components/file_store/base_store_spec.rb +++ b/spec/components/file_store/base_store_spec.rb @@ -21,16 +21,16 @@ RSpec.describe FileStore::BaseStore do end describe '#get_path_for_optimized_image' do - let(:upload) { Fabricate(:upload) } + let(:upload) { Fabricate.build(:upload, id: 100) } let(:optimized_path) { "optimized/1X/#{upload.sha1}_1_100x200.png" } it 'should return the right path' do - optimized = Fabricate(:optimized_image, upload: upload, version: 1) + optimized = Fabricate.build(:optimized_image, upload: upload, version: 1) expect(FileStore::BaseStore.new.get_path_for_optimized_image(optimized)).to eq(optimized_path) end it 'should return the right path for `nil` version' do - optimized = Fabricate(:optimized_image, upload: upload, version: nil) + optimized = Fabricate.build(:optimized_image, upload: upload, version: nil) expect(FileStore::BaseStore.new.get_path_for_optimized_image(optimized)).to eq(optimized_path) end end