Skip to content
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

Update Gemfile for Spree 2.0 #2209

Merged
merged 5 commits into from
Apr 16, 2018

Conversation

HugsDaniel
Copy link
Contributor

@HugsDaniel HugsDaniel commented Apr 12, 2018

What? Why?

Closes #2219. First attempt to boot the app with Spree 2.0.

@HugsDaniel HugsDaniel changed the title Spree upgrade Update gemfile for Spree 2.0 Apr 12, 2018
@HugsDaniel HugsDaniel changed the title Update gemfile for Spree 2.0 Update Gemfile for Spree 2.0 Apr 12, 2018

# Our branch contains two changes
# - Pass customer email and phone number to PayPal (merged to upstream master)
# - Change type of password from string to password to hide it in the form
gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "spree-upgrade-intermediate"
#gem 'spree_paypal_express', github: "spree-contrib/better_spree_paypal_express", branch: "1-3-stable"
# gem 'spree_paypal_express'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove this line. If it's commented out it's because we don't need it. If we ever do, Git will have in its history.

@@ -37,7 +37,7 @@ def set_order_cycles

# And default to the only order cycle if there's only the one
if @order_cycles.count == 1
current_order(true).set_order_cycle! @order_cycles.first
current_order( create_order_if_necessary: true ).set_order_cycle! @order_cycles.first
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for this extra spacing inside the parenthesis.

@@ -18,7 +18,7 @@

# Patching to redirect to shop if order is empty
def edit
@order = current_order(true)
@order = current_order( create_order_if_necessary: true )
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well

@@ -78,7 +78,7 @@ def populate
# callbacks on Spree::Adjustment and then manually invoke Spree::Order#update! on success.

Spree::Adjustment.without_callbacks do
populator = Spree::OrderPopulator.new(current_order(true), current_currency)
populator = Spree::OrderPopulator.new(current_order( create_order_if_necessary: true ), current_currency)
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

Copy link
Contributor

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

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

⚠️ Let's all be aware that it'll take some PRs until we get the tests to pass again. Basically, the whole upgrade process so we will have to apply this exception meanwhile.

@sauloperez sauloperez merged commit f7a5019 into openfoodfoundation:2-0-stable Apr 16, 2018
sauloperez added a commit to coopdevs/openfoodnetwork that referenced this pull request Apr 18, 2018
Although we don't know how big the fixes introduced between 2.0.4 and
2.0.13 are, jumping from roughly 1.3.99 to 2.0.13 seems too big of
a change to do in one go.

Unless more issues like this one come up that force us to upgrade to
a newer version I believe it's best to be conservative. You'll find an
in-depth explanation in
https://github.com/openfoodfoundation/openfoodnetwork/wiki/Spree-2.0-upgrade#getting-to-version-204-

A previous effort was done to upgrade to v2.0.13 in
openfoodfoundation#2209
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Sorry, I'm late to the party, just getting familiar with the Spree upgrade process. In order to avoid merge conflicts later on, I would like to suggest to split changes like this into two parts. Part one is pure re-factoring that can be applied to the stable master branch (not spree upgrade). The purpose is to contain Spree dependency in a small confined area. Part two is a contribution for the Spree upgrade where we can change only a few lines. This pull request is a great example. We see a lot of changes like:

-    @order = current_order(true)
+    @order = current_order(create_order_if_necessary: true)

Instead of this change, I would create our own wrapper. In this case we can create two methods on the application controller:

  • current_order_or_new
  • current_order_if_exists

In part one, these two methods just call current_order(true) or current_order(false). A lot of controllers are touched for this part, but we can easily merge it into master and improve it's readability already.

In part two, we can adapt to the Spree upgrade by touching only the two methods in the application controller without touching all the other ones.

What do you think guys? Should we do it?

@enricostano
Copy link
Contributor

@mkllnk yes, during the Spree upgrade (but not only) we constantly struggle to find the less disruptive strategy and the "wrapper" thing is something we're taking in account all the time. The idea is to take advantage of the Spree upgrade to define our own OFN business logic abstraction and then internally we can plug into Spree or make our own thing.

In any case, yes. This PR could have included that OFN abstraction but in this specific case we didn't find a better reason than possible merge conflicts. But we'll need to question ourselves in any PR and ask other devs how to achieve it.

@sauloperez
Copy link
Contributor

Sorry @mkllnk, I don't understand either what you mean with a wrapper nor the explanation about the two parts.

I'm spending a bit of time while working on #2205 to find out a way to make this whole dependency on Spree a bit easier to manage.

@mkllnk
Copy link
Member

mkllnk commented Apr 23, 2018

@sauloperez I meant that we are changing a lot of calls to Spree's current_order here. My idea was to create our own version of current_order and name it slightly differently. Then we call our own method everywhere. We can do this change in the master branch to separate our code from Spree's code a bit more. In the Spree upgrade, we just need to change our implementation of our current_order method in one place without changing all the other files. That would prevent merge conflicts. With this way of encapsulation it's easier to deal with API changes in Spree.

@kirstenalarsen
Copy link
Contributor

kirstenalarsen commented Apr 23, 2018 via email

@sauloperez
Copy link
Contributor

sauloperez commented Apr 23, 2018

that's an interesting idea @mkllnk. That's essentially implementing an adapter. I haven't considered the nice side effect of cutting down the possibility of merge conflict and that's a major win!

This might not be the place to have an in-depth discussion about OOP design but I've been considering the possibility of building our own extendible_spree gem (hosted in rubygems) to implement well-designed hooks that allow extending it in a clean way, like we need in OFN, as opposed to the hackish and unmaintainable class_eval approach they favour.

I feel like we need a series of design/architecture session to better address the spree upgrade.

@daniellemoorhead
Copy link
Contributor

daniellemoorhead commented Apr 27, 2018

I feel like we need a series of design/architecture session to better address the spree upgrade.

@sauloperez I say set up a call and invite all the people (aka @oeoeaio @mkllnk alongside of you guys working on Spree already). I think it's super important, and worth running potentially fortnightly catchups with our timezone to talk through things. IMO 😀

@sauloperez
Copy link
Contributor

totally agree @daniellemoorhead . I want to prepare first a code proposal to base our discussions on.

@sauloperez
Copy link
Contributor

We finally had that call. Read about it in the Team catch ups wiki page.

@HugsDaniel HugsDaniel deleted the spree_upgrade branch June 4, 2018 06:41
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.

6 participants