Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using Time.parse on the yaml timestamps from issues to ensure correct…

… parsing against time zones
  • Loading branch information...
commit ad96bb21aea6c17aa6572a3aaaf0efeeef8532bb 1 parent b5166fc
@drnic drnic authored
View
5 lib/commands/helpers.rb
@@ -413,11 +413,10 @@
helper :distance_of_time do |from_time, to_time|
# this is a dumbed-down version of actionpack's helper.
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
+ from_time = Time.parse(from_time) if from_time.is_a?(String)
+ to_time = Time.parse(to_time) if to_time.is_a?(String)
distance_in_minutes = (((to_time - from_time).abs)/60).round
-
words = case distance_in_minutes
when 0 then "less than 1 minute"
when 2..44 then "%d minutes" % distance_in_minutes
View
27 spec/commands/command_issues_spec.rb
@@ -27,8 +27,8 @@
stdout.should == <<-EOS.gsub(/^ /, '')
-----
Issue #1 (0 votes): members.json 500 error
- * Opened about 19 hours ago by kdmny
- * Last updated about 18 hours ago
+ * Opened about 10 hours ago by bug_finder
+ * Last updated 5 minutes ago
I have a nasty bug.
-----
@@ -43,9 +43,9 @@
stdout.should == <<-EOS.gsub(/^ /, '')
-----
Issue #1 (0 votes): members.json 500 error
- * Opened about 19 hours ago by kdmny
- * Closed about 18 hours ago
- * Last updated about 18 hours ago
+ * Opened about 10 hours ago by bug_finder
+ * Closed 5 minutes ago
+ * Last updated 5 minutes ago
I have a nasty bug.
-----
@@ -68,24 +68,29 @@
end
class CommandHelper::Runner
- def mock_issues_for(state = "open", user = "user", project = "project")
+ def mock_issues_for(state = "open", options = {})
+ options[:updated_at] = 5.minutes.ago
+ options[:closed_at] = 5.minutes.ago
+ options[:created_at] = 10.hours.ago
+ options[:user] = "user"
+ options[:project] = "project"
yaml = <<-YAML.gsub(/^ /, '')
---
issues:
- number: 1
votes: 0
- created_at: 2009-11-04 20:25:02 -08:00
+ created_at: #{options[:created_at].strftime("%Y-%m-%d %H:%M:%S %z")}
body: |-
I have a nasty bug.
title: members.json 500 error
- updated_at: 2009-11-04 21:26:39 -08:00
- #{"closed_at: 2009-11-04 21:25:17 -08:00" if state == "closed"}
- user: kdmny
+ updated_at: #{options[:updated_at].strftime("%Y-%m-%d %H:%M:%S %z")}
+ #{"closed_at: #{options[:closed_at].strftime("%Y-%m-%d %H:%M:%S %z")}" if state == "closed"}
+ user: bug_finder
labels: []
state: #{state}
YAML
- api_url = "http://github.com/api/v2/yaml/issues/list/#{user}/#{project}/#{state}"
+ api_url = "http://github.com/api/v2/yaml/issues/list/#{options[:user]}/#{options[:project]}/#{state}"
@command.should_receive(:open).with(api_url).and_return(yaml)
end
end
View
1  spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec'
+require 'activerecord'
require File.dirname(__FILE__) + '/../lib/github'
Please sign in to comment.
Something went wrong with that request. Please try again.