From d595577a4957c1746264d78937d7550a6b443c1f Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Mon, 24 Apr 2017 20:41:43 +0200 Subject: [PATCH] Convert the duplicate_tags node controller test to use factories. --- test/controllers/node_controller_test.rb | 15 ++++++++------- test/factories/node_tags.rb | 3 +-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/controllers/node_controller_test.rb b/test/controllers/node_controller_test.rb index 37ccba9ed..2d876ffd8 100644 --- a/test/controllers/node_controller_test.rb +++ b/test/controllers/node_controller_test.rb @@ -460,25 +460,26 @@ class NodeControllerTest < ActionController::TestCase ## # test adding tags to a node def test_duplicate_tags - existing = create(:node_tag, :node => current_nodes(:public_visible_node)) + existing_tag = create(:node_tag) + assert_equal true, existing_tag.node.changeset.user.data_public # setup auth - basic_authorization(users(:public_user).email, "test") + basic_authorization(existing_tag.node.changeset.user.email, "test") # add an identical tag to the node tag_xml = XML::Node.new("tag") - tag_xml["k"] = existing.k - tag_xml["v"] = existing.v + tag_xml["k"] = existing_tag.k + tag_xml["v"] = existing_tag.v # add the tag into the existing xml - node_xml = current_nodes(:public_visible_node).to_xml + node_xml = existing_tag.node.to_xml node_xml.find("//osm/node").first << tag_xml # try and upload it content node_xml - put :update, :id => current_nodes(:public_visible_node).id + put :update, :id => existing_tag.node.id assert_response :bad_request, "adding duplicate tags to a node should fail with 'bad request'" - assert_equal "Element node/#{current_nodes(:public_visible_node).id} has duplicate tags with key #{existing.k}", @response.body + assert_equal "Element node/#{existing_tag.node.id} has duplicate tags with key #{existing_tag.k}", @response.body end # test whether string injection is possible diff --git a/test/factories/node_tags.rb b/test/factories/node_tags.rb index 267309e90..0a10fc65d 100644 --- a/test/factories/node_tags.rb +++ b/test/factories/node_tags.rb @@ -3,7 +3,6 @@ FactoryGirl.define do sequence(:k) { |n| "Key #{n}" } sequence(:v) { |n| "Value #{n}" } - # Fixme requires node factory - node_id 1 + node end end -- 2.43.2