Upgrade madmin to v2.x#371
Open
etagwerker wants to merge 6 commits into
Open
Conversation
Upgraded sass-rails from 5.0 to 6.0 (which uses sassc-rails 2.1) to support modern CSS features like rgb() syntax used in madmin 2.3.3. Updated SCSS files to properly escape calc() and min() expressions using unquote() to prevent SassC from trying to evaluate unit-mixed expressions at compile time. Added variables import to project.scss since each SCSS file is compiled independently. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The SassC/libsass CSS compressor re-parses already-compiled CSS and evaluates arithmetic inside calc()/min() (e.g. `100vh - 160px`), raising "Incompatible units: 'px' and 'vh'" on otherwise valid CSS. This only manifests during production precompilation, since the compressor does not run in development. Setting css_compressor to nil explicitly (sprockets-rails defaults to :sass when sassc is present) skips CSS compression while keeping terser for JS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover every route under /madmin with integration (request) specs: - Authorization: unauthenticated and non-admin users are redirected to the root path; admins get access across all controllers. - Dashboard: GET /madmin renders successfully (guards against layout / partial regressions like the removed npm_rails_version helper). - Each resource (projects, stories, estimates, users, version_jumps): index/new/show, plus create/update/destroy where those routes exist. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
madmin 2.x dropped the madmin/pagy/_nav partial and renders pagination via pagy's own helpers. The app's overridden index.html.erb still rendered the old partial, raising ActionView::MissingTemplate for any resource list with more than one page (pagy's default limit is 20). Replace the stale partial render with pagy's helpers, mirroring the gem's own index template (series_nav/info_tag on pagy 43+, pagy_nav/pagy_info on older versions). Add a request spec that creates 21 records to exercise the multi-page path, which the single-record index specs never hit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Upgrades the app’s admin interface dependency (madmin) from 1.x to 2.x to restore compatibility with Ruby 3.4, and updates supporting views/assets/tests to match the newer madmin + pagy + sass-rails behavior.
Changes:
- Bump
madminto~> 2.0(and update related dependencies likepagy,sass-rails,sprocketsin the lockfile). - Update madmin view overrides to work with madmin 2.x (pagination rendering + replacing removed
npm_rails_versionhelper behavior). - Add request specs covering madmin authorization and key CRUD/navigation routes, plus a pagination regression spec; adjust production CSS compressor behavior and SCSS output for modern CSS functions.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/madmin/authorization_spec.rb | Adds request coverage to ensure non-admins are redirected and admins can access madmin routes. |
| spec/requests/madmin/dashboard_spec.rb | Smoke test for the madmin dashboard and shared layout rendering. |
| spec/requests/madmin/estimates_spec.rb | Request coverage for estimates index/new/show/destroy in madmin. |
| spec/requests/madmin/pagination_spec.rb | Regression test for pagination rendering when results exceed one page. |
| spec/requests/madmin/projects_spec.rb | Request coverage for projects index/new/show/destroy in madmin. |
| spec/requests/madmin/stories_spec.rb | Request coverage for stories CRUD routes in madmin. |
| spec/requests/madmin/users_spec.rb | Request coverage for users index/new/show/destroy in madmin. |
| spec/requests/madmin/version_jumps_spec.rb | Request coverage for version_jumps CRUD routes in madmin. |
| Gemfile | Bumps madmin and sass-rails constraints to match the new dependency requirements. |
| Gemfile.lock | Locks updated versions for madmin 2.x and its dependency graph (notably pagy/sprockets-related changes). |
| config/environments/production.rb | Disables the Sass-based CSS compressor in production to avoid invalid calc/min evaluation errors. |
| app/views/madmin/application/index.html.erb | Reworks pagination rendering to avoid the removed madmin/pagy/_nav partial and support newer pagy APIs. |
| app/views/madmin/application/_javascript.html.erb | Restores npm_rails_version behavior locally for importmap URLs after upstream helper removal. |
| app/assets/stylesheets/stories.scss | Prevents Sass re-processing of CSS min() by emitting it as a literal string. |
| app/assets/stylesheets/project.scss | Imports shared variables to ensure $white and other variables are available under the updated Sass toolchain. |
| app/assets/stylesheets/4-molecules/_floors.scss | Prevents Sass re-processing of CSS calc() by emitting it as a literal string. |
| app/assets/stylesheets/1-utilities/_basic.scss | Prevents Sass re-processing of CSS calc() by emitting it as a literal string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| get "/madmin/projects" | ||
|
|
||
| expect(response).to have_http_status(:ok) | ||
| expect(response.body).to include(project.title.truncate(20)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / Context
Using madmin 1.2.8 with ruby 3.4 is raising this error:
QA / Testing Instructions
Smoke test madmin interface.
I will abide by the code of conduct.