Skip to content

Fixed: replaced AnyAscii.transliterate with I18n.transliterate#58

Merged
damianlegawiec merged 6 commits intomainfrom
fix/remove-anyascii
Mar 11, 2026
Merged

Fixed: replaced AnyAscii.transliterate with I18n.transliterate#58
damianlegawiec merged 6 commits intomainfrom
fix/remove-anyascii

Conversation

@damianlegawiec
Copy link
Member

@damianlegawiec damianlegawiec commented Mar 11, 2026

any_ascii gem was removed from spree dependencies

Summary by CodeRabbit

  • Bug Fixes

    • Improved order description normalization (switched transliteration source and added extra trimming) for cleaner payment statements
  • Dependencies

    • Raised minimum Spree requirement to 5.4.0.beta
    • Added storefront posts and legacy product properties integrations
  • Chores

    • Bumped package version to 1.6.0.beta
    • Updated test app setup to install new integrations
  • Tests

    • Removed a redundant synchronous test; coverage moved to async/job-based spec

`any_ascii` gem was removed from spree dependencies
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4f5e582-ce49-41f8-8202-83b53f041a71

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf2047 and 51a1910.

📒 Files selected for processing (1)
  • spec/services/spree_stripe/complete_order_spec.rb

Walkthrough

Switches transliteration to I18n and trims the result; bumps gem VERSION to 1.6.0.beta; raises minimum Spree dependency to >= 5.4.0.beta; adds two gems to the Gemfile; adds corresponding rails generator calls to the Rakefile; removes one synchronous test example.

Changes

Cohort / File(s) Summary
Presenter Logic
app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb
Replaces AnyAscii.transliterate(order_description) with I18n.transliterate(order_description) and adds a final .strip to the cleanup chain.
Version & Gemspec
lib/spree_stripe/version.rb, spree_stripe.gemspec
Bumps SpreeStripe::VERSION to 1.6.0.beta and tightens Spree/spree_admin dependency minimum from >= 5.4.0.alpha to >= 5.4.0.beta.
Gem additions
Gemfile
Adds spree_posts and spree_legacy_product_properties as GitHub-sourced gems (branch main).
Test app generators
Rakefile
Adds rails g spree_posts:install and rails g spree_legacy_product_properties:install invocations inside the test_app task.
Specs
spec/services/spree_stripe/complete_order_spec.rb
Removes a synchronous example that attached a customer to a credit card; notes that attachment is covered asynchronously.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mad-eel

Poem

🐰 I hopped through strings and gave them a tweak,
I18n whispers and trims what you'd seek.
A version bumped, new gems on the shelf —
Generators called while I polished myself.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change in the pull request - replacing AnyAscii.transliterate with I18n.transliterate in the presenter.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/remove-anyascii

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb (1)

27-31: ⚠️ Potential issue | 🟠 Major

Add explicit locale and replacement parameters to I18n.transliterate.

Without an explicit locale: parameter, I18n.transliterate uses the current request locale, which can produce inconsistent output. Without a replacement: parameter, characters without ASCII approximations fall back to ?—non-Latin scripts like Japanese, Arabic, and Chinese become chains of question marks that won't be stripped by the allowed-character filter. For payment descriptors, this should be deterministic and graceful.

Suggested change
-        I18n.transliterate(order_description)
+        I18n.transliterate(order_description, locale: :en, replacement: '')
                 .gsub(STATEMENT_DESCRIPTOR_NOT_ALLOWED_CHARS, '')
                 .strip
                 .upcase[0...STATEMENT_DESCRIPTOR_MAX_CHARS]
                 .strip

Add a regression spec for non-Latin input (e.g., a Japanese order description) to verify it produces a valid descriptor instead of ? characters.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb` around
lines 27 - 31, The transliteration call should be made deterministic and not
produce question marks for non-Latin scripts: change the
I18n.transliterate(order_description) invocation in the presenter to include
explicit locale and replacement options (e.g.,
I18n.transliterate(order_description, locale: :en, replacement: '') ) so unknown
characters are dropped instead of becoming '?' before applying
STATEMENT_DESCRIPTOR_NOT_ALLOWED_CHARS and truncating to
STATEMENT_DESCRIPTOR_MAX_CHARS; then add a regression spec that passes a
Japanese (or other non-Latin) order description to the presenter to assert the
resulting descriptor contains only allowed characters (no question marks) and
respects the max length.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb`:
- Around line 27-31: The transliteration call should be made deterministic and
not produce question marks for non-Latin scripts: change the
I18n.transliterate(order_description) invocation in the presenter to include
explicit locale and replacement options (e.g.,
I18n.transliterate(order_description, locale: :en, replacement: '') ) so unknown
characters are dropped instead of becoming '?' before applying
STATEMENT_DESCRIPTOR_NOT_ALLOWED_CHARS and truncating to
STATEMENT_DESCRIPTOR_MAX_CHARS; then add a regression spec that passes a
Japanese (or other non-Latin) order description to the presenter to assert the
resulting descriptor contains only allowed characters (no question marks) and
respects the max length.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cdacadd5-65e1-451d-bc05-09e8cfe675d5

📥 Commits

Reviewing files that changed from the base of the PR and between 7e4b363 and 18b4e97.

📒 Files selected for processing (3)
  • app/presenters/spree_stripe/statement_descriptor_suffix_presenter.rb
  • lib/spree_stripe/version.rb
  • spree_stripe.gemspec

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Gemfile`:
- Around line 18-19: The Gemfile now includes an unrelated dependency gem
'spree_posts' (the line gem 'spree_posts', github: 'spree/spree-posts', branch:
'main') which appears out of scope for the transliteration change; either remove
that gem line from the Gemfile to keep the PR focused, or if it's intentional,
add a short explanation to the PR description describing why 'spree_posts' is
required and how it relates to the AnyAscii -> I18n.transliterate change so
reviewers understand the rationale.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51ba0ce8-145c-4bfd-bac9-a14c722df3f3

📥 Commits

Reviewing files that changed from the base of the PR and between 18b4e97 and 6c0984c.

📒 Files selected for processing (2)
  • Gemfile
  • lib/spree_stripe/version.rb

Comment on lines +18 to +19
gem 'spree_posts', github: 'spree/spree-posts', branch: 'main'

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Unrelated change: clarify the reason for adding spree_posts.

The PR objective is to replace AnyAscii.transliterate with I18n.transliterate, but this adds an unrelated spree_posts gem dependency. This appears to be scope creep or an accidental inclusion.

If this is intentional, please update the PR description to explain why this dependency is needed. Otherwise, consider removing it to keep the PR focused.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Gemfile` around lines 18 - 19, The Gemfile now includes an unrelated
dependency gem 'spree_posts' (the line gem 'spree_posts', github:
'spree/spree-posts', branch: 'main') which appears out of scope for the
transliteration change; either remove that gem line from the Gemfile to keep the
PR focused, or if it's intentional, add a short explanation to the PR
description describing why 'spree_posts' is required and how it relates to the
AnyAscii -> I18n.transliterate change so reviewers understand the rationale.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Gemfile`:
- Around line 18-19: Reorder the two gem entries so the Gemfile section is
alphabetized: move the gem 'spree_legacy_product_properties', github:
'spree/spree_legacy_product_properties', branch: 'main' line to appear before
gem 'spree_posts', github: 'spree/spree-posts', branch: 'main' to satisfy
Bundler/OrderedGems and avoid lint churn.

In `@Rakefile`:
- Around line 24-26: The three system(...) calls invoking the generators (the
commands 'rails g spree_posts:install', 'rails g spree_legacy_api_v2:install',
and 'rails g spree_legacy_product_properties:install') currently ignore exit
status; change them to fail fast by either replacing them with Rake's sh (which
raises on non‑zero) or by checking the boolean return and aborting/raising on
failure (e.g., raise or abort with a clear message if system(...) returns false)
so the Rake task stops immediately when any generator exits non‑zero.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e548eaf-4961-4511-a1ec-1267d39c34ac

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0984c and 4bf2047.

📒 Files selected for processing (2)
  • Gemfile
  • Rakefile

@damianlegawiec damianlegawiec merged commit 6039c81 into main Mar 11, 2026
4 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