Skip to content

fix(generate): scaffold, api and auth output compile and pass on Amber V2 - #41

Merged
crimson-knight merged 5 commits into
mainfrom
fix/generator-v2-apps
Oct 2, 2026
Merged

crimson-knight merged 5 commits into
mainfrom
fix/generator-v2-apps

Conversation

@crimson-knight

Copy link
Copy Markdown
Member

Generated apps now compile and pass their own specs. Found by generating a fresh app against the new Grant (ActiveRecord parity wave 1).

  • Scaffold/API index use an explicit order(id: :desc) (Grant no longer adds an implicit ORDER BY id DESC).
  • .gitignore ignores *.db, *.db-wal, *.db-shm (SQLite runs in WAL mode).
  • field:reference emits belongs_to (which declares <field>_id); forms, controllers and specs use <field>_id.
  • generate api uses respond_with (Amber 2.0.0-beta.5 rejects render json:) and inserts the /api routes above the static wildcard.
  • generate auth [Name] defaults to User, stores a stdlib Crypto::Bcrypt::Password digest, adds authenticate, and renders compiling forms with csrf_tag. No new dependency.
  • Generated POST/PUT/DELETE specs run with a real CSRF token (spec/support/csrf_helpers.cr) instead of being commented out; CSRF stays on.
  • time fields render in the scaffold form.

Verified: a fresh app with scaffold Post, scaffold Comment post:reference, api Product and auth builds with no warnings; its generated specs pass 44/44 on the pinned Grant and 54/54 on the new Grant. amber_cli specs: 419 examples, 0 failures (with bin/amber-lsp built).

…n Amber V2 and Grant

- order index listings explicitly with order(id: :desc)
- reference fields emit belongs_to with a <name>_id foreign key, schema, form, and specs
- api controllers use respond_with { json ... } and routes are added under /api ahead of the static wildcard
- auth generates a bcrypt-backed model with authenticate, plain <form> views, routes, and specs; the name defaults to User
- write specs send a CSRF token through spec/support/csrf_helpers.cr instead of being commented out
- time fields render with to_rfc3339 in the form
The generated spec_helper loaded config/ without setting AMBER_ENV, so
crystal spec wrote to the development database. The new scaffold specs
create records, which left the smoke test's first POST at /pets/8
instead of /pets/1. Default AMBER_ENV to test before config loads.
install-crystal runs apt-get install without apt-get update; the runner
image's stale index now 404s on superseded libevent packages.
@crimson-knight
crimson-knight marked this pull request as ready for review October 2, 2026 23:59
@crimson-knight
crimson-knight merged commit 5ef6ffb into main Oct 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant