- Timecop.freeze(Time.parse("2010-04-03 10:55:00"))
- 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
- assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do
- assert_select "tile", :count => 0
+ # 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)
+
+ travel_to Time.utc(2010, 4, 3, 10, 55, 0) do
+ get :changes
+ assert_response :success
+ now = Time.now.getutc
+ 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 => 0
+ end