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

API-4: ordering #573

Merged
merged 4 commits into from Feb 17, 2021
Merged

Conversation

wvengen
Copy link
Member

@wvengen wvengen commented Oct 13, 2018

Part four of #429 in chunks, continued from #572:

  • /api/v1/orders(/:id)
  • /api/v1/order_articles(/:id)
  • /api/v1/group_order_articles(/:id) with CRUD
  • /api/v1/article_categories(/:id)

Updating single GroupOrderArticles is something (I believe) we don't really do elsewhere. I've looked into this years ago in the foodcoop-adam fork, and used something similar here.

  • add docs and specs for endpoints (rebase on updated API-3: financial transactions #572)
  • see if update logic can be moved to model
  • specs for updating endpoints
  • add description to swagger fields
  • test group_order_article serializer total_price (first check if Apivore might test that)
  • rebase

@wvengen wvengen added the api label Oct 13, 2018
@wvengen wvengen added this to the API v1 milestone Oct 13, 2018
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch 3 times, most recently from 9ebe42b to e0b06fe Compare October 13, 2018 18:56
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch from e0b06fe to db7a8ab Compare October 13, 2018 19:22
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch 2 times, most recently from a37f6f2 to b802609 Compare October 15, 2018 11:04
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch from b802609 to 7bf3204 Compare November 4, 2018 15:04
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch from 7bf3204 to 6047366 Compare July 29, 2020 14:53
@wvengen wvengen removed the needs work label Aug 3, 2020
@wvengen wvengen requested a review from paroga August 13, 2020 06:14
@wvengen
Copy link
Member Author

wvengen commented Sep 3, 2020

@paroga I think this is ready now, care to review?
(note that the CI error is because of a disappeared commit after a force-push, note that the other CI succeeds)

@paroga paroga force-pushed the master branch 6 times, most recently from ca76347 to c6250de Compare September 5, 2020 15:00
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch 3 times, most recently from 3949916 to 4a081f6 Compare January 23, 2021 10:31
@wvengen
Copy link
Member Author

wvengen commented Jan 25, 2021

I'm slowly proposing to merge this, if there are no further objections.

Copy link
Member

@paroga paroga left a comment

Choose a reason for hiding this comment

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

maybe i missed something, but expected some additional tests:

  • do api calls return the correct content? (at least check the id and/or a relevant property like name) i only see some tests which validate the content for GET /orders
  • do api calls perform any work? does a DELETE really removes the element from the database and not just returns the expected status code?

we have the chance to improve our test coverage with the new api endpoints, so we should try to write tests for as many relevant cases as possible

app/controllers/concerns/auth_api.rb Outdated Show resolved Hide resolved
app/serializers/order_serializer.rb Outdated Show resolved Hide resolved
app/models/order.rb Outdated Show resolved Hide resolved
app/serializers/group_order_article_serializer.rb Outdated Show resolved Hide resolved
@wvengen
Copy link
Member Author

wvengen commented Feb 5, 2021

  • do api calls return the correct content? (at least check the id and/or a relevant property like name) i only see some tests which validate the content for GET /orders

The swagger_spec uses Apivore which checks that all responses are conforming to the Swagger/OpenAPI specification in doc/.

  • do api calls perform any work? does a DELETE really removes the element from the database and not just returns the expected status code?

That's a good point, which I have stepped over perhaps a bit too lightly.

we have the chance to improve our test coverage with the new api endpoints, so we should try to write tests for as many relevant cases as possible

I agree that is a good opportunity, will write tests for modifying methods.

@paroga
Copy link
Member

paroga commented Feb 5, 2021

The swagger_spec uses Apivore which checks that all responses are conforming to the Swagger/OpenAPI specification in doc/.

does it also also check if the correct items are returned or does it only check for the schema?

@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch 2 times, most recently from fc91f5e to 822ec12 Compare February 5, 2021 13:42
@wvengen
Copy link
Member Author

wvengen commented Feb 5, 2021

does it also also check if the correct items are returned or does it only check for the schema?

It only checks for the schema, which is an approach we've already adopted.
I think it wouldn't be a bad idea to move to a different testing approach for the API. We'd probably implement controller specs for all the API endpoints, checking status and return values. This would kind of double with the Apivore specs, which would better be moved to become part of the controller specs (if possible, or find another solution to test OpenAPI conformance, or skip that).
I think that, while it would be good to look into, this overhaul is outside the scope of this PR.

Updating data is new here, I'd be happy to include specs for that.

@paroga
Copy link
Member

paroga commented Feb 5, 2021

this overhaul is outside the scope of this PR.

agree

Updating data is new here, I'd be happy to include specs for that.

thanks

id:
type: integer
name:
type: string
Copy link
Member

Choose a reason for hiding this comment

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

do we want to add description to all properties?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Except, perhaps id and name (which are self-explanatory).

@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch from 822ec12 to 186620a Compare February 17, 2021 14:14
@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch 2 times, most recently from 15e9912 to a7892e4 Compare February 17, 2021 14:27
Copy link
Member

@paroga paroga left a comment

Choose a reason for hiding this comment

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

LGTM (beside the missing newline)
many thanks for the additional tests!

@wvengen wvengen force-pushed the feature/api-4-endpoints-orders branch from a7892e4 to 74e455c Compare February 17, 2021 14:50
@wvengen wvengen merged commit 69732cc into foodcoops:master Feb 17, 2021
wvengen added a commit to foodcoops/foodsoft-shop that referenced this pull request Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants