Permalink
Browse files

CLC-696 In test, instantiating starting_date as a Time object should …

…make the test pass even when the machine is in UTC
  • Loading branch information...
1 parent 0d88d47 commit 16459390708e5562227b5870fb6207ab3d421a3f Chris Tweney committed Dec 5, 2012
Showing with 5 additions and 5 deletions.
  1. +4 −4 app/models/my_tasks.rb
  2. +1 −1 spec/models/my_tasks_spec.rb
@@ -89,7 +89,7 @@ def fetch_canvas_tasks
due_date = result["start_at"]
convert_due_date(due_date, formatted_entry)
bucket = determine_bucket(due_date, "inprogress", formatted_entry)
- logger.info "#{self.class.name} Putting Canvas task in #{bucket} bucket: #{formatted_entry}"
+ logger.info "#{self.class.name} Putting Canvas task with epoch #{formatted_entry["due_date"]["epoch"]} in #{bucket} bucket: #{formatted_entry}"
@buckets[bucket]["tasks"].push(formatted_entry)
end
end
@@ -113,8 +113,8 @@ def determine_bucket(due_date, status, formatted_entry)
if !due_date.blank?
due = DateTime.parse(due_date.to_s)
today = @starting_date.to_time.to_i
- tomorrow = (@starting_date + 1).to_time.to_i
- day_after_tomorrow = (@starting_date + 2).to_time.to_i
+ tomorrow = (@starting_date.to_date + 1).to_time.to_i
+ day_after_tomorrow = (@starting_date.to_date + 2).to_time.to_i
if due.to_i < tomorrow
bucket = "due"
@@ -125,7 +125,7 @@ def determine_bucket(due_date, status, formatted_entry)
bucket = "upcoming"
end
- logger.info "In determine_bucket, today = #{today} tomorrow = #{tomorrow} day after tomorrow = #{day_after_tomorrow}; formatted entry = #{formatted_entry}"
+ logger.info "In determine_bucket, today = #{today}, today.zone = #{@starting_date.to_time.zone}, tomorrow = #{tomorrow} day after tomorrow = #{day_after_tomorrow}; formatted entry = #{formatted_entry}"
end
bucket
end
@@ -14,7 +14,7 @@
GoogleProxy.stub(:new).and_return(@fake_google_proxy)
CanvasProxy.stub(:new).and_return(@fake_canvas_proxy)
GoogleProxy.any_instance.stub(:events_list).and_return(@fake_google_tasks_array)
- my_tasks_model = MyTasks.new(@user_id, Date.civil(2012, 11, 27))
+ my_tasks_model = MyTasks.new(@user_id, Time.utc(2012, 11, 27, 8, 0))
valid_feed = my_tasks_model.get_feed
valid_feed["sections"].length.should == 4
valid_feed["sections"][0]["title"].should == "Due"

0 comments on commit 1645939

Please sign in to comment.