spec/paperclip/attachment_spec.rb in paperclip-5.1.0 vs spec/paperclip/attachment_spec.rb in paperclip-5.2.0
- old
+ new
@@ -498,10 +498,11 @@
it "only processes the provided style" do
@attachment.expects(:post_process).with(:thumb)
@attachment.expects(:post_process).with(:large).never
@attachment.assign(@file)
+ @attachment.save
end
end
context "An attachment with :convert_options that is a proc" do
before do
@@ -1431,19 +1432,49 @@
it "does not error when assigned an attachment" do
assert_nothing_raised { @dummy.avatar = @file }
end
- it "returns the right value when sent #avatar_fingerprint" do
- @dummy.avatar = @file
- assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_fingerprint
+ context "with explicitly set digest" do
+ before do
+ rebuild_class adapter_options: { hash_digest: Digest::SHA256 }
+ @dummy = Dummy.new
+ end
+
+ it "returns the right value when sent #avatar_fingerprint" do
+ @dummy.avatar = @file
+ assert_equal "734016d801a497f5579cdd4ef2ae1d020088c1db754dc434482d76dd5486520a",
+ @dummy.avatar_fingerprint
+ end
+
+ it "returns the right value when saved, reloaded, and sent #avatar_fingerprint" do
+ @dummy.avatar = @file
+ @dummy.save
+ @dummy = Dummy.find(@dummy.id)
+ assert_equal "734016d801a497f5579cdd4ef2ae1d020088c1db754dc434482d76dd5486520a",
+ @dummy.avatar_fingerprint
+ end
end
- it "returns the right value when saved, reloaded, and sent #avatar_fingerprint" do
- @dummy.avatar = @file
- @dummy.save
- @dummy = Dummy.find(@dummy.id)
- assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_fingerprint
+ context "with the default digest" do
+ before do
+ rebuild_class # MD5 is the default
+ @dummy = Dummy.new
+ end
+
+ it "returns the right value when sent #avatar_fingerprint" do
+ @dummy.avatar = @file
+ assert_equal "aec488126c3b33c08a10c3fa303acf27",
+ @dummy.avatar_fingerprint
+ end
+
+ it "returns the right value when saved, reloaded, and sent #avatar_fingerprint" do
+ @dummy.avatar = @file
+ @dummy.save
+ @dummy = Dummy.find(@dummy.id)
+ assert_equal "aec488126c3b33c08a10c3fa303acf27",
+ @dummy.avatar_fingerprint
+ end
end
end
end
context "an attachment with delete_file option set to false" do