Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9121 +/- ##
=======================================
Coverage 99.11% 99.12%
=======================================
Files 139 140 +1
Lines 4071 4115 +44
=======================================
+ Hits 4035 4079 +44
Misses 36 36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is focused and well tested; only minor documentation wording remains.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds an explicit numeric range filter using inclusive Ransack bounds.
Changes:
- Adds
NumericRangeInputwith configurable number fields. - Adds unit and feature coverage.
- Documents the new filter type.
| File | Description |
|---|---|
lib/active_admin/inputs/filters/numeric_range_input.rb |
Implements the range input. |
lib/active_admin/inputs.rb |
Registers the input class. |
spec/helpers/filter_form_helper_spec.rb |
Tests rendering and options. |
features/index/filters.feature |
Tests end-to-end filtering. |
features/step_definitions/filter_steps.rb |
Adds range-filter assertion. |
features/step_definitions/factory_steps.rb |
Creates positioned test posts. |
spec/support/templates_with_data/admin/posts.rb |
Configures a numeric range filter. |
docs/3-index-pages.md |
Documents the filter type. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fde3d83 to
51739b6
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The upper-bound field lacks a reliable accessible label, and the documentation examples misstate what the declarations configure.
Review effort: Balanced
Findings: 1
Open (2)
Resolved since last review (1)
| def attribute_label | ||
| localized_label || humanized_method_name | ||
| end |
There was a problem hiding this comment.
Astra here — this specific finding is a false positive. The gemspec at the reviewed revision requires formtastic >= 6.0: 6.0 is the minimum, not an exclusive major-version constraint. Older Formtastic releases are outside this branch's supported range. I checked Formtastic 6.0.0, the minimum supported release, where localized_label already calls label_from_options:
def localized_label
localized_string(method, label_from_options || method, :label)
endI rendered the input at 6587a30 with label: "Rank" and checked the parsed HTML attributes, not just the visible label. The two inputs have aria-label="Rank From" and aria-label="Rank To", not “Position From/To”. A proc label also passes through ActiveAdmin's label_from_options override correctly. No extra call to label_from_options is needed for this case.
There is a separate double-escaping issue for labels containing ampersands/apostrophes, documented in this finding.
AI reviewer: openai-codex/gpt-6-astra · reasoning: high
There was a problem hiding this comment.
One accessibility issue to fix: labels containing HTML-sensitive characters are double-escaped in the new aria-label attributes (inline example below).
I could not reproduce Copilot's outstanding label: "Rank" finding: Formtastic 6's localized_label already calls label_from_options, including ActiveAdmin's proc handling. Both a string label and a proc label rendered matching accessible names in an isolated check.
The same check reproduced the escaping defect with Formtastic 6.0.0 / Action View 8.1.3.1 / Ruby 4.0.7 at this commit; assertions comparing parsed input attributes with the visible label failed for Profit & Loss and Player's rank, while the plain-string/proc controls passed. Required CI is green; I did not rerun the full suite.
AI reviewer: openai-codex/gpt-6-astra · reasoning: high
| input_html_options.merge( | ||
| id: dom_id_for(input_name), | ||
| placeholder: placeholder, | ||
| "aria-label": "#{attribute_label} #{placeholder}", |
There was a problem hiding this comment.
[P2] Avoid double-escaping the accessible label
localized_label returns HTML-escaped text by default. Interpolating it into a regular string here and passing it through number_field escapes it again. For example, filter :position, as: :numeric_range, label: "Profit & Loss" renders aria-label="Profit & Loss From"; after HTML parsing the accessible name is literally Profit & Loss From, whereas the visible label is Profit & Loss. For an English apostrophe example, label: "Player's rank" renders aria-label="Player's rank From", whose parsed value is literally Player's rank From. This affects both bounds and makes assistive technologies receive entity syntax rather than the displayed label.
Please derive a plain-text accessible label before Rails performs attribute escaping (or reference the visible label with aria-labelledby) and cover ampersands/apostrophes in a regression test. Do not mark the whole interpolated attribute HTML-safe, since attribute escaping must remain intact.
There was a problem hiding this comment.
@tagliala thanks.
I could not avoid the escaping, so the fix undoes it. Localizer#localize escapes
unconditionally — String :label at line 64, i18n result at line 109 — and the only
switch, escape_html_entities_in_hints_and_labels, is global (form_builder.rb:33),
so flipping it would change every label in the gem.
def attribute_label
CGI.unescapeHTML(localized_label || humanized_method_name)
endlabel: |
visible | announced |
|---|---|---|
"Profit & Loss" |
Profit & Loss | Profit & Loss From |
"Bob's rank" |
Bob's rank | Bob's rank From |
proc { "A & B" } |
A & B | A & B From |
aria-labelledby would need extra hidden elements, since one label serves both
bounds. Rebuilding the name from a second lookup could drift from the visible label —
Formtastic also resolves the formtastic.labels.* scopes — and matching it is the
point. Not elegant, happy to switch if you see a cleaner seam. The attribute is not
marked html_safe.
Regression test covers both characters; reverting the fix fails it:
expected to find css "[aria-label=\"Bob's profit & loss From\"]" but there were no matches
There was a problem hiding this comment.
Astra here — @tagliala, the human maintainer, favored this compromise and asked me to challenge it. After inspecting the implementation and regression test, I agree on technical grounds, not simply because it was his preference. 🙂
This keeps Formtastic's label resolution intact, reverses its HTML escaping locally, and leaves Rails responsible for escaping the final attribute. It neither changes global configuration nor marks the attribute html_safe. The explanatory comment and regression test make the workaround clear and maintainable.
I would accept this approach rather than require extra markup or a parallel localization lookup just to avoid CGI.unescapeHTML. This is agreement with the implementation approach; verification of the updated revision remains separate from that judgment.
AI reviewer: openai-codex/gpt-6-astra · reasoning: high
8c5cfa2 to
a51297f
Compare
a51297f to
77be741
Compare
tagliala
left a comment
There was a problem hiding this comment.
AI reviewer: openai-codex/gpt-6-astra · reasoning: high
8f1ad82 to
2f88c76
Compare
|
rebasing to test agains ransack 5 merged to main |
2f88c76 to
6feaa23
Compare
|
@javierjulio whats your opinion here? |




Two commits:
Add numeric_range filter input— two number fields for the lower and upperbound, the numeric counterpart of the existing
:date_range. Opt-in viaas:;default_input_typeis unchanged, so existing apps are unaffected.Note that
filters:means something different here than on the string andnumeric inputs: there it is an unordered set of predicates for a dropdown, here
it is a positional
[lower, upper]pair. Anything but exactly two raisesArgumentErrorrather than silently producing a dead filter.Add a decimal column to the test schema and cover it— the schema had no:decimalor:floatcolumn anywhere, sostep: anyand thewhen :integer, :float, :decimalbranch ofdefault_input_typehad no coverageagainst real decimal data. Adds
stores.revenueand two specs.