Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#59866] fixed update contract #17354

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?
NobodysNightmare marked this conversation as resolved.
Show resolved Hide resolved

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
Loading