-
Notifications
You must be signed in to change notification settings - Fork 147
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
charge transport cost as well when accounting order (fix #861 after f7c7b56) #862
charge transport cost as well when accounting order (fix #861 after f7c7b56) #862
Conversation
can you add an unit test for it to |
sorry, I have no idea how that should look like (and about writing tests in general) |
The idea of test is, that the test runner (in our case |
Here's my first go at it.
The difference was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have no clear answer why the test failed.
anyway: usually a test should only test one single point at a time. here we just want to make sure that the amount of the financial transaction is the same as the total of the group order. how total
is calculated is not important here. checking that total
returns the correct value should be done in a separate test (in group_order_spec.rb
).
spec/factories/order_article.rb
Outdated
require 'factory_bot' | ||
|
||
FactoryBot.define do | ||
factory :order_article do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this file is not necessary
ok, since you wrote "including the transport costs," I thought the transaction amount should include at least one article's price, not just the transport cost. |
|
but it doesn't have a price, so only the transport cost is charged |
the price should be created via the factory at foodsoft/spec/factories/article.rb Line 6 in 007ff70
you can see that the article has an price e.g. by printing it with |
now there should be an article in the result too, maybe @wvengen knows if there are already some fitting test helpers for that (to avoid the ugly code in |
Would you mind merging this for now and adding more tests later, if necessary? |
3aef1b1
to
a141cc7
Compare
a141cc7
to
e22caaf
Compare
for me it worked now
Note: I think it could be useful to check if price != 0 before creating a transaction (to avoid empty transactions) but I left it out since this should be fixed quickly