-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove code from Spree::Api::PromotionsController #3529
Remove code from Spree::Api::PromotionsController #3529
Conversation
8b14eb5
to
c5551e2
Compare
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.
@SamuelMartini thank you for this PR, looks good to me, I left just a small style note, let me know what you think.
def load_promotion | ||
@promotion = Spree::Promotion.find_by(id: params[:id]) || Spree::Promotion.with_coupon_code(params[:id]) | ||
@promotion = Spree::Promotion.with_coupon_code(params[:id]) | ||
@promotion ||= Spree::Promotion.find(params[: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.
@SamuelMartini for consistency with what was done after this I would consider using the ||
here as well, WDYT?
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.
c5551e2
to
eb481bd
Compare
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.
@SamuelMartini thank you 👍
Make it leaner by using the way solidus api has to deal with ActiveRecord::RecordNotFound and authorization. In `load_promotion`, `find_by` is replaced with `find` and the order of the finders is inverted to have the exception as last operator: if a promotion can't be found, raise an exception.
eb481bd
to
996a15a
Compare
Thanks @SamuelMartini! |
Description
Little change to make
Spree::Api::PromotionsController
leaner and also consistent with how solidus api deals withActiveRecord::RecordNotFound
and authorization.Checklist: