Fix specs after adding the principal_explicit flag

This commit is contained in:
Klaus Zanders
2026-06-08 15:15:25 +02:00
parent e3fe605ce9
commit f3319c8a36
3 changed files with 6 additions and 2 deletions
@@ -80,7 +80,7 @@ RSpec.describe ResourceAllocation do
end
it "tracks filter_name changes" do
allocation.update!(filter_name: "Full stack Developer (DE-EN)")
allocation.update!(principal_explicit: false, filter_name: "Full stack Developer (DE-EN)")
expect(allocation.last_journal.data.filter_name).to eq("Full stack Developer (DE-EN)")
expect(allocation.last_journal.details).to include("filter_name" => [nil, "Full stack Developer (DE-EN)"])
@@ -32,6 +32,8 @@ require "spec_helper"
RSpec.describe ResourceAllocation do
describe "associations" do
subject { described_class.new(principal_explicit: false) }
it { is_expected.to belong_to(:entity).required }
it { is_expected.to belong_to(:principal).class_name("User").inverse_of(:resource_allocations).optional }
it { is_expected.to belong_to(:requested_by).class_name("User").optional }
@@ -39,7 +39,9 @@ RSpec.describe Principals::DeleteJob, "ResourceAllocation", type: :model do
context "with a resource allocation assigned to the principal" do
let!(:allocation) { create(:resource_allocation, principal:) }
let!(:other_allocation) { create(:resource_allocation, principal: create(:user)) }
let!(:unassigned_allocation) { create(:resource_allocation, principal: nil) }
let!(:unassigned_allocation) do
create(:resource_allocation, principal: nil, principal_explicit: false, filter_name: "Devs")
end
it "rewrites the principal to the deleted user placeholder" do
job