I'm trigering validations for new records but I don't want to trigger validations if that record with invalid data is already created and exists in the database.
It seems that I can only use build and create with rspec/factory which will always trigger the validations. Even if created/ built with a past date it won't work because "create" and "build" does trigger validations.
how can I fake an existing record?
thank you
Edit:
Using the following seems to do the trick:
let(:record_name) build(....invalid_data )
record_name.update_attribute(:created_at, date_in_the_past)
If I understand this correctly "update_attribute" will skip the validations when updating the created_at attribute.
So by the time it runs expect(record_name).to be_valid
it will consider this record as a record created in the past.
did I get the purpose of "update_attribute" correctly?