I am using latest ruby 3.3.3 and latest rails 7.1.3.4.
I am new to rails and I am learning it. Sorry if my request seems dumb to some.
I got this error when I run tests.
It seems that ActiveRecord is unable to prefill them with Time.now
. According to the documentation here, it should do so.
I tried to reproduce the issue in a clean install but it worked just fine. I don't understand what's going wrong in my project, especially it's almost the same code.
Here is how my model looks like:
class Drive < ApplicationRecord
with_options presence: true do
validates :name
validates :provider
validates :credentials
end
encrypts :credentials
end
The migration file:
class CreateDrives < ActiveRecord::Migration[7.1]
def change
create_table :drives do |t|
t.string :name
t.string :provider
t.text :credentials
t.timestamps
end
end
end
The fixtures:
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
provider: MyString
credentials: MyText
two:
name: MyString
provider: MyString
credentials: MyText
When looking at test.log I find these entries:
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
[1m[36mFixtures Load (0.2ms)[0m [1m[31mDELETE FROM "drives";
INSERT INTO "drives" ("name", "provider", "credentials") VALUES ('MyString', 'MyString', 'MyText');
INSERT INTO "drives" ("name", "provider", "credentials") VALUES ('MyString', 'MyString', 'MyText')[0m
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
I couldn't find what's going wrong and fix it. Help is much appreciated