]> git.openstreetmap.org Git - rails.git/commitdiff
Use factories for tag uniqueness tests
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 30 Mar 2022 16:15:11 +0000 (17:15 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 30 Mar 2022 16:15:11 +0000 (17:15 +0100)
test/models/changeset_tag_test.rb
test/models/node_tag_test.rb
test/models/old_node_tag_test.rb
test/models/old_relation_tag_test.rb
test/models/old_way_tag_test.rb
test/models/relation_tag_test.rb
test/models/way_tag_test.rb

index 4ac372416616c7410bae782fff1432196291ffb9..5832b8a706523674aeb96cc6ca21d8e770a9dcc8 100644 (file)
@@ -40,10 +40,7 @@ class ChangesetTagTest < ActiveSupport::TestCase
 
   def test_uniqueness
     existing = create(:changeset_tag)
-    tag = ChangesetTag.new
-    tag.changeset_id = existing.changeset_id
-    tag.k = existing.k
-    tag.v = existing.v
+    tag = build(:changeset_tag, :changeset => existing.changeset, :k => existing.k, :v => existing.v)
     assert_predicate tag, :new_record?
     assert_not tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
index a7e72df73ae4fa6bcc1c1e24b5389091b38ca564..d927b5fea202edc7d9f945c40fa13bc2bdacbb0f 100644 (file)
@@ -40,10 +40,7 @@ class NodeTagTest < ActiveSupport::TestCase
 
   def test_uniqueness
     existing = create(:node_tag)
-    tag = NodeTag.new
-    tag.node_id = existing.node_id
-    tag.k = existing.k
-    tag.v = existing.v
+    tag = build(:node_tag, :node => existing.node, :k => existing.k, :v => existing.v)
     assert_predicate tag, :new_record?
     assert_not tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
index ed819c11165048d8ab388903b29a2f0af18fea14..40c91c82d54a9624f882cf1739623c4ca7a9d3ff 100644 (file)
@@ -40,11 +40,7 @@ class OldNodeTagTest < ActiveSupport::TestCase
 
   def test_uniqueness
     existing = create(:old_node_tag)
-    tag = OldNodeTag.new
-    tag.node_id = existing.node_id
-    tag.version = existing.version
-    tag.k = existing.k
-    tag.v = existing.v
+    tag = build(:old_node_tag, :old_node => existing.old_node, :version => existing.version, :k => existing.k, :v => existing.v)
     assert_predicate tag, :new_record?
     assert_not tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
index d21cb27183d329e297a00e813cd4f01399d40119..d920f91da197370f8225ece0c43b8778d222ff84 100644 (file)
@@ -40,11 +40,7 @@ class OldRelationTagTest < ActiveSupport::TestCase
 
   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! }
index 121829111acf454d040f301959d4eb0ba667085a..793962438dc57d49336b208b69af994ec3b8912d 100644 (file)
@@ -40,7 +40,7 @@ class OldWayTagTest < ActiveSupport::TestCase
 
   def test_uniqueness
     existing = create(:old_way_tag)
-    tag = OldWayTag.new
+    tag = build(:old_way_tag, :old_way => existing.old_way, :version => existing.version, :k => existing.k, :v => existing.v)
     tag.way_id = existing.way_id
     tag.version = existing.version
     tag.k = existing.k
index 792671e2889296b1899229265bf699a863993cf0..69a491890101b0f8e5122198066f11300e2230e6 100644 (file)
@@ -40,10 +40,7 @@ class RelationTagTest < ActiveSupport::TestCase
 
   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! }
index da13068da4b5f6c0ef3a4b9091700b51eb8f7320..64aacc63b532660bb7278721addc0f8c9fc6001b 100644 (file)
@@ -40,7 +40,7 @@ class WayTagTest < ActiveSupport::TestCase
 
   def test_uniqueness
     existing = create(:way_tag)
-    tag = WayTag.new
+    tag = build(:way_tag, :way => existing.way, :k => existing.k, :v => existing.v)
     tag.way_id = existing.way_id
     tag.k = existing.k
     tag.v = existing.v