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

Remove default address dependency part 2 #2802

Merged

Conversation

kennyadsl
Copy link
Member

@kennyadsl kennyadsl commented Jul 18, 2018

Continuation of #2686
Closes #2930

This PR continues the work of @gevann removing hard-coded dependency of having a specific user in the database to perform a set of operations related to reimbursements.

@tvdeyen this basically seconds your comments on that PR, let me know if it's enough!

I've also deprecated whodunnit argument from some methods in favor of a more consistent created_by.

@kennyadsl kennyadsl changed the title Gevann remove default address dependency part 2 Remove default address dependency part 2 Jul 18, 2018
@kennyadsl kennyadsl self-assigned this Jul 18, 2018
def perform!
def perform!(created_by: nil)
unless created_by
created_by = Spree.user_class.where(email: '[email protected]').first
Copy link
Contributor

Choose a reason for hiding this comment

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

Use find_by instead of where.first.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done and squashed changes into 3f33fa199e889251c517a60c4ac98be958248b4c

@kennyadsl kennyadsl force-pushed the gevann-remove-default-address-dependency branch 3 times, most recently from 8afe61d to 381a522 Compare October 2, 2018 10:53
Copy link
Contributor

@ericsaupe ericsaupe left a comment

Choose a reason for hiding this comment

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

I like the consistency change from whodunnit to created_by. I don't really love the Spree.user_class.find_by(email: '[email protected]') calls as I suspect nearly all production stores do not have that user but since it is within the deprecation call I think it's a good middle ground until it can be removed after the deprecation.

Thanks!

Graeme Nathan and others added 10 commits October 31, 2018 11:06
Without a user with email address equal to '[email protected]', when
a reimbursement is created a Spree::StoreCredit is not. This spec
illustrates this behaviour.
Previously, reimbursement helpers did not take a parameter for the
creator of the reimbursement. Instead, they relied on a hard-coded
dependency on a user in the database existing with the email address
'[email protected]'.
Reimbursements only work if there is a user with the email address
'[email protected]', or if you explicitly pass the creator when creating
a reimbursement.

This commit adds to the testing set-up for this spec by mocking
a signed in admin creating the reimbursement, who can be passed as the
creator.
This is done to keep the code language uniform, since at the
end we are setting the store credit attribute (association with user)
named created_by:

https://github.com/solidusio/solidus/blob/826d9288684cf8f275bf04ac144b9b0ee84da1b6/core/app/models/spree/store_credit.rb#L24
whodunnit was basically doing the same thing. It's better to
have the same argument name for every method that is using it.
This applies only to some deprecated blocks and does not
change the new, working logic.

This means that if those methods were used by some store or
extension, they will now don't have the creator set instead
of having a specific user that could even be not present in the
database, causing the creator to be nil anyway.
@kennyadsl kennyadsl force-pushed the gevann-remove-default-address-dependency branch from 381a522 to 05b6354 Compare November 1, 2018 08:58
@kennyadsl
Copy link
Member Author

@ericsaupe @gmacdougall I've addressed the concern we talked about in the core team meeting. This should be fine now!

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.

5 participants