BURs: don't allow requesting implications that already exist.

Fix it being possible to request duplicate implications.
This commit is contained in:
evazion
2020-11-12 19:37:55 -06:00
parent 654d2175b6
commit 25cba710bf
6 changed files with 20 additions and 4 deletions

View File

@@ -129,6 +129,14 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
assert_equal(["Can't create implication a -> c (a already implies c through another implication)"], @bur.errors.full_messages)
end
should "fail for an implication that is a duplicate of an existing implication" do
create(:tag_implication, antecedent_name: "a", consequent_name: "b")
@bur = build(:bulk_update_request, script: "imply a -> b")
assert_equal(false, @bur.valid?)
assert_equal(["Can't create implication a -> b (Implication already exists)"], @bur.errors.full_messages)
end
should_eventually "fail for an implication that is redundant with another implication in the same BUR" do
create(:tag_implication, antecedent_name: "b", consequent_name: "c")
@bur = build(:bulk_update_request, script: "imply a -> b\nimply a -> c")

View File

@@ -47,7 +47,7 @@ class TagImplicationTest < ActiveSupport::TestCase
[ti1, ti2, ti3, ti4, ti5].each { |ti| assert(ti.valid?) }
ti5.update(status: "active")
assert_includes(ti5.errors[:antecedent_name], "has already been taken")
assert_includes(ti5.errors[:antecedent_name], "Implication already exists")
end
end
@@ -115,7 +115,7 @@ class TagImplicationTest < ActiveSupport::TestCase
ti2 = FactoryBot.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
ti2.save
assert(ti2.errors.any?, "Tag implication should not have validated.")
assert_includes(ti2.errors.full_messages, "Antecedent name has already been taken")
assert_includes(ti2.errors.full_messages, "Implication already exists")
end
should "not validate if its antecedent or consequent are aliased to another tag" do