]> git.openstreetmap.org Git - rails.git/commitdiff
Create a changeset factory, and use it for model tests.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Mar 2017 10:47:24 +0000 (10:47 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Mar 2017 10:47:24 +0000 (10:47 +0000)
test/factories/changesets.rb [new file with mode: 0644]
test/models/changeset_comment_test.rb
test/models/node_test.rb

diff --git a/test/factories/changesets.rb b/test/factories/changesets.rb
new file mode 100644 (file)
index 0000000..f76b731
--- /dev/null
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+  factory :changeset do
+    created_at Time.now.utc
+    closed_at Time.now.utc + 1.day
+
+    user
+  end
+end
index 64fbb36637e253fec6ea954ef009c5a114f0d86b..5ef0c1d93ee9de6fca964fdc5e383fff0dd13a00 100644 (file)
@@ -33,8 +33,9 @@ class ChangesetCommentTest < ActiveSupport::TestCase
   end
 
   def test_comments_of_changeset_count
-    create_list(:changeset_comment, 3, :changeset_id => changesets(:normal_user_closed_change).id)
-    assert_equal 3, Changeset.find(changesets(:normal_user_closed_change).id).comments.count
+    changeset = create(:changeset)
+    create_list(:changeset_comment, 3, :changeset_id => changeset.id)
+    assert_equal 3, Changeset.find(changeset.id).comments.count
   end
 
   def test_body_valid
index 85bdfc99559a60f4805f83d7625eb6c7ea8b3dad..31f7d6ed5f47aaebc33e631572a8d49748ebf588 100644 (file)
@@ -77,14 +77,15 @@ class NodeTest < ActiveSupport::TestCase
 
   # Check that you can create a node and store it
   def test_create
+    changeset = create(:changeset)
     node_template = Node.new(
       :latitude => 12.3456,
       :longitude => 65.4321,
-      :changeset_id => changesets(:normal_user_first_change).id,
+      :changeset_id => changeset.id,
       :visible => 1,
       :version => 1
     )
-    assert node_template.create_with_history(changesets(:normal_user_first_change).user)
+    assert node_template.create_with_history(changeset.user)
 
     node = Node.find(node_template.id)
     assert_not_nil node