Repository navigation
Fix the extension on Solidus 4.8 and run the specs on GitHub Actions - #2
Conversation
solidus_support 0.15 deprecates SolidusSupport::Migration, and its [] already returns ActiveRecord::Migration[4.2], so the superclass stays the same class object. Versions and file names don't change, so apps that already ran these migrations see no difference. Generating the test app no longer logs six deprecation warnings.
Includes Devise::Test::ControllerHelpers in controller specs. Every controller example failed with Devise::MissingWarden before reaching the controller. Creates the avalara_order factory's store even under the build strategy. Spree::Order validates store_id, and the factory saves the order while recalculating adjustments, so build(:avalara_order) raised "Store can't be blank" in 13 examples. Solidus core's order factory declares its store the same way. Bootstraps the dummy app with bundle exec rake, since the repo has no bin/rake binstub.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues can cause boot failures with older Zeitwerk versions and leave recalculated order taxes stale, double-counted, or incorrectly zeroed.
4 open issues
What changed in this PR
Updates the Avalara tax extension for Solidus 4.8 and Rails 8.1, and moves CI to GitHub Actions so the fork can run its spec suite.
Changes:
- Changes decorator loading to avoid duplicate callbacks and adds calculator response guards.
- Updates admin forms, controller parameters, translations, JavaScript routes, and migration base classes.
- Repairs spec setup, adds regression specs and offline fixtures, and replaces CircleCI with GitHub Actions.
| File | Description |
|---|---|
spec/vcr/Spree_Calculator_AvalaraTransaction/_compute_line_item/when_tax_is_not_included_in_price/returns_the_previous_tax_when_the_response_is_a_String.yml |
Adds an offline setup fixture for the String-response test. |
spec/vcr/Spree_Calculator_AvalaraTransaction/_compute_line_item/when_tax_is_not_included_in_price/returns_0_when_the_response_has_no_lines.yml |
Adds an offline setup fixture for the missing-lines test. |
spec/spec_helper.rb |
Uses Bundler rake and includes Devise controller helpers. |
spec/models/spree/calculator/avalara_transaction_spec.rb |
Adds String-response and missing-lines examples. |
spec/lib/solidus_avatax_certified/engine_spec.rb |
Checks that state-machine callbacks register once. |
spec/controllers/spree/admin/users_controller_decorator_spec.rb |
Checks the translated success flash. |
spec/controllers/spree/admin/avalara_entity_use_codes_controller_spec.rb |
Enables view rendering to catch template errors. |
solidus_avatax_certified.gemspec |
Raises the solidus_support minimum to 0.15. |
lib/solidus_avatax_certified/testing_support/factories/avalara_order_factory.rb |
Persists the store association when building orders. |
lib/solidus_avatax_certified/engine.rb |
Resolves decorators through Zeitwerk and removes redundant loading. |
Gemfile |
Updates the frontend source and allows a Rails version constraint. |
db/migrate/20170509201056_drop_spree_avalara_preferences.rb |
Uses ActiveRecord::Migration[4.2] directly. |
db/migrate/20160805193512_add_vat_id_to_spree_users.rb |
Uses ActiveRecord::Migration[4.2] directly. |
db/migrate/20160628200504_create_spree_avalara_preferences.rb |
Uses ActiveRecord::Migration[4.2] directly. |
db/migrate/20160624155217_add_columns_to_spree_users.rb |
Uses ActiveRecord::Migration[4.2] directly. |
db/migrate/20160624154423_create_spree_avalara_entity_use_codes.rb |
Uses ActiveRecord::Migration[4.2] directly. |
db/migrate/20160624154205_create_spree_avalara_transactions.rb |
Uses ActiveRecord::Migration[4.2] directly. |
app/views/spree/admin/avalara_entity_use_codes/index.html.erb |
Replaces the removed button helper with a styled link. |
app/views/spree/admin/avalara_entity_use_codes/edit.html.erb |
Uses the shared resource-edit controls. |
app/models/spree/calculator/avalara_transaction.rb |
Handles non-Hash responses and missing tax lines. |
app/decorators/controllers/solidus_avatax_certified/spree/admin/users_controller_decorator.rb |
Corrects the success-message translation key. |
app/controllers/spree/admin/avalara_entity_use_codes_controller.rb |
Permits the two editable use-code fields. |
app/assets/javascripts/spree/frontend/solidus_avatax_certified.js |
Initializes Spree.routes before assigning the validation route. |
app/assets/javascripts/spree/backend/solidus_avatax_certified.js |
Initializes Spree.routes before assigning admin routes. |
.github/workflows/test.yml |
Adds CI for Solidus 4.8, Rails 8.1, Ruby 4.0, and SQLite. |
.circleci/config.yml |
Removes the previous CircleCI configuration. |
Review effort: Max (adaptive)
60a7027 to
b373429
Compare
SolidusSupport::EngineExtensions adds app/decorators to the autoload paths and then loads every decorator file in to_prepare. The module keyword hits Zeitwerk's pending autoload, Zeitwerk requires the file, and the outer load then runs the body a second time. Every state machine callback added in a decorator's prepended hook was registered twice: Spree::Payment ran avalara_finalize twice per completion and committed the Avalara transaction twice. Overrides load_solidus_decorators_from to resolve each file's constant through Zeitwerk, which runs each body once per boot and once per reload. Drops the engine's own to_prepare glob, which added a third run when classes are not cached. Requires solidus_support 0.15, the version the override was checked against, and solidus_core 4.1, the minimum solidus_support 0.15 accepts. Requires zeitwerk 2.6.9, the first release with Loader#cpath_expected_at: Rails 7.0 and 7.1 accept older versions, so a host could otherwise boot into a NoMethodError.
b373429 to
cd0e327
Compare
cd0e327 to
594d16f
Compare
594d16f to
9c3d034
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Successful quote cache writes lack an expiry, allowing unchanged carts to reuse stale tax quotes indefinitely on stores without a default expiration because the cache key omits the tax date.
1 open issue
3 resolved since last review
Review effort: Max (adaptive)
9c3d034 to
0c7b7d6
Compare
There was a problem hiding this comment.
🟡 Changes recommended
With a non-storing cache, repeated AvaTax lookups can mix old and new taxes within one recalculation, while decorator callback registration after reload remains untested.
2 open issues
1 resolved since last review
Review effort: Max (adaptive)
0c7b7d6 to
b76d35e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Recalculation can resubmit finalized invoices and raise errors on locked transactions, while unchanged cache keys can leave paid orders uncommitted after committing is enabled.
2 open issues
3 resolved since last review
Review effort: Max (adaptive)
With document commit disabled, get_avalara_response asked for the final SalesInvoice of an order that can commit and got back the String "Avalara Document Committing Disabled", so tax_for_item raised NoMethodError on avalara_response['lines']. It now asks for a SalesOrder unless document committing is enabled, so the tax stays current on the confirm step. Returns the previous tax amount for any other non-Hash response, as it already did for nil, and 0 for a Hash without lines (the guard from upstream 9310b80). Returns nil from post_order_to_avalara when Avalara answers with an error, instead of a zero totalTax. A failed lookup leaves the previous tax in place instead of zeroing it, and is cached as a marker for one minute, so the other items of the same order reuse the failure instead of each asking Avalara again. SalesOrder quotes expire after five minutes, the lifetime time_to_idle was meant to set: ActiveSupport::Cache doesn't recognise that option, so they never expired, and the key leaves out inputs such as the document date and the customer's exemption. Committed SalesInvoice responses keep no expiry, as before: the invoice is dated at completion, and posting it again on a later recalculation would adjust the filed document, which AvaTax rejects once the period is locked. The key prefix becomes avtx_v2, so the zero-tax error results cached by the previous code are not read after a deploy. Adds VCR cassettes for the six new examples so they run offline. They hold the sandbox's 401 reply to the factory's order setup, sent with the fake 12345:12345 credentials.
Solidus 4.8 has no button or button_link_to helpers, so the edit and index pages raised NoMethodError. The edit page renders the shared edit_resource_links partial and the index page a btn-primary link, as Solidus's own admin pages do. Implements permitted_resource_params, which ResourceController requires. Without it, submitting the new or edit form raised NotImplementedError. It permits the two fields the form renders. Renders views in the controller spec so it catches template errors, and creates a use code before the index request so the rows and their edit and delete links render.
The account_updated key lives under the spree namespace, so the flash read "Translation missing: en.account_updated". The spec comes from upstream 6c8d3c8.
Neither solidus_backend 4.8 nor solidus_frontend defines Spree.routes any more, so the backend and frontend scripts threw a TypeError on load. Each now creates the object when it's missing.
Replaces the CircleCI config, which never reported on this fork, with a workflow on solidusio/test-solidus-extension pinned by SHA. It tests Solidus v4.8 on Rails 8.1 and Ruby 4.0 with SQLite. The Gemfile honours RAILS_VERSION, which the action exports, and takes solidus_frontend from GitHub for every Solidus branch from v3.2, pinned to commit 16546d19. The released 4.8.0 gem depends on canonical-rails, which caps actionview below 8.1; that commit vendors the canonical tag helper instead.
b76d35e to
b46e5b0
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Default cache expiration, uncached payment-finalization responses, and discarded legacy entries can cause committed invoices to be reposted, failing when those invoices are filed or locked.
3 open issues
2 resolved since last review
Review effort: Max (adaptive)


This PR fixes the bugs that break the extension on Solidus 4.8, gets the spec suite green, and replaces CircleCI with GitHub Actions so the fork finally has a CI signal.
On Solidus 4.8 and Rails 8.1 the extension had a few runtime bugs, and 26 of 200 examples failed, most of them in the spec setup. The worst one is in production code: every decorator body ran twice, so
Spree::Paymentregisteredavalara_finalizetwice and committed the Avalara transaction twice per payment completion. CircleCI never reported on this fork, so none of this showed up anywhere.Decorators load once (
b3c3382):SolidusSupport::EngineExtensionsaddsapp/decoratorsto the autoload paths and thenloads every decorator into_prepare. Themodulekeyword triggers Zeitwerk's autoload of the same file, and the outerloadruns the body a second time.Engine.load_solidus_decorators_fromto resolve each file's constant throughRails.autoloaders.main.cpath_expected_at(decorator_path).constantize, so Zeitwerk runs each body once per boot and once per reload.to_prepareglob, which added a third run when classes aren't cached.solidus_support >= 0.15, the version I checked the override against, andsolidus_core >= 4.1, the minimum solidus_support 0.15 accepts. It also requireszeitwerk >= 2.6.9, the first release withLoader#cpath_expected_at, since Rails 7.0 and 7.1 accept older versions.Calculator (
8b327d2):get_avalara_responseasked for the final SalesInvoice of an order that can commit and got back the String "Avalara Document Committing Disabled", soAvalaraTransaction#tax_for_itemraisedNoMethodErroronavalara_response['lines'].nil, and 0 for a Hash withoutlines(the guard from upstream9310b80).post_order_to_avalarareturnsnilon an AvaTax error instead of{ 'totalTax' => 0.0 }, so a failed lookup keeps the previous tax.get_avalara_responsecaches the failure as a marker for one minute, so the other items and shipments in the same recalculation reuse it instead of each asking AvaTax again. SalesOrder quotes expire after five minutes, since the cache key leaves out inputs such as the document date and the customer's exemption. Committed SalesInvoice responses keep no expiry, so a later recalculation doesn't post the filed invoice again. The cache key prefix becomesavtx_v2, so results cached by the previous code aren't read after a deploy. Before, a completed order recalculated during an outage was saved with zero tax.Admin (
e5e6f66,78cb756,94242dc):buttonorbutton_link_tohelpers, so the use code edit and index pages raisedNoMethodError. The edit page now rendersspree/admin/shared/edit_resource_linksand the index page abtn btn-primarylink, as Solidus's own admin pages do.AvalaraEntityUseCodesControllernow implementspermitted_resource_params, whichResourceControllerrequires. Submitting the edit form raisedNotImplementedErrorwithout it. It permitsuse_codeanduse_code_description, the two fields the form renders.UsersControllerDecorator#avalara_informationreadsspree.account_updated, so the flash no longer says "Translation missing: en.account_updated". The spec comes from upstream6c8d3c8.Spree.routesanymore, so the backend and frontend scripts threw aTypeErroron load. Each one now creates the object when it's missing.Migrations (
21bd3e5):ActiveRecord::Migration[4.2]instead of the deprecatedSolidusSupport::Migration[4.2], which already returned the same class. Versions and file names are unchanged.Spec setup (
420e11f):spec_helper.rbincludesDevise::Test::ControllerHelpersin controller specs. Every controller example failed withDevise::MissingWardenbefore reaching the controller.avalara_orderfactory creates its store even under the build strategy, like Solidus core's order factory does.build(:avalara_order)raised "Store can't be blank" in 13 examples.spec_helper.rbbootstraps the dummy app withbundle exec rake, since the repo has nobin/rakebinstub.engine_spec.rbchecks each state machine callback is registered once, and the users decorator spec checks the flash. The use code controller spec now usesrender_viewsso it catches template errors, and creates a use code before the index request so the rows and their links render. The six new calculator examples have VCR cassettes, so they run offline.CI (
b46e5b0):.github/workflows/test.ymlreplaces the CircleCI config. It runssolidusio/test-solidus-extension, pinned by SHA, on Solidus v4.8, Rails 8.1, Ruby 4.0 and SQLite. The workflow token is limited tocontents: read, and the README badge points at this workflow instead of CircleCI.GemfilehonoursRAILS_VERSION, which the action exports, and takessolidus_frontendfrom GitHub, pinned to16546d19, for every Solidus branch from v3.2. The released 4.8.0 gem depends on canonical-rails, which caps actionview below 8.1, and the pin keeps upstream commits from changing the CI run, sinceGemfile.lockis ignored.