-
Notifications
You must be signed in to change notification settings - Fork 33
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
Y24-190: Support Limber with Submission creation #4555
Y24-190: Support Limber with Submission creation #4555
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-Y24-190 #4555 +/- ##
===================================================
+ Coverage 89.18% 89.20% +0.02%
===================================================
Files 1405 1405
Lines 29967 29980 +13
===================================================
+ Hits 26725 26745 +20
+ Misses 3242 3235 -7 ☔ View full report in Codecov by Sentry. |
Still need to add tests of and_submit as well as malformed payloads
describe '#filter' do | ||
let(:target_resource) { resources.sample } | ||
|
||
shared_examples 'it filters the resources correctly' 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.
This shared example seems to declared in spec/requests/api/v2/qc_files_spec.rb
, spec/requests/api/v2/submissions_spec.rb
and in spec/requests/api/v2/shared_behaviour/labware_shared_behaviour_spec.rb
.
And all of them seem to be doing the following:
- Checking if the response is an HTTP succes.
- Checking if the call returns only one resource.
- Checking if the call returns the correct resource.
Maybe we can move all these declarations into somewhere in shared_behavior
directory and reuse it?
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.
In case @StephenHulme picks this up (please feel free), I've implemented something like this in my Qcable work. So probably best to reuse that and go through existing tests, looking to replace this pattern with the shared example.
Shared example:
https://github.com/sanger/sequencescape/blob/Y24-190-support-limber-v2-qcable/spec/requests/api/v2/shared_examples/requests.rb#L138-L150
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 now done this!
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.
Looks good, thorough tests again.
Couple of minor questions.
@@ -64,7 +64,7 @@ | |||
jsonapi_resources :studies | |||
jsonapi_resources :submission_pools | |||
jsonapi_resources :submission_templates | |||
jsonapi_resources :submissions | |||
jsonapi_resources :submissions, except: %i[update] |
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.
Curious about that restriction and also state being read only.
Wondering if we need to be able to directly update submission state. Or if's all done indirectly through requests...
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.
This pull request takes an endpoint that could not previously be created or updated (i.e. it was immutable
) and adds a create POST endpoint while still leaving the update PATCH endpoint turned off. If we need to update state, it's not needed so far, but could be enabled carefully in future. immutable
in the resource effectively adds , only: %i[show]
to the route without explicitly writing it. I think it's a poor choice by the gem creators and they should expect you to just add that annotation to the routes file instead so it's explicit. As it is, you cannot tell from the routes alone which are immutable and which are full access.
@@ -51,7 +51,7 @@ | |||
end | |||
|
|||
shared_examples 'a GET request including a has_one relationship' do |related_name| | |||
before { api_get "#{base_endpoint}/#{resource.id}?include=#{related_name}" } | |||
before { api_get "#{base_endpoint}/#{resource.id}?include=#{related_name}&fields[#{resource_type}]=#{related_name}" } |
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.
what's going on with this change (and the one below)?
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.
Hmm yeah that isn't clear from these changes alone is it? The SubmissionsController
has a dubious method override in it which modifies the fields being returned by the API to only be the [uuid,name,state,created_at,updated_at]
set if you didn't specify. As such, our tests for including relationships fail for ones that aren't in that set. I don't think there should be a default set of fields that you have to override in your request, but it's an existing endpoint and I don't want to break usage somewhere. So instead I make the request in the test explicitly ask for the one relationship to be included in the response (and no other fields for that matter). As that's the only field we want to check for anyway, it's more optimal, but that's not why I implemented it this way as I agree it's ugly and should be unnecessary for any other resource.
Closes #4244
Changes proposed in this pull request
Instructions for Reviewers
[All PRs] - Confirm PR template filled
[Feature Branches] - Review code