From 76b6d7d8760a04c39c574aed8a19682868176955 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Tue, 29 Sep 2009 03:58:33 +0000 Subject: [PATCH] Tests for [17838] Why is our testing fixtures such a mess? It took me half an hour to find a useable node. And I'm still not sure if it's ok, since I want to get to bed. kthxbye --- test/fixtures/current_way_nodes.yml | 10 ++++++++++ test/fixtures/current_ways.yml | 7 +++++++ test/fixtures/way_nodes.yml | 12 ++++++++++++ test/fixtures/ways.yml | 6 ++++++ test/functional/way_controller_test.rb | 7 +++---- test/unit/way_node_test.rb | 2 +- test/unit/way_test.rb | 2 +- 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/test/fixtures/current_way_nodes.yml b/test/fixtures/current_way_nodes.yml index 66aae0f20..ced1a686c 100644 --- a/test/fixtures/current_way_nodes.yml +++ b/test/fixtures/current_way_nodes.yml @@ -17,3 +17,13 @@ t4: id: 4 node_id: 15 sequence_id: 1 + +w5_n1: + id: 5 + node_id: 4 + sequence_id: 1 + +w5_n2: + id: 5 + node_id: 4 + sequence_id: 2 diff --git a/test/fixtures/current_ways.yml b/test/fixtures/current_ways.yml index 51b585df0..cd06d06d3 100644 --- a/test/fixtures/current_ways.yml +++ b/test/fixtures/current_ways.yml @@ -25,3 +25,10 @@ way_with_versions: timestamp: 2008-01-01 00:04:00 visible: true version: 4 + +way_with_duplicate_nodes: + id: 5 + changeset_id: 2 + timestamp: 2007-01-01 00:00:00 + visible: true + version: 1 diff --git a/test/fixtures/way_nodes.yml b/test/fixtures/way_nodes.yml index 0b43f6a9c..3f7a3dbde 100644 --- a/test/fixtures/way_nodes.yml +++ b/test/fixtures/way_nodes.yml @@ -63,3 +63,15 @@ w4_v4_n1: node_id: 15 sequence_id: 1 version: 4 + +w5_n1: + id: 5 + node_id: 4 + sequence_id: 1 + version: 1 + +w5_n2: + id: 5 + node_id: 4 + sequence_id: 2 + version: 1 diff --git a/test/fixtures/ways.yml b/test/fixtures/ways.yml index 62ff2458d..090508702 100644 --- a/test/fixtures/ways.yml +++ b/test/fixtures/ways.yml @@ -47,3 +47,9 @@ way_with_versions_v4: visible: true version: 4 +way_with_duplicate_nodes: + id: 5 + changeset_id: 2 + timestamp: 2007-01-01 00:00:00 + visible: true + version: 1 diff --git a/test/functional/way_controller_test.rb b/test/functional/way_controller_test.rb index 607f2dc6f..6b58137ae 100644 --- a/test/functional/way_controller_test.rb +++ b/test/functional/way_controller_test.rb @@ -41,11 +41,10 @@ class WayControllerTest < ActionController::TestCase assert_select "osm way[id=#{way.id}][version=#{way.version}][visible=#{way.visible}]", 1 # check that each node in the way appears once in the output as a - # reference and as the node element. note the slightly dodgy assumption - # that nodes appear only once. this is currently the case with the - # fixtures, but it doesn't have to be. + # reference and as the node element. way.nodes.each do |n| - assert_select "osm way nd[ref=#{n.id}]", 1 + count = (way.nodes - (way.nodes - [n])).length + assert_select "osm way nd[ref=#{n.id}]", count assert_select "osm node[id=#{n.id}][version=#{n.version}][lat=#{n.lat}][lon=#{n.lon}]", 1 end end diff --git a/test/unit/way_node_test.rb b/test/unit/way_node_test.rb index edb6558fa..608d5c5ae 100644 --- a/test/unit/way_node_test.rb +++ b/test/unit/way_node_test.rb @@ -4,7 +4,7 @@ class WayNodeTest < ActiveSupport::TestCase api_fixtures def test_way_nodes_count - assert_equal 4, WayNode.count + assert_equal 6, WayNode.count end end diff --git a/test/unit/way_test.rb b/test/unit/way_test.rb index c13c9755f..39da76ec0 100644 --- a/test/unit/way_test.rb +++ b/test/unit/way_test.rb @@ -6,7 +6,7 @@ class WayTest < ActiveSupport::TestCase # Check that we have the correct number of currnet ways in the db # This will need to updated whenever the current_ways.yml is updated def test_db_count - assert_equal 4, Way.count + assert_equal 5, Way.count end def test_bbox -- 2.43.2