From 56752ac02ae1b99a5bcf36bfe390bf5d98ce2ab8 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 22 Mar 2017 10:47:24 +0000 Subject: [PATCH] Create a changeset factory, and use it for model tests. --- test/factories/changesets.rb | 8 ++++++++ test/models/changeset_comment_test.rb | 5 +++-- test/models/node_test.rb | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 test/factories/changesets.rb diff --git a/test/factories/changesets.rb b/test/factories/changesets.rb new file mode 100644 index 000000000..f76b73126 --- /dev/null +++ b/test/factories/changesets.rb @@ -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 diff --git a/test/models/changeset_comment_test.rb b/test/models/changeset_comment_test.rb index 64fbb3663..5ef0c1d93 100644 --- a/test/models/changeset_comment_test.rb +++ b/test/models/changeset_comment_test.rb @@ -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 diff --git a/test/models/node_test.rb b/test/models/node_test.rb index 85bdfc995..31f7d6ed5 100644 --- a/test/models/node_test.rb +++ b/test/models/node_test.rb @@ -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 -- 2.39.5