Replace changeset_tags fixtures with a factory.
authorAndy Allan <git@gravitystorm.co.uk>
Sun, 30 Oct 2016 11:45:02 +0000 (12:45 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Sun, 30 Oct 2016 11:45:02 +0000 (12:45 +0100)
.rubocop_todo.yml
test/controllers/changeset_controller_test.rb
test/factories/changeset_tags.rb [new file with mode: 0644]
test/fixtures/changeset_tags.yml [deleted file]
test/models/changeset_tag_test.rb
test/test_helper.rb

index 95ddea8f893b186fa297cfddcc3a176a0aed2f71..b5834b8ce4ad2f968579b137f07bcfe8d23108e0 100644 (file)
@@ -64,7 +64,7 @@ Metrics/BlockNesting:
 # Offense count: 62
 # Configuration parameters: CountComments.
 Metrics/ClassLength:
 # Offense count: 62
 # Configuration parameters: CountComments.
 Metrics/ClassLength:
-  Max: 1652
+  Max: 1653
 
 # Offense count: 69
 Metrics/CyclomaticComplexity:
 
 # Offense count: 69
 Metrics/CyclomaticComplexity:
index a9a838aff9da8749f41575ab78b32cad826ee2e3..5744ed9abbd8f24f7f3ccd385d0b9f4e288c9eea 100644 (file)
@@ -1649,6 +1649,7 @@ EOF
 
     ## Now try with the public user
     changeset = changesets(:public_user_first_change)
 
     ## Now try with the public user
     changeset = changesets(:public_user_first_change)
+    create(:changeset_tag, :changeset => changeset)
     new_changeset = changeset.to_xml
     new_tag = XML::Node.new "tag"
     new_tag["k"] = "tagtesting"
     new_changeset = changeset.to_xml
     new_tag = XML::Node.new "tag"
     new_tag["k"] = "tagtesting"
diff --git a/test/factories/changeset_tags.rb b/test/factories/changeset_tags.rb
new file mode 100644 (file)
index 0000000..fa728f0
--- /dev/null
@@ -0,0 +1,9 @@
+FactoryGirl.define do
+  factory :changeset_tag do
+    sequence(:k) { |n| "Key #{n}" }
+    sequence(:v) { |n| "Value #{n}" }
+
+    # Fixme requires changeset factory
+    changeset_id 1
+  end
+end
diff --git a/test/fixtures/changeset_tags.yml b/test/fixtures/changeset_tags.yml
deleted file mode 100644 (file)
index ab5968b..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-changeset_1_tag_1: 
-  changeset_id: 1
-  k: created_by
-  v: test suite yml
-  
-changeset_2_tag_1: 
-  changeset_id: 2
-  k: created_by
-  v: test suite yml 2
index e62808b6eb38ef7ea1ea0283bb886182e54721b9..90a8518b431bf1befe77dae90d260f9fe483e150 100644 (file)
@@ -3,10 +3,6 @@ require "test_helper"
 class ChangesetTagTest < ActiveSupport::TestCase
   api_fixtures
 
 class ChangesetTagTest < ActiveSupport::TestCase
   api_fixtures
 
-  def test_changeset_tag_count
-    assert_equal 2, ChangesetTag.count
-  end
-
   def test_length_key_valid
     key = "k"
     (0..255).each do |i|
   def test_length_key_valid
     key = "k"
     (0..255).each do |i|
@@ -58,10 +54,11 @@ class ChangesetTagTest < ActiveSupport::TestCase
   end
 
   def test_uniqueness
   end
 
   def test_uniqueness
+    existing = create(:changeset_tag)
     tag = ChangesetTag.new
     tag = ChangesetTag.new
-    tag.changeset_id = changeset_tags(:changeset_1_tag_1).changeset_id
-    tag.k = changeset_tags(:changeset_1_tag_1).k
-    tag.v = changeset_tags(:changeset_1_tag_1).v
+    tag.changeset_id = existing.changeset_id
+    tag.k = existing.k
+    tag.v = existing.v
     assert tag.new_record?
     assert !tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
     assert tag.new_record?
     assert !tag.valid?
     assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
index 0cf7c4afba2037bff098d1613079b9c26a7a97ec..95b1df307fec59d3e5876470734ba4cf2a4cb30b 100644 (file)
@@ -14,7 +14,7 @@ module ActiveSupport
     def self.api_fixtures
       # print "setting up the api_fixtures"
       fixtures :users, :user_roles
     def self.api_fixtures
       # print "setting up the api_fixtures"
       fixtures :users, :user_roles
-      fixtures :changesets, :changeset_tags
+      fixtures :changesets
 
       fixtures :current_nodes, :nodes
       set_fixture_class :current_nodes => Node
 
       fixtures :current_nodes, :nodes
       set_fixture_class :current_nodes => Node