Skip to content

Commit

Permalink
Run tests in UTC, instead of the local time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
reidab committed Aug 30, 2013
1 parent 6a1444a commit 99916f8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 2 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

config.time_zone = 'UTC'
4 changes: 2 additions & 2 deletions spec/controllers/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,8 @@ def assert_delete(login=nil, &block)
calendar = Vpim::Icalendar.decode(response.body).first
component = calendar.find{|t| t.summary == item.title}
component.should_not be_nil
component.dtstart.should == item.start_time
component.dtend.should == item.end_time
component.dtstart.utc.should == item.start_time.utc
component.dtend.utc.should == item.end_time.utc
component.summary.should == item.title
component.description.should == (item.respond_to?(:users) ?
"#{item.users.map(&:fullname).join(', ')}: #{item.excerpt}" :
Expand Down
20 changes: 10 additions & 10 deletions spec/fixtures/proposals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ postgresql_session:
event_id: 2009
track: cooking
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 10:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 10:00am UTC').to_s(:db) %>
speaking_experience: "I know PostgreSQL stuff."
audience_level: a
title: "PostgreSQL Session"
Expand All @@ -118,7 +118,7 @@ drizzle_session:
event_id: 2009
track: cooking
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 10:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 10:00am UTC').to_s(:db) %>
speaking_experience: "I know Drizzle stuff."
audience_level: a
title: "Drizzle Session"
Expand All @@ -132,7 +132,7 @@ mysql_session:
event_id: 2009
track: cooking
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 11:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 11:00am UTC').to_s(:db) %>
speaking_experience: "I know MySQL stuff."
audience_level: a
title: "MySQL Session"
Expand All @@ -146,7 +146,7 @@ sqlite_session:
event_id: 2009
track: cooking
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 11:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 11:00am UTC').to_s(:db) %>
audience_level: a
title: "SQLite Session"
speaking_experience: "I know SQLite stuff."
Expand All @@ -160,7 +160,7 @@ rakudo_session:
event_id: 2009
track: cooking
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 12:00pm').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 12:00pm UTC').to_s(:db) %>
speaking_experience: "I AM A PONY!!1!"
audience_level: a
title: "Rakudo Session"
Expand All @@ -174,7 +174,7 @@ cloud_session:
event_id: 2009
track: hacks
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-18 12:00pm').to_s(:db) %>
start_time: <%= Time.parse('2009-06-18 12:00pm UTC').to_s(:db) %>
speaking_experience: "I know everything there is about stratocumulus clouds."
audience_level: a
title: "The Cloud is Falling!"
Expand All @@ -188,7 +188,7 @@ business_session:
event_id: 2009
track: hacks
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-18 12:00pm').to_s(:db) %>
start_time: <%= Time.parse('2009-06-18 12:00pm UTC').to_s(:db) %>
speaking_experience: "I own you."
audience_level: a
title: "Give us money."
Expand All @@ -202,7 +202,7 @@ sql_server_session:
event_id: 2009
track: business
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 10:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 10:00am UTC').to_s(:db) %>
speaking_experience: "Microsoft owns me."
audience_level: a
title: "SQL Server Session"
Expand All @@ -216,7 +216,7 @@ couchdb_session:
event_id: 2009
track: hacks
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 10:30am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 10:30am UTC').to_s(:db) %>
speaking_experience: "I write all my code using curl."
audience_level: a
title: "CouchDB Session"
Expand All @@ -230,7 +230,7 @@ bigtable_session:
event_id: 2009
track: hacks
submitted_at: <%= Time.now.to_s(:db) %>
start_time: <%= Time.zone.parse('2009-06-17 11:00am').to_s(:db) %>
start_time: <%= Time.parse('2009-06-17 11:00am UTC').to_s(:db) %>
speaking_experience: "My table is bigger than yours."
audience_level: a
title: "BigTable Session"
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/time_range_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@

describe "with objects" do
it "should format from objects that respond to just start_time" do
event = Proposal.new(:start_time => Time.parse('2008-04-01 13:30'))
event = Proposal.new(:start_time => Time.parse('2008-04-01 13:30 UTC'))
TimeRange.new(event, :format => :text).to_s.should == "Tuesday, April 1, 2008 at 1:30pm"
end

it "should format from objects that respond to both start_time and end_time" do
event = Proposal.new(:start_time => Time.parse('2008-04-01 13:30'),
event = Proposal.new(:start_time => Time.parse('2008-04-01 13:30 UTC'),
:session_type => stub_model(SessionType,:duration => 45))
TimeRange.new(event, :format => :text).to_s.should == "Tuesday, April 1, 2008 from 1:30 - 2:15pm"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@

describe "#dates" do
it "should return range between start_date and end_date" do
start_date = Date.today + 1.week
end_date = Date.today + 2.weeks
start_date = Time.now.utc.to_date + 1.week
end_date = Time.now.utc.to_date + 2.weeks
event = Event.new(:start_date => start_date, :end_date => end_date)

event.dates.should == (start_date..end_date).to_a
Expand Down
13 changes: 11 additions & 2 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,18 @@
describe "to_icalendar" do
def assert_calendar_match(item, component, url_helper=nil)
component.should_not be_nil
component.dtstart.to_i.should == item.start_time.to_i

# This is hacky, but necessary because vPim doesn't actually parse
# time zone information out of iCalendar files.
#
# The files are output with the correct time zone, but seem to be
# parsed in the computer's local time, regardless of the Rails
# time zone setting.
dtstart = Time.parse(component.dtstart.strftime('%Y-%m-%d %H:%M:%S UTC'))
dtstart.to_i.should == item.start_time.to_i
if item.duration
component.dtend.to_i.should == item.end_time.to_i
dtend = Time.parse(component.dtend.strftime('%Y-%m-%d %H:%M:%S UTC'))
dtend.to_i.should == item.end_time.to_i
else
component.dtend.should be_nil
end
Expand Down

0 comments on commit 99916f8

Please sign in to comment.