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

Honor guest checkout config #36

Merged
merged 3 commits into from
Mar 21, 2016

Conversation

bbuchalter
Copy link
Contributor

Do not allow guest authenticated to proceed to checkout when
guest checkout is not allowed.

return if spree_current_user or current_order.email
return if (
spree_current_user ||
(guest_authenticated? && Spree::Config[:allow_guest_checkout])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this config check be folded into the body of guest_authenticated?, or is there a reason you kept them separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original thought was that guest_authenticated? shouldn't include the configuration check, however, it makes sense that guest_authenticated? should always return false when allow_guest_checkout is configured to false.

I went a bit further on the refactoring of this to make it more readable: 8bc711b

@stewart
Copy link
Contributor

stewart commented Mar 19, 2016

Hey Brian,

Looking good! Just a couple small notes, but otherwise I think this is good to go.

@bbuchalter
Copy link
Contributor Author

Don't know what's going on with CI here, tests pass locally.

@bbuchalter bbuchalter force-pushed the honor-guest-checkout-config branch from 8bc711b to 0504447 Compare March 20, 2016 15:26
The specs as written don't properly set the case for an authenticated
guest, as an authenticated guest should have their email assigned to an
order and therefore not need a redirect.

If no email is assigned to the order, then a redirect is required.
Do not allow guest authenticated to proceed to checkout when
guest checkout is not allowed.
The original implementation had two guard statements and was difficult
to read because it lacked private methods which expressed intent. By
consolidating the guard statements, the check_registration method is now
reads clearly and the private methods which implement have a clear
purpose.
@stewart
Copy link
Contributor

stewart commented Mar 21, 2016

We just switched this repo over to Travis CI; can you rebase to trigger a re-build, please?

@bbuchalter bbuchalter force-pushed the honor-guest-checkout-config branch from 0504447 to 622fe09 Compare March 21, 2016 19:55
@bbuchalter
Copy link
Contributor Author

Passed in Travis!

@stewart
Copy link
Contributor

stewart commented Mar 21, 2016

👍 - thanks for fixing this!

stewart added a commit that referenced this pull request Mar 21, 2016
@stewart stewart merged commit dc7b3bd into solidusio:master Mar 21, 2016
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.

2 participants