X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/03cad948e30d8f82d0c1c5e249cd6c92bb44dd3d..c9442b669d0f345d13ea64cde34f964d7054e0c9:/test/models/old_relation_tag_test.rb diff --git a/test/models/old_relation_tag_test.rb b/test/models/old_relation_tag_test.rb index a373e386d..d920f91da 100644 --- a/test/models/old_relation_tag_test.rb +++ b/test/models/old_relation_tag_test.rb @@ -31,19 +31,16 @@ class OldRelationTagTest < ActiveSupport::TestCase assert_predicate tag.errors[:v], :any? end - def test_empty_tag_invalid - tag = OldRelationTag.new - assert_not tag.valid?, "Empty tag should be invalid" + def test_orphaned_tag_invalid + tag = create(:old_relation_tag) + tag.old_relation = nil + assert_not tag.valid?, "Orphaned tag should be invalid" assert_predicate tag.errors[:old_relation], :any? end def test_uniqueness existing = create(:old_relation_tag) - tag = OldRelationTag.new - tag.relation_id = existing.relation_id - tag.version = existing.version - tag.k = existing.k - tag.v = existing.v + tag = build(:old_relation_tag, :old_relation => existing.old_relation, :version => existing.version, :k => existing.k, :v => existing.v) assert_predicate tag, :new_record? assert_not tag.valid? assert_raise(ActiveRecord::RecordInvalid) { tag.save! }