]> git.openstreetmap.org Git - rails.git/commitdiff
Adding timecop as a gem dependency when in development env. This allows for time...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Sat, 3 Apr 2010 21:02:20 +0000 (21:02 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Sat, 3 Apr 2010 21:02:20 +0000 (21:02 +0000)
config/environment.rb
test/functional/api_controller_test.rb

index 539af83b2971842a09296fe6456493c4c79e3571..724ceebbb85f241695c2d63d3d4c9b5a5761eba0 100644 (file)
@@ -54,6 +54,9 @@ Rails::Initializer.run do |config|
   config.gem 'httpclient'
   config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
   config.gem 'sanitize'
   config.gem 'httpclient'
   config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
   config.gem 'sanitize'
+  if Rails.env == "development"
+    config.gem 'timecop'
+  end
 
   # Only load the plugins named here, in the order given. By default, all plugins
   # in vendor/plugins are loaded in alphabetical order.
 
   # Only load the plugins named here, in the order given. By default, all plugins
   # in vendor/plugins are loaded in alphabetical order.
index ce4020ca7de92349fb72a5a1904bede5f0da39cd..e1543726f74bb64c4674f7e0e7bcb16e459f2e5e 100644 (file)
@@ -199,17 +199,18 @@ 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
   # http://wiki.openstreetmap.org/wiki/Rails#Installing_the_quadtile_functions
   # or by looking at the readme in db/README
   def test_changes_simple
+    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 
     get :changes
     assert_response :success
     #print @response.body
     # As we have loaded the fixtures, we can assume that there are no 
-    # changes recently
+    # changes at the time we have frozen at
     now = Time.now.getutc
     hourago = now - 1.hour
     now = Time.now.getutc
     hourago = now - 1.hour
-    # Note that this may fail on a very slow machine, so isn't a great test
     assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']:root", :count => 1 do
       assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1
     end
     assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']:root", :count => 1 do
       assert_select "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1
     end
+    Timecop.return
   end
   
   def test_changes_zoom_invalid
   end
   
   def test_changes_zoom_invalid