class ActiveStorage::Blob::RepresentableTest

Overview

How a variant is located depends on what the Rails app wrote: a tracked record when config.active_storage.track_variants is on (the default from load_defaults 6.1), the derived key when it is off, and neither when nothing has processed the variation yet. :nodoc:

Defined in:

active_storage/blob/representable_test.cr

Constant Summary

BLOB_KEY = "gz0zdzhk0yn6zjhxfzl6qt1ys5rj"
DERIVED_KEY = "variants/#{BLOB_KEY}/1349c67feef77f80b95ba12d5ee190149ed47e212ff4fffb0a237b33a3c313a5"

variants/<blob key>/<SHA256 hexdigest of the signed variation key>, the untracked layout.

MEDIUM = "{\"format\":\"jpg\",\"resize_to_fill\":[500,500]}"
MEDIUM_DIGEST = "spWDgYmFptMnmwEsfcpfOPL1tZA="

Instance Method Summary

Instance Method Detail

def setup #

def teardown #

def test_a_record_for_another_variation_falls_back_to_the_derived_key #

def test_a_record_without_an_attached_image_falls_back_to_the_derived_key #

def test_a_stored_derived_object_is_used_without_a_record #

The middle step: no record, but an untracked Rails app wrote the object, so it is served from there. This is what lets one deployment serve both layouts.


def test_a_tracked_variant_is_resolved_without_a_storage_probe #

A tracked record is enough on its own, so the storage is never asked.


def test_a_tracked_variant_resolves_to_the_variant_blob #

def test_a_variation_nothing_stored_resolves_to_the_tracked_layout #

Nothing stored either layout, so the variation is processed, and which layout it is written in is what track_variants decides.


def test_the_derived_key_is_used_when_track_variants_is_off #

Turning the lookup off skips the record query and the probe both, so a tracked variant is no longer found and the derived key is written if nothing is there.


def test_the_two_layouts_do_not_share_a_key #

def test_the_url_follows_the_resolved_variant #