class Document < ApplicationRecord
belongs_to :individual, optional: true
belongs_to :union, optional: true
has_one_attached :file
Upon executing a test patch document_url(documents(:one)), params: { document: { title: documents(:two).title } }, xhr: true an error is returned:
ActiveRecord::RecordNotFound: Couldn't find Individual with 'id'=498572325
app/controllers/documents_controller.rb:42:in `update'
the controller searches for the document's owner to generate an instance variable
@individual = Individual.find(@document.individual_id). A putsin the controller returns consistent with the error @document.individual_id 498572325
The fixtures for documents.yml are
one:
title: MyString1
synopsis: MyString1
individual: individuals(:one)
two:
title: MyString2
synopsis: MyString3
union: unions(:one)
while individuals.yml does not establish a fixed ID, leaving it to the testing environment
one:
shop: shops(:one)
categoryminor: categoryminors(:one)
union: unions(:one)
name_last: MyString1
name_first: MyString1
in the test, before calling the update action, we verify the value of the individuals(:one).id before logging in a user and get
puts individuals(:one).id
==> 980190962
puts documents(:one).individual_id
==> 498572325
So the test result is coherent. 'individual' is not to my knowledge a reserved word.
Why are the test data then shifting? Is this somehow related to Document class using ActiveStorage?