]> git.openstreetmap.org Git - rails.git/commitdiff
Convert the duplicate_tags node controller test to use factories.
authorAndy Allan <git@gravitystorm.co.uk>
Mon, 24 Apr 2017 18:41:43 +0000 (20:41 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Mon, 24 Apr 2017 18:41:43 +0000 (20:41 +0200)
test/controllers/node_controller_test.rb
test/factories/node_tags.rb

index 37ccba9ed5cf3f22bdd3bcf704e103777cf23f22..2d876ffd89c8537b2f8e63c1d1819bb31c321d87 100644 (file)
@@ -460,25 +460,26 @@ class NodeControllerTest < ActionController::TestCase
   ##
   # test adding tags to a node
   def test_duplicate_tags
   ##
   # 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
     # 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")
 
     # 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
 
     # 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
     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_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
   end
 
   # test whether string injection is possible
index 267309e90f8e43012cb78af12ccb830a075be40c..0a10fc65d6565a64b41fe52a0d443268b3e7f64c 100644 (file)
@@ -3,7 +3,6 @@ FactoryGirl.define do
     sequence(:k) { |n| "Key #{n}" }
     sequence(:v) { |n| "Value #{n}" }
 
     sequence(:k) { |n| "Key #{n}" }
     sequence(:v) { |n| "Value #{n}" }
 
-    # Fixme requires node factory
-    node_id 1
+    node
   end
 end
   end
 end