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

Order scopes #7471

Merged
merged 2 commits into from Apr 25, 2021
Merged

Conversation

Matt-Yorkley
Copy link
Contributor

@Matt-Yorkley Matt-Yorkley commented Apr 23, 2021

What? Why?

Removes some dead code in Spree::Order and moves old query methods to chainable scopes.

What should we test?

Green build should be enough.

Release notes

Tidied up order scopes.

Changelog Category: Technical changes

@Matt-Yorkley Matt-Yorkley self-assigned this Apr 23, 2021
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #7471 (4938285) into master (9b52c45) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7471      +/-   ##
==========================================
+ Coverage   93.16%   93.17%   +0.01%     
==========================================
  Files         633      633              
  Lines       18101    18091      -10     
==========================================
- Hits        16864    16857       -7     
+ Misses       1237     1234       -3     
Impacted Files Coverage Δ
app/models/spree/order.rb 96.00% <100.00%> (+0.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b52c45...4938285. Read the comment docs.

@Matt-Yorkley Matt-Yorkley marked this pull request as ready for review April 23, 2021 10:50
Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

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

👏

end
scope :complete, -> { where.not(completed_at: nil) }
scope :incomplete, -> { where(completed_at: nil) }
scope :by_state, lambda { |state| where(state: state) }
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this should also go by using the complete scope on the ProducerMailer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered that, but I think there's a subtle difference between order.complete and order.by_state("complete"). An order in "complete" state will be returned by both scopes, but an order that was completed and then cancelled will be returned by the first but not the second, eg: completed_at will be a non-nil timestamp but the state will be "cancelled".

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.

None yet

3 participants