CDB-4060 Replace Timecop with Delorean to avoid specs failing on different timezones

pull/751/head
Jose A. Rilla 10 years ago
parent ba3251744e
commit 4d2772861a

@ -97,7 +97,7 @@ group :development, :test do
gem 'rspec-rails', '2.10.1'
gem 'capybara', '1.1.2'
gem 'timecop', '0.6.3'
gem 'delorean'
gem 'rack', '1.4.1'
gem 'rack-reverse-proxy', '0.4.4', require: 'rack/reverse_proxy'
gem 'rack-test', '0.6.2', require: 'rack/test'

@ -63,6 +63,7 @@ GEM
charlock_holmes (0.6.9.4)
childprocess (0.5.1)
ffi (~> 1.0, >= 1.0.11)
chronic (0.10.2)
chunky_png (1.3.0)
ci_reporter (1.9.0)
builder (>= 2.1.2)
@ -84,6 +85,8 @@ GEM
debugger-ruby_core_source (~> 1.3.1)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.5)
delorean (2.1.0)
chronic
descendants_tracker (0.0.3)
diff-lcs (1.1.3)
dropbox-sdk (1.6.3)
@ -309,7 +312,6 @@ GEM
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.4.1)
timecop (0.6.3)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
@ -351,6 +353,7 @@ DEPENDENCIES
compass (= 0.12.3)
dbf (= 2.0.6)
debugger (= 1.6.5)
delorean
dropbox-sdk (= 1.6.3)
ejs (~> 1.1.1)
em-pg-client (= 0.2.1)
@ -403,7 +406,6 @@ DEPENDENCIES
statsd-client (= 0.0.7)
therubyracer (= 0.12.1)
thin
timecop (= 0.6.3)
typhoeus (= 0.6.7)
unicorn (= 4.8.2)
uuidtools (= 2.1.3)

@ -133,8 +133,9 @@ describe Layer do
it "should update updated_at after saving" do
layer = Layer.create(:kind => 'carto')
after = layer.updated_at
Timecop.travel Time.now + 1.minutes
Delorean.jump(1.minute)
after.should < layer.save.updated_at
Delorean.back_to_the_present
end
it "should correctly identify affected tables" do
@ -280,7 +281,7 @@ describe Layer do
describe '#uses_private_tables?' do
it 'returns true if any of the affected tables is private' do
CartoDB::NamedMapsWrapper::NamedMaps.any_instance.stubs(:create).returns(true)
map = Map.create(:user_id => @user.id, :table_id => @table.id)
source = @table.table_visualization
derived = CartoDB::Visualization::Copier.new(@user, source).copy

@ -191,7 +191,7 @@ describe User do
organization.destroy
end
it 'should set default settings properly unless overriden', focus: true do
it 'should set default settings properly unless overriden' do
organization = create_organization_with_users
organization.users.reject(&:organization_owner?).each do |u|
u.max_layers.should == 6
@ -828,23 +828,24 @@ describe User do
it "should correctly identify last billing cycle" do
user = create_user :email => 'example@example.com', :username => 'example', :password => 'testingbilling'
Timecop.freeze(Date.parse("2013-01-01")) do
Delorean.time_travel_to(Date.parse("2013-01-01")) do
user.stubs(:period_end_date).returns(Date.parse("2012-12-15"))
user.last_billing_cycle.should == Date.parse("2012-12-15")
end
Timecop.freeze(Date.parse("2013-01-01")) do
Delorean.time_travel_to(Date.parse("2013-01-01")) do
user.stubs(:period_end_date).returns(Date.parse("2012-12-02"))
user.last_billing_cycle.should == Date.parse("2012-12-02")
end
Timecop.freeze(Date.parse("2013-03-01")) do
Delorean.time_travel_to(Date.parse("2013-03-01")) do
user.stubs(:period_end_date).returns(Date.parse("2012-12-31"))
user.last_billing_cycle.should == Date.parse("2013-02-28")
end
Timecop.freeze(Date.parse("2013-03-15")) do
Delorean.time_travel_to(Date.parse("2013-03-15")) do
user.stubs(:period_end_date).returns(Date.parse("2012-12-02"))
user.last_billing_cycle.should == Date.parse("2013-03-02")
end
user.destroy
Delorean.back_to_the_present
end
it "should calculate the trial end date" do

@ -24,7 +24,7 @@ describe "Imports API" do
f = upload_file('db/fake_data/column_number_to_boolean.csv', 'text/csv')
post api_v1_imports_create_url(
params.merge(:filename => 'column_number_to_boolean.csv',
:table_name => "wadus")),
:table_name => "wadus")),
f.read.force_encoding('UTF-8')
@ -76,7 +76,7 @@ describe "Imports API" do
:table_name => "wadus")
end
Timecop.travel Time.now + 7.hours
Delorean.jump(7.hours)
get api_v1_imports_index_url, params
response.code.should be == '200'
@ -86,6 +86,7 @@ describe "Imports API" do
imports = response_json['imports']
imports.should have(0).items
Resque.inline = true
Delorean.back_to_the_present
end
it 'gets the detail of an import' do
@ -247,7 +248,7 @@ describe "Imports API" do
table.should have_no_invalid_the_geom
table.geometry_types.should_not be_blank
end
DataImport.count.should == import_files.size
Map.count.should == import_files.size
end

Loading…
Cancel
Save