I just had a bunch of tests fail with errors like this:
ActiveRecord::RecordInvalid:
Validation failed: Name has already been taken
and it looks like this is the problem:
fab!(:the_group) { Fabricate(:group) }
These all worked until recently. I saw this on some other plugin that I was working on and, I think, I contrived to set a random name myself, but these worked, I believe, as recently as yesterday.
Has something changed, or have I done something silly by mistake?
EDIT: With the help of Claude and the Discourse Helper Bot, I tried replacing the above fab
with
Fabricator(:the_group) do
name { sequence(:group_name) { |i| "Test Group #{i}" } }
end
but couldn’t quite figure out how to do it.
I then used
let(:the_group) { Fabricate(:group) }
instead of the above !fab
and this has reduced the number of failures from 12 to 1, but it’s still failing with
1) Pfaffmanager::ServersController servers admin can get servers owned by a group
Failure/Error: let(:the_group) { Fabricate(:group) }
ActiveRecord::RecordInvalid:
Validation failed: Name has already been taken
I don’t think anything around these tests has changed since yesterday at 10:30 AM CDT when I did the last commit.
I reverted to an earlier commit and now it fails with
1) Pfaffmanager::ServersController servers includes groups that the user is in
Failure/Error: let(:the_group) { Fabricate(:group) }
ActiveRecord::RecordInvalid:
Validation failed: Name has already been taken
and I ran it again without making any changes and now it fails on
1) Pfaffmanager::ServersController servers can update group id if group owner
Failure/Error: let(:the_group) { Fabricate(:group) }
ActiveRecord::RecordInvalid:
Validation failed: Name has already been taken
So it seems that it’s failing on one test, and it’s random?