Skip to content

Order update attributes refactor#357

Merged
jhawthorn merged 30 commits into
solidusio:masterfrom
jhawthorn:order_update_attributes
Nov 5, 2015
Merged

Order update attributes refactor#357
jhawthorn merged 30 commits into
solidusio:masterfrom
jhawthorn:order_update_attributes

Conversation

@jhawthorn

Copy link
Copy Markdown
Contributor

No description provided.

@jordan-brough

Copy link
Copy Markdown
Contributor

Looking great to me! The extraction of code into standalone classes seems like what we've been needing and the spec cleanups along the way are great to have also.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think of apply instead of update for the name of this method? Or something else like that. If I have a "FooAttributes" object, I kind expect foo_attributes.update to refresh the attributes themselves or something like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like apply

@jhawthorn

Copy link
Copy Markdown
Contributor Author

Disappointing discovery: if I comment out set_shipments_cost, all specs still pass 😞. Will have to try and add a feature test exposing that.

@jhawthorn jhawthorn changed the title [WIP] Order update attributes refactor Order update attributes refactor Sep 9, 2015
@jhawthorn jhawthorn force-pushed the order_update_attributes branch from aaef027 to c1e5d26 Compare September 9, 2015 23:01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like setting variables in conditional statements. I propose 2 different wat how to handle it:

return {} if masseged_params[:order].blank?
massaged_params[:order].permit(permitted_checkout_attributes)
update_params = massaged_params.fetch(:order, {})
update_params.permit(permitted_checkout_attributes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems a bit bike-shedding-ish...

Also, in this case I like how the current form calls out the fact that we may want to discontinue supporting requests without parameters (which I find weird).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah I'm with @jordan-brough and @jhawthorn on this. I think the assignment in the conditional makes a lot of sense here.

@jhawthorn jhawthorn force-pushed the order_update_attributes branch 2 times, most recently from 8a24713 to 5938878 Compare September 30, 2015 17:42
@jordan-brough

Copy link
Copy Markdown
Contributor

This is looking pretty great! @jhawthorn do you have much more on your todo list here or do you think this is pretty close to ready?

@jhawthorn

Copy link
Copy Markdown
Contributor Author

@jordan-brough I have just two things I want to check up on. The first you might be able to help clarify

Here https://github.com/solidusio/solidus/pull/357/files#diff-0a2f4b241f8427ca90d58eec529e0e8aR53 we assign credit_card.verification_value and there are tests which verify (though expect(..).to receive(:varification_value=)) that that is assigned. However that record is never saved, and I see no place that that would be used. If we need that value to be around at some point we need to test for it.

Second issue is to find out why we have set_shipments_cost

@jhawthorn jhawthorn force-pushed the order_update_attributes branch from 5938878 to 146d73c Compare October 5, 2015 20:48
@jhawthorn

Copy link
Copy Markdown
Contributor Author

I've added a test for set_shipments_cost. Other than my question to you @jordan-brough I believe this is ready

@jordan-brough

Copy link
Copy Markdown
Contributor

@jhawthorn taking a look now

@jordan-brough

Copy link
Copy Markdown
Contributor

@jhawthorn I can't see a definite use for the verification_value with existing cards. We definitely haven't used it ourselves.

You probably already saw this, but this is the commit that added this via the cvc_confirm parameter (which we now translate into verification_value in controller_helpers/payment_parameters.rb to be more consistent in what we call it). I couldn't find any corresponding PR or anything but it does seem to be meant specifically for use with existing cards.

I'd guess that someone was requiring their customers to re-supply the CVV before being able to re-use an existing card, and that the in-memory credit card was making its way to the payment processor code (e.g. in code like this) and that code expected the verification value to be there.

Summary: I don't know. When I moved that code around I was just trying to be extra cautious. I would be willing to bet that there are very few stores that use that param, if any.

@jhawthorn jhawthorn force-pushed the order_update_attributes branch from 146d73c to 3a5e16a Compare October 5, 2015 23:20
@jhawthorn

Copy link
Copy Markdown
Contributor Author

@jordan-brough thanks. I was mistaken and assumed that was added by us. Might as well leave it in for now, changing that would be ouside this PR's scope.

As of 3a5e16ab49687c7960d90bfbf8e05b09eff0ecd2 (which was horrible to track down) this is good to go by me. 🚢

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still not a fan of the fact that we define this twice even though we already have a module in place which we can use to DRY this up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still not a fan of changing this. :)

@jordan-brough

Copy link
Copy Markdown
Contributor

@jhawthorn super! I'm going to take another look today and verify that it'll give us what we were looking for originally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we just leave this in apply? I don't see the point of extracting one line of code that we only call once.

@magnusvk

magnusvk commented Oct 7, 2015

Copy link
Copy Markdown
Contributor

This looks great overall. Keen to still chat a bit more about OrderUpdateAttributes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jhawthorn should this be a configurable class? e.g. Spree::Config.order_update_attributes_class.new(...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and same question for PaymentCreate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that might be a good idea but is outside the scope of this PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think before we merge this PR it ought to be in a state that satisfies the original extension goal that we had in mind. Maybe we should chat sometime about how we could best do that with the current state of this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll submit this also as a follow-up after this PR.

@jhawthorn jhawthorn force-pushed the order_update_attributes branch from a49cedc to 1ab4d74 Compare November 4, 2015 22:53
jhawthorn added a commit that referenced this pull request Nov 5, 2015
@jhawthorn jhawthorn merged commit b3f7dd8 into solidusio:master Nov 5, 2015
@jhawthorn jhawthorn deleted the order_update_attributes branch November 9, 2015 07:23
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.

7 participants