Skip to content

Rails Engine integration - #5

Merged
hahuang65 merged 5 commits into
mainfrom
hh/rails-engine
Jun 10, 2026
Merged

Rails Engine integration#5
hahuang65 merged 5 commits into
mainfrom
hh/rails-engine

Conversation

@hahuang65

Copy link
Copy Markdown
Member
  • CHORE: Move docs/claude to docs/features
  • Migrate workflows to Blacksmith
  • FEATURE: Mountable Rails engine with full sign-in flow
  • REFACTOR: Split test suite into separate unit and engine tasks
  • CHORE: Suppress CGI deprecation warning from mocha

hahuang65 and others added 3 commits June 9, 2026 23:50
Add a mountable Rails engine (Bitsmithy::Auth::Engine) that owns the
entire sign-in flow — send code, verify code, and sign out — with five
engine routes, a self-contained SessionsController, I18n error messages,
and an opt-in require_authentication! guard.

What is this change?

Introduces the engine at lib/bitsmithy/auth/engine.rb with isolate_namespace,
routes defined in config/routes.rb (so the reloader re-draws them on
reload!), and a SessionsController that includes both the shared Controller
concern and the Concerns::Localization error-resolution module. Ships an en
locale file covering invalid_phone_number, rate_limited, and invalid_code.
Adds configuration options for after_sign_in_path, after_sign_out_path,
sign_in_path, and an on_verified callback.

Why is the change being made?

The prior v0.1.0 release required host apps to write their own sign-in
controller — roughly thirty lines of boilerplate. A mountable engine
eliminates that boilerplate while remaining self-contained (no dependency
on the host's ApplicationController). Host apps need only provide two view
templates (phone form, code form) and one line in routes.
@hahuang65 hahuang65 changed the title hh/rails engine Rails Engine integration Jun 10, 2026
Run the framework-agnostic unit tests and the Rails engine integration
tests as separate Ruby processes so they no longer conflict when invoked
together.

What is this change?

Replaces the single Minitest::TestTask (which globbed all test/**/test_*.rb
into one process) with two named tasks:
  - `rake unit`   — test/bitsmithy/**/test_*.rb (no Rails boot)
  - `rake engine` — test/engine/**/test_*.rb    (full Rails app)
`rake test` runs both in sequence, each in its own process. Adds announce
banners so output is clearly separated.

Why is the change being made?

The unit tests define a lightweight Rails env stub (RailsEnvStub) with a
simple attr_accessor for Rails.env. The engine tests load Railties, which
overrides Rails.env= to create an EnvironmentInquirer requiring a String
argument. Running both suites in the same Ruby process causes
TypeError: no implicit conversion of RailsEnvStub into String.
Running them as separate processes avoids all shared-state conflicts.
Add cgi gem to the test group so mocha's equivalent_uri.rb can
resolve CGI.escape without triggering a Ruby 4.0 removal warning.
@hahuang65
hahuang65 merged commit adf5d74 into main Jun 10, 2026
2 checks passed
@hahuang65
hahuang65 deleted the hh/rails-engine branch June 10, 2026 19:18
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