Skip to content

Fix Coverband auth and clean up config#167

Merged
JuanVqz merged 4 commits intorailsbump:mainfrom
JuanVqz:fix/coverband-auth
Apr 9, 2026
Merged

Fix Coverband auth and clean up config#167
JuanVqz merged 4 commits intorailsbump:mainfrom
JuanVqz:fix/coverband-auth

Conversation

@JuanVqz
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz commented Apr 9, 2026

Summary

  • Fix NoMethodError on Coverband::Reporters::Web.use (it's a plain Rack app, not Sinatra)
  • Use Coverband's built-in config.password for auth instead of a custom Rack middleware wrapper
  • Require COVERBAND_PASSWORD env var in production (app crashes on boot if missing, preventing open access)
  • Move config from config/initializers/coverband.rb to config/coverband.rb per Coverband docs
  • Add config.logger = Rails.logger
  • Remove unnecessary require "coverband" from routes (Railtie handles it)

JuanVqz added 4 commits April 9, 2026 12:23
Coverband::Reporters::Web is a plain Rack app, not Sinatra, so it
doesn't respond to .use. Wrap it with Rack::Builder to add Basic Auth.
The error only occurred in production because the code was inside an
`if Rails.env.production?` guard.
- Use config.password instead of Rack::Builder wrapper for auth
- Move config from config/initializers/coverband.rb to config/coverband.rb
  per Coverband docs
- Remove redundant track_views (true by default)
- Add config.logger = Rails.logger
- Remove unnecessary require "coverband" from routes (Railtie handles it)
Coverband skips auth entirely when password is nil. Use ENV.fetch
so the app fails to boot if the var is missing in production,
rather than silently exposing coverage data. Skip in dev/test.
@JuanVqz JuanVqz requested a review from a team April 9, 2026 18:35
@JuanVqz JuanVqz self-assigned this Apr 9, 2026
@JuanVqz JuanVqz merged commit 69244cd into railsbump:main Apr 9, 2026
2 checks passed
@JuanVqz JuanVqz changed the title Fix Coverband NoMethodError on .use Fix Coverband auth and clean up config Apr 9, 2026
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