Skip to content

Commit

Permalink
[#59866] fixed update contract
Browse files Browse the repository at this point in the history
- https://community.openproject.org/work_packages/59866
- skip uniqueness check for short if short is deleted
  • Loading branch information
Kharonus committed Dec 5, 2024
1 parent 310785e commit 01f5cb1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class UpdateItemContract < Dry::Validation::Contract

rule(:short) do
next if schema_error?(:item)
next unless key?

key.failure(:not_unique) if values[:item].siblings.exists?(short: value)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
let!(:vader) { create(:hierarchy_item) }
let!(:luke) { create(:hierarchy_item, label: "luke", short: "ls", parent: vader) }
let!(:leia) { create(:hierarchy_item, label: "leia", short: "lo", parent: vader) }
let!(:starkiller) { create(:hierarchy_item, label: "starkiller", parent: vader) }

context "when all required fields are valid" do
it "is valid" do
Expand Down
1 change: 0 additions & 1 deletion spec/factories/hierarchy_item_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
FactoryBot.define do
factory :hierarchy_item, class: "CustomField::Hierarchy::Item" do
sequence(:label) { |n| "Item #{n}" }
sequence(:short) { |n| "I #{n}" }
end
end

0 comments on commit 01f5cb1

Please sign in to comment.