-
- def test_uniquness
- tag = RelationTag.new
- tag.relation_id = current_relation_tags(:t1).relation_id
- tag.k = current_relation_tags(:t1).k
- tag.v = current_relation_tags(:t1).v
- assert tag.new_record?
- assert !tag.valid?
- assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
- assert tag.new_record?
+
+ def test_uniqueness
+ existing = create(:relation_tag)
+ tag = build(:relation_tag, :relation => existing.relation, :k => existing.k, :v => existing.v)
+ assert_predicate tag, :new_record?
+ assert_not_predicate tag, :valid?
+ assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
+ assert_predicate tag, :new_record?