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

Make OC advanced settings work by permitting the extra parameter and make the OC edit page work with that option activated #5775

Merged
merged 4 commits into from Jul 22, 2020

Conversation

luisramos0
Copy link
Contributor

@luisramos0 luisramos0 commented Jul 16, 2020

What? Why?

Closes #5773 & #5802

Setting the filter in the OC to products from coordinator inventory only was broken due to strong params permissions. That is fixed in this PR.
But the main issue 5773 was when the filter products from coordinator inventory only was active. For some reason in rails 4 the SQL query generation was going wrong and the list of fields in the select part of the SQL included the select from both the visible_for scope in product (which had a distinct in it) and the fields from the included table variants. In this PR I just remove the select from the visible_for scope as it is not needed for this exchange renderer.

What should we test?

I can see the problem with the live data on my local machine and I confirm the PR fixes the problem.
For this reason I havent tried to replicate the problem with other data/OC. I did write a auto test that validates the bug so I believe it as simple as activating the "inventory only" option and add some variants to the exchanges.

We should validate the OC page features around adding and removing different types of variants to the exchanges. This combined with activating the "inventory only" setting and validating it works as appropriate: only variants from the coordinators inventory should show in the page to be added to the OC.

Release notes

Changelog Category: Fixed
Fixed a bug in the Order Cycles edit page when the option "coordinator inventory only" was activated.

@sauloperez sauloperez self-assigned this Jul 21, 2020
@luisramos0 luisramos0 force-pushed the oc_inv_bug branch 2 times, most recently from d5352c1 to c1886ab Compare July 21, 2020 18:22
…product queries and it's just not needed there. The only other use of this product's scope visible_for is the enterprise serializer so we add the select to it.
@luisramos0 luisramos0 marked this pull request as ready for review July 21, 2020 19:33
@luisramos0 luisramos0 changed the title Make OC advanced settings work by permitting the extra parameter Make OC advanced settings work by permitting the extra parameter and make the OC edit page work with that option activated Jul 21, 2020
products = renderer.exchange_products(false, exchange.receiver)

expect(products).to eq [exchange.variants.first.product]
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test blows up in master just like #5773

@mbudm
Copy link

mbudm commented Jul 22, 2020

I missed that this fixes the steps to create as well and ended up creating #5802 for that bug. So that gives you a 2 issue PR @luisramos0 if you want it.

mbudm pushed a commit to mbudm/openfoodnetwork that referenced this pull request Jul 22, 2020
@luisramos0
Copy link
Contributor Author

ah, yes, that's fixed here as well (it was a very common rails 4 upgrade problem: incomplete list of permitted "strong" params). Thanks Steve.

luisramos0 added a commit that referenced this pull request Jul 22, 2020
Apply PR #5775 to branch v3.1.2 to make v3.1.3 patch
@filipefurtad0 filipefurtad0 self-assigned this Jul 22, 2020
@filipefurtad0 filipefurtad0 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 22, 2020
@filipefurtad0
Copy link
Contributor

Hi @luisramos0 ,

Thank you for your help reproducing this issue!

Setting the an OC to "Coordinators Inventory only" breaks the Outgoing Products page. Staging this PR solves this issue. Several tests were done, in this regard, please see my notes in the release-draft testing here.

I think this PR could be merged and the patch deployed, and two separate issues open. Awaiting feedback on this.

@luisramos0
Copy link
Contributor Author

I left a comment on the release issue. Let's merge this and create new issues if needed 👍

@luisramos0 luisramos0 merged commit 3dc9548 into openfoodfoundation:master Jul 22, 2020
@luisramos0 luisramos0 deleted the oc_inv_bug branch July 22, 2020 21:23
@filipefurtad0 filipefurtad0 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 22, 2020
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.

Products can't be added to Outgoing O/C (Aus Customer)
4 participants