From 3438c15c8f0a1b1c624a25277691f868dc0c1a85 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Thu, 1 Jun 2017 10:52:05 +0100 Subject: [PATCH] create nodes from factories for the api changes test. --- test/controllers/api_controller_test.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index 0715a64ad..6501ba3bc 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -2,8 +2,6 @@ require "test_helper" require "api_controller" class ApiControllerTest < ActionController::TestCase - api_fixtures - def setup super @badbigbbox = %w(-0.1,-0.1,1.1,1.1 10,10,11,11) @@ -295,12 +293,20 @@ class ApiControllerTest < ActionController::TestCase # http://wiki.openstreetmap.org/wiki/Rails#Installing_the_quadtile_functions # or by looking at the readme in db/README def test_changes_simple + # create a selection of nodes + (1..5).each do |n| + create(:node, :timestamp => Time.utc(2007, 1, 1, 0, 0, 0), :lat => n, :lon => n) + end + # deleted nodes should also be counted + create(:node, :deleted, :timestamp => Time.utc(2007, 1, 1, 0, 0, 0), :lat => 6, :lon => 6) + # nodes in the same tile won't change the total + create(:node, :timestamp => Time.utc(2007, 1, 1, 0, 0, 0), :lat => 6, :lon => 6) + # nodes with a different timestamp should be ignored + create(:node, :timestamp => Time.utc(2008, 1, 1, 0, 0, 0), :lat => 7, :lon => 7) + Timecop.freeze(Time.utc(2010, 4, 3, 10, 55, 0)) get :changes assert_response :success - # print @response.body - # As we have loaded the fixtures, we can assume that there are no - # changes at the time we have frozen at now = Time.now.getutc hourago = now - 1.hour assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do @@ -320,7 +326,7 @@ class ApiControllerTest < ActionController::TestCase hourago = now - 1.hour assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do - assert_select "tile", :count => 10 + assert_select "tile", :count => 6 end end Timecop.return -- 2.43.2