Replace timecop with the rails builtin travel_to method
This commit is contained in:
parent
3ab39f48ba
commit
28bfaa9fb6
3 changed files with 22 additions and 25 deletions
1
Gemfile
1
Gemfile
|
@ -113,7 +113,6 @@ group :test do
|
||||||
gem "minitest", "~> 5.1", :platforms => [:ruby_19, :ruby_20]
|
gem "minitest", "~> 5.1", :platforms => [:ruby_19, :ruby_20]
|
||||||
gem "rails-controller-testing"
|
gem "rails-controller-testing"
|
||||||
gem "rubocop"
|
gem "rubocop"
|
||||||
gem "timecop"
|
|
||||||
gem "webmock"
|
gem "webmock"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,6 @@ GEM
|
||||||
thor (0.19.4)
|
thor (0.19.4)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.7)
|
tilt (2.0.7)
|
||||||
timecop (0.9.0)
|
|
||||||
tins (1.14.0)
|
tins (1.14.0)
|
||||||
tzinfo (1.2.3)
|
tzinfo (1.2.3)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
|
@ -397,11 +396,10 @@ DEPENDENCIES
|
||||||
sanitize
|
sanitize
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
secure_headers
|
secure_headers
|
||||||
timecop
|
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
validates_email_format_of (>= 1.5.1)
|
validates_email_format_of (>= 1.5.1)
|
||||||
vendorer
|
vendorer
|
||||||
webmock
|
webmock
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.12.5
|
1.13.7
|
||||||
|
|
|
@ -304,32 +304,32 @@ class ApiControllerTest < ActionController::TestCase
|
||||||
# nodes with a different timestamp should be ignored
|
# nodes with a different timestamp should be ignored
|
||||||
create(:node, :timestamp => Time.utc(2008, 1, 1, 0, 0, 0), :lat => 7, :lon => 7)
|
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))
|
travel_to Time.utc(2010, 4, 3, 10, 55, 0) do
|
||||||
get :changes
|
get :changes
|
||||||
assert_response :success
|
assert_response :success
|
||||||
now = Time.now.getutc
|
now = Time.now.getutc
|
||||||
hourago = now - 1.hour
|
hourago = now - 1.hour
|
||||||
assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
|
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 "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do
|
||||||
assert_select "tile", :count => 0
|
assert_select "tile", :count => 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Timecop.return
|
|
||||||
|
|
||||||
Timecop.freeze(Time.utc(2007, 1, 1, 0, 30, 0))
|
travel_to Time.utc(2007, 1, 1, 0, 30, 0) do
|
||||||
get :changes
|
get :changes
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# print @response.body
|
# print @response.body
|
||||||
# As we have loaded the fixtures, we can assume that there are some
|
# As we have loaded the fixtures, we can assume that there are some
|
||||||
# changes at the time we have frozen at
|
# changes at the time we have frozen at
|
||||||
now = Time.now.getutc
|
now = Time.now.getutc
|
||||||
hourago = now - 1.hour
|
hourago = now - 1.hour
|
||||||
assert_select "osm[version='#{API_VERSION}'][generator='#{GENERATOR}']", :count => 1 do
|
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 "changes[starttime='#{hourago.xmlschema}'][endtime='#{now.xmlschema}']", :count => 1 do
|
||||||
assert_select "tile", :count => 6
|
assert_select "tile", :count => 6
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Timecop.return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_changes_zoom_invalid
|
def test_changes_zoom_invalid
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue