From b0bcd5984eed1b7657dae0d89a997853ab60690c Mon Sep 17 00:00:00 2001 From: Cory Streiff Date: Mon, 6 Jan 2025 22:08:09 +0100 Subject: [PATCH] Fix factory bot lint error --- app/models/tagging.rb | 2 +- spec/factories/taggings.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/tagging.rb b/app/models/tagging.rb index 4198a627c4..5de8d9a9bb 100644 --- a/app/models/tagging.rb +++ b/app/models/tagging.rb @@ -19,7 +19,7 @@ class Tagging < ApplicationRecord validates :tag_id, uniqueness: {scope: :taggable, message: "has already been applied"} - after_initialize :set_organization_id + before_create :set_organization_id def set_organization_id self.organization_id ||= taggable.organization_id diff --git a/spec/factories/taggings.rb b/spec/factories/taggings.rb index d4b9ebd1ed..30cb945253 100644 --- a/spec/factories/taggings.rb +++ b/spec/factories/taggings.rb @@ -12,7 +12,7 @@ # FactoryBot.define do factory :tagging do - organization { create(:organization) } + organization { Organization.try(:first) || create(:organization) } tag { create(:tag) } taggable { create(:product_drive) } end