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! }