jeudi 29 septembre 2016

FactoryGirl set updated_at attribute in factory

Using FactoryGirl 4.7.0, I have a factory that I want to specify the updated_at attribute to a date in the past.

factory :living_arrangement do

    trait :expired do
        updated_at Date.new(2012, 3, 6)
        # or
        updated_at { Date.new(2012, 3, 6) }
    end
end

However these are not working. The factory updated_at attribute keeps getting set back to Date.now.

How do I get this to work?

Aucun commentaire:

Enregistrer un commentaire