class MartenRailsBridge::ActiveStorage::Representations::RedirectHandlerUrlFormatsTest

Overview

The URL formats a consumer can mount this handler on.

The handler reads the signed_blob_id and variation_key route parameters and never looks at the path, so every format below is served identically. These tests pin that, and pin the one way a consumer can get the route declaration wrong. :nodoc:

Defined in:

active_storage/representations/redirect_handler_test.cr

Constant Summary

BLOB_KEY = "gz0zdzhk0yn6zjhxfzl6qt1ys5rj"
MEDIUM_DIGEST = "1349c67feef77f80b95ba12d5ee190149ed47e212ff4fffb0a237b33a3c313a5"

Instance Method Summary

Instance Method Detail

def setup #

def teardown #

def test_a_custom_routes_prefix_resolves #

ActiveStorage.routes_prefix is configurable, so the prefix is not fixed.


def test_every_url_format_returns_404_for_a_tampered_variation_key #

def test_every_url_format_serves_the_same_redirect #

def test_legacy_route_declared_first_swallows_the_modern_path #

Declaring the pre-6.1 alias before the specific route makes it match redirect as the signed_blob_id, which then fails verification. Rails avoids this by drawing the alias last.


def test_the_filename_glob_spans_several_segments #

def test_the_filename_in_the_path_does_not_affect_the_response #

The filename only shapes the URL: Rails serves the variant filename derived from the blob, so a mismatched filename in the path changes nothing.


def test_the_filename_may_contain_spaces_and_dots #

def test_the_legacy_path_without_the_redirect_segment_resolves #

The pre-6.1 path, which Rails still ships as an unnamed alias of the redirect controller. A Rails app upgraded from 6.0 keeps serving URLs in this shape.


def test_the_named_redirect_path_resolves #

GET /rails/active_storage/representations/redirect/:signed_blob_id/:variation_key/*filename