rgsoc-teams
rgsoc-teams copied to clipboard
Application form: touch draft record when updating the student fields
Since the student fields are saved on the User instance, the ApplicationDraft instance will not update updated_at. That should be changed to avoid confusion.
Possible conflict with #201 when comparing updated_at timestamps?
@carpodaster Hello, I noticed this issue is still open. I am a first-time contributor and was hoping to help out with this issue. If there is already a solution in progress I would be happy to help out elsewhere. @marshallhouston will be contributing as well.
@carpodaster Hello again! After going through the code and experimenting with the application, it became apparent to @marshallhouston and I that we were not clear on the issue that is trying to be solved. Our thoughts are that the application_draft is not updating when one of the student fields is being edited because the updater field on application_draft does not change. This is a snippet of the test we were starting to write in the spec/controllers/application_drafs_controller_spec inside the describe patch block.
it 'changes the application_draft updated_at attribute when a student field is updated' do
expect {
patch :update, { params: { id: draft.to_param, student: { name: 'Foo!' },
application_draft: { misc_info: draft.misc_info } } }
}.to change { draft.reload.updated_at }
end
Is this test on the right track?
Hey @dionew1 👋
sorry for the late response - could you already figure out how to solve the problem?
I think it's not even necessary to write controller specs for this, normal unit tests in the model directory should actually be enough to cover this behavior. Aside that, your test also sort of misses the point - since you're also updating an attribute on the application_draft, namely the misc_info - so it's a false positive 😉
What you need is probably touch for the association. Maybe take a look here in the docs.
Does this help you?