Presubmit.Assertions.Phoenix (presubmit v0.2.2)

Copy Markdown View Source

Assertions over Phoenix routers, controllers, and LiveViews, built on Presubmit.Adapters.PhoenixRouter and Presubmit.Adapters.PhoenixHandler.

Summary

Functions

Asserts every controller or LiveView the commit adds is routed by some router in the resulting tree.

Routes added by the commit, across every router it touched.

Routes removed by the commit.

Functions

assert_routed(commit)

@spec assert_routed(Presubmit.Commit.t()) :: :ok

Asserts every controller or LiveView the commit adds is routed by some router in the resulting tree.

Routers are discovered across the tree, and plug modules are resolved through scope aliasing exactly as Phoenix does, so this holds whether the route was added in this commit or an earlier one, and fails even when the router file was edited for an unrelated reason.

Not every controller is routed by design: action_fallback targets are exempt, and so is any module a router names at all — custom route macros and forwarded plugs mention their modules without the adapter knowing what the macro does.

routes_added(commit)

Routes added by the commit, across every router it touched.

routes_removed(commit)

Routes removed by the commit.