-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade json_api_client gem #158
Conversation
super(klass) | ||
self.connection = connection | ||
self.path = path | ||
def initialize(klass, opts = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes to bring us in line with interface changes within the json_api_client
gem we're extending
@@ -1,50 +0,0 @@ | |||
require "json_api_client/version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dont we require this patch anymore?
Updating the I've decided to remove the gzip aspect of this work (this wasn't in the original ticket) and to add a separate ticket for that work. I'm taking this as a reminder not to let extra features sneak into tickets and nipping these things in the bud earlier in the development process. |
I was seeing these specs fail:
with the following error This meant that the error details were returned against a key of I originally thought this was due to this change in the However it was actually due to the fact we are overriding |
# @returns shipping methods with promotions applied | ||
def shipping_methods | ||
@shipping_methods ||= ShippingMethodsForCart.new(cart: cart, shipping_methods: shipping_method_model.all).call.sort_by(&:total) | ||
end | ||
|
||
def validate_shipping_method | ||
unless cart.shipping_method_id.nil? || shipping_methods.any? {|sm| sm.id == cart.shipping_method_id} then | ||
raise ::FlexCommerce::PaypalExpress::Exception::AccessDenied.new(I18n.t("payment_setup.shipping_method_not_available")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This translation wasn't loading and we were getting a translation missing error in the test runs. It was the only one in the locale file anyway, so I've moved it into the library. We could add another error class here as well (open to naming ideas)
Last issue on the list is the F/E specs failing with I'm just looking through what's changed in Edit: this is why #158 (comment) |
app/models/line_item.rb
Outdated
|
||
# This allows us to set the `path` parameter automatically from the provided `container_id` | ||
def self.path(params = nil, *args) | ||
params["path"] = { "cart_id" => params["container_id"] } if params["container_id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required as we've removed the _prefix_path
workaround to help with nested / multitenanted line items endpoint (here) which causes the upgraded json_api_client
gem version to error.
We always have the container_id
present so this saves us having to pass the path: { cart_id: ... }
attribute everywhere.
The alternative is we make this a requirement and go through the F/E code adding path: { cart_id: ... }
everywhere like we've done with nested coupons (and I'm not sure this would work if we're loading line items from a cart, updating them, then re-saving)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another fix would have been to update the platform to always include this path parameter in API responses. Not sure this is a good idea as we'd be adding it specifically for json_api_client
but it isn't necessarily required for any other json API libraries.
errors.add(:base, error.title || error.detail) | ||
end | ||
end | ||
fill_errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our patch needed updating to use the json_api_client
gem's latest method of dealing with errors
Related ticket: #157
This PR upgrades the
json_api_client
gem from 1.1.1 to 1.5.3 and makes relevant changes to support changes in the gem.Note that the matalan-rails-site will not be compatible with this version - work needs to be done to bring this up to date (some issues exist with nested line items and out-of-date fixtures)
Deployment