X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/03408b6294e0aa56d46823c1f44d47aaf69e226b..43c09d8062fc4aef4f1e0e5d3598e526a02bb288:/test/controllers/api_controller_test.rb diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb index efcc06307..cdc20a1aa 100644 --- a/test/controllers/api_controller_test.rb +++ b/test/controllers/api_controller_test.rb @@ -1,5 +1,4 @@ require "test_helper" -require "api_controller" class ApiControllerTest < ActionController::TestCase def setup @@ -304,32 +303,32 @@ class ApiControllerTest < ActionController::TestCase # 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 - 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 + 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 end end - Timecop.return - Timecop.freeze(Time.utc(2007, 1, 1, 0, 30, 0)) - get :changes - assert_response :success - # print @response.body - # As we have loaded the fixtures, we can assume that there are some - # 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 => 6 + travel_to Time.utc(2007, 1, 1, 0, 30, 0) do + get :changes + assert_response :success + # print @response.body + # As we have loaded the fixtures, we can assume that there are some + # 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 => 6 + end end end - Timecop.return end def test_changes_zoom_invalid @@ -406,7 +405,7 @@ class ApiControllerTest < ActionController::TestCase end def test_permissions_basic_auth - basic_authorization(create(:user).email, "test") + basic_authorization create(:user).email, "test" get :permissions assert_response :success assert_select "osm > permissions", :count => 1 do