Create a redactions factory and use for model tests.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 15 Mar 2017 16:24:39 +0000 (16:24 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 15 Mar 2017 16:24:39 +0000 (16:24 +0000)
test/factories/redaction.rb [new file with mode: 0644]
test/models/redaction_test.rb

diff --git a/test/factories/redaction.rb b/test/factories/redaction.rb
new file mode 100644 (file)
index 0000000..0ee5f19
--- /dev/null
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+  factory :redaction do
+    sequence(:title) { |n| "Redaction #{n}" }
+    sequence(:description) { |n| "Description of redaction #{n}" }
+
+    user
+  end
+end
index b30c80c66e52502ec33f8865826bafce7f88723a..3cadb8a089c7ff3a51dd2e2ee9b52fe09903c49e 100644 (file)
@@ -3,11 +3,10 @@ require "osm"
 
 class RedactionTest < ActiveSupport::TestCase
   api_fixtures
-  fixtures :redactions
 
   def test_cannot_redact_current
     n = current_nodes(:node_with_versions)
-    r = redactions(:example)
+    r = create(:redaction)
     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
     assert_raise(OSM::APICannotRedactError) do
       n.redact!(r)
@@ -16,7 +15,7 @@ class RedactionTest < ActiveSupport::TestCase
 
   def test_cannot_redact_current_via_old
     n = nodes(:node_with_versions_v4)
-    r = redactions(:example)
+    r = create(:redaction)
     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
     assert_raise(OSM::APICannotRedactError) do
       n.redact!(r)
@@ -25,7 +24,7 @@ class RedactionTest < ActiveSupport::TestCase
 
   def test_can_redact_old
     n = nodes(:node_with_versions_v3)
-    r = redactions(:example)
+    r = create(:redaction)
     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
     assert_nothing_raised(OSM::APICannotRedactError) do
       n.redact!(r)