]> git.openstreetmap.org Git - rails.git/blobdiff - test/models/relation_tag_test.rb
Fix new rubocop warnings
[rails.git] / test / models / relation_tag_test.rb
index 4e9108a634da14576367a047c8d6e57536c1e989..69a491890101b0f8e5122198066f11300e2230e6 100644 (file)
@@ -31,18 +31,16 @@ class RelationTagTest < ActiveSupport::TestCase
     assert_predicate tag.errors[:v], :any?
   end
 
-  def test_empty_tag_invalid
-    tag = RelationTag.new
-    assert_not tag.valid?, "Empty relation tag should be invalid"
+  def test_orphaned_tag_invalid
+    tag = create(:relation_tag)
+    tag.relation = nil
+    assert_not tag.valid?, "Orphaned tag should be invalid"
     assert_predicate tag.errors[:relation], :any?
   end
 
   def test_uniqueness
     existing = create(:relation_tag)
-    tag = RelationTag.new
-    tag.relation_id = existing.relation_id
-    tag.k = existing.k
-    tag.v = existing.v
+    tag = build(:relation_tag, :relation => existing.relation, :k => existing.k, :v => existing.v)
     assert_predicate tag, :new_record?
     assert_not tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }