]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/api/map_controller_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / controllers / api / map_controller_test.rb
index fb64b07163581259ea6b8cd0ce6bb47b312f0ac0..c050100ae0c56a0fbbbaf7906089d306367e06f6 100644 (file)
@@ -13,7 +13,7 @@ module Api
       @goodbbox = %w[-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
                      -0.1,%20-0.1,%200.1,%200.1 -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1]
       # That last item in the goodbbox really shouldn't be there, as the API should
       @goodbbox = %w[-0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
                      -0.1,%20-0.1,%200.1,%200.1 -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1]
       # That last item in the goodbbox really shouldn't be there, as the API should
-      # reall reject it, however this is to test to see if the api changes.
+      # really reject it, however this is to test to see if the api changes.
     end
 
     ##
     end
 
     ##
@@ -129,10 +129,19 @@ module Api
         print @request.to_yaml
         print @response.body
       end
         print @request.to_yaml
         print @response.body
       end
-      assert_response :success, "Expected scucess with the map call"
+      assert_response :success, "Expected success with the map call"
       assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
       assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
-        assert_select "bounds[minlon='#{format('%.7f', minlon)}'][minlat='#{format('%.7f', minlat)}'][maxlon='#{format('%.7f', maxlon)}'][maxlat='#{format('%.7f', maxlat)}']", :count => 1
-        assert_select "node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
+        assert_select "bounds[minlon='#{format('%<lon>.7f', :lon => minlon)}']" \
+                      "[minlat='#{format('%<lat>.7f', :lat => minlat)}']" \
+                      "[maxlon='#{format('%<lon>.7f', :lon => maxlon)}']" \
+                      "[maxlat='#{format('%<lat>.7f', :lat => maxlat)}']", :count => 1
+        assert_select "node[id='#{node.id}']" \
+                      "[lat='#{format('%<lat>.7f', :lat => node.lat)}']" \
+                      "[lon='#{format('%<lon>.7f', :lon => node.lon)}']" \
+                      "[version='#{node.version}']" \
+                      "[changeset='#{node.changeset_id}']" \
+                      "[visible='#{node.visible}']" \
+                      "[timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
           # This should really be more generic
           assert_select "tag[k='#{tag.k}'][v='#{tag.v}']"
         end
           # This should really be more generic
           assert_select "tag[k='#{tag.k}'][v='#{tag.v}']"
         end
@@ -181,7 +190,7 @@ module Api
                                    .select { |a| a["version"] == node.version }
                                    .select { |a| a["changeset"] == node.changeset_id }
                                    .select { |a| a["timestamp"] == node.timestamp.xmlschema }
                                    .select { |a| a["version"] == node.version }
                                    .select { |a| a["changeset"] == node.changeset_id }
                                    .select { |a| a["timestamp"] == node.timestamp.xmlschema }
-      assert_equal result_nodes.count, 1
+      assert_equal(1, result_nodes.count)
       result_node = result_nodes.first
 
       assert_equal result_node["tags"], tag.k => tag.v
       result_node = result_nodes.first
 
       assert_equal result_node["tags"], tag.k => tag.v
@@ -205,8 +214,17 @@ module Api
       get map_path(:bbox => bbox)
       assert_response :success, "The map call should have succeeded"
       assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
       get map_path(:bbox => bbox)
       assert_response :success, "The map call should have succeeded"
       assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", :count => 1 do
-        assert_select "bounds[minlon='#{node.lon}'][minlat='#{node.lat}'][maxlon='#{node.lon}'][maxlat='#{node.lat}']", :count => 1
-        assert_select "node[id='#{node.id}'][lat='#{format('%.7f', node.lat)}'][lon='#{format('%.7f', node.lon)}'][version='#{node.version}'][changeset='#{node.changeset_id}'][visible='#{node.visible}'][timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
+        assert_select "bounds[minlon='#{node.lon}']" \
+                      "[minlat='#{node.lat}']" \
+                      "[maxlon='#{node.lon}']" \
+                      "[maxlat='#{node.lat}']", :count => 1
+        assert_select "node[id='#{node.id}']" \
+                      "[lat='#{format('%<lat>.7f', :lat => node.lat)}']" \
+                      "[lon='#{format('%<lon>.7f', :lon => node.lon)}']" \
+                      "[version='#{node.version}']" \
+                      "[changeset='#{node.changeset_id}']" \
+                      "[visible='#{node.visible}']" \
+                      "[timestamp='#{node.timestamp.xmlschema}']", :count => 1 do
           # This should really be more generic
           assert_select "tag[k='#{tag.k}'][v='#{tag.v}']"
         end
           # This should really be more generic
           assert_select "tag[k='#{tag.k}'][v='#{tag.v}']"
         end
@@ -260,7 +278,7 @@ module Api
     def test_map_without_bbox
       get map_path
       assert_response :bad_request
     def test_map_without_bbox
       get map_path
       assert_response :bad_request
-      assert_equal "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "A bbox param was expected"
+      assert_equal "The parameter bbox is required", @response.body, "A bbox param was expected"
     end
 
     def test_bbox_too_big
     end
 
     def test_bbox_too_big
@@ -275,7 +293,7 @@ module Api
       @badmalformedbbox.each do |bbox|
         get map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to be malformed"
       @badmalformedbbox.each do |bbox|
         get map_path(:bbox => bbox)
         assert_response :bad_request, "The bbox:#{bbox} was expected to be malformed"
-        assert_equal "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "bbox: #{bbox}"
+        assert_equal "The parameter bbox must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "bbox: #{bbox}"
       end
     end
 
       end
     end