Open dasunpubudumal opened 2 weeks ago
Thanks Dasun.
I would add the following summary from the meeting. Feel free to correct if I've got things wrong.
For this story we require:
If we believe the current endpoint behavior is incorrect we will create another story to implement the correct behavior.
If the endpoint behaviour between Rails versions is consistent we can either rework the test so it works in Rails 6 or comment it out for re-implementation in another story.
If the endpoint behaviour between Rails versions is not consistent then we will need to take a view on possible options to correct or mitigate this.
It should be possible to test the endpoint under different Rails versions using the UAT environment, having set up the requests & batches manually.
Describe the Housekeeping
We have been using Rails 5.0 as our defaults, and are in the process of upgrading it to 6.1. The story that started the process of migrating the defaults to Rails 6.1 is https://github.com/sanger/sequencescape/issues/4005. Note that upgrading the Rails version in the Gemfile to 6.1 - which we did in https://github.com/sanger/sequencescape/issues/4006 - does not necessarily upgrade the Framework Defaults to 6.1. We need to update
config/application.rb
file'sconfig.load_defaults
value to6.1
, and it was done in https://github.com/sanger/sequencescape/issues/4005.There were certain tests failing, including one Minitest, and we fixed them except for one test, which is
spec/controllers/npg_actions/assets_controller_spec.rb:181
.The reason that this test fails is described below.
Take the following code snippet from
app/models/batch_request.rb
, which is the join table associating theBatch
model and theRequest
model with a one-to-many relationship. The snippet is from thebefore_validation
callback that is assigned to theBatchRequest
model.Note: Since this is part of the validation process, any failure for this callback would inevitably lead to a failure to persist a
batch_request
record, thereby failing to create an association between a givenbatch
and arequest
.record.batch.batch_requests
will return[]
before validating the first request (with thepassed
state). However, when invoking thebefore_validation
call for the second request (with thecancelled
state), it also returns[]
when it should return the firstbatch_request
record in the list.in
app/models/batch.rb:577
returns true when using Rails 5.0 as it does not return the cancelled request forrequests
association.[]
before validating the first request as in Rails 5.0. However, it correctly returns the firstbatch_request
association created when persisting the second request. Because of this, the proposition listed in the point before returns false, as the cancelled request is returned for therequests
association, preventing the state of thebatch
from transitioning toreleased
.The purpose of this story is to investigate why this occur and provide a fix for the issue.
Furthermore, it might be beneficial to setup an actual use-case for this NPG action and invoke the endpoint that the test tries to invoke. This might help to localise whether if the issue is only within the test context.
Update: Please refer to the comments in https://github.com/sanger/sequencescape/issues/4138#issuecomment-2163397002 as well.
asset_controller
test.Blocking issues Describe any other issues or tickets that may be blocking this change.
Additional context Add any other context about the problem here.