Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #477 from mildmojo/fix_download_test_465

Fixes download test for count/day over month boundary.
  • Loading branch information...
commit da5e69e8ade3fb66a744a9e9ac273b57e7862861 2 parents 14993b4 + cc95de5
Christopher Meiklejohn cmeiklejohn authored
Showing with 28 additions and 4 deletions.
  1. +28 −4 test/unit/download_test.rb
32 test/unit/download_test.rb
View
@@ -164,6 +164,30 @@ class DownloadTest < ActiveSupport::TestCase
assert_equal downloads, Download.counts_by_day_for_versions([@version_1, @version_2, @version_3], 2)
end
+ should "find counts per day for versions in range across month boundary" do
+ Timecop.freeze(Time.parse("2012-10-01")) do
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+
+ Timecop.freeze(1.day.ago) do
+ create :version_history, :version => @version_1, :count => 5
+ end
+
+ Download.incr(@rubygem_1, @version_1.full_name)
+
+ start = 2.days.ago.to_date
+ fin = Time.zone.today
+
+ downloads = ActiveSupport::OrderedHash.new.tap do |d|
+ d[start.to_s] = 0
+ d["#{Date.yesterday}"] = 5
+ d[fin.to_s] = 1
+ end
+
+ assert_equal downloads, Download.counts_by_day_for_version_in_date_range(@version_1, start, fin)
+ end
+ end
+
should "find counts per day for versions in range" do
@rubygem_1 = create(:rubygem)
@version_1 = create(:version, :rubygem => @rubygem_1)
@@ -174,13 +198,13 @@ class DownloadTest < ActiveSupport::TestCase
Download.incr(@rubygem_1, @version_1.full_name)
- start = 2.days.ago.to_date.to_s
- fin = Time.zone.today.to_s
+ start = 2.days.ago.to_date
+ fin = Time.zone.today
downloads = ActiveSupport::OrderedHash.new.tap do |d|
- d[start] = 0
+ d[start.to_s] = 0
d["#{Date.yesterday}"] = 5
- d[fin] = 1
+ d[fin.to_s] = 1
end
assert_equal downloads, Download.counts_by_day_for_version_in_date_range(@version_1, start, fin)
Please sign in to comment.
Something went wrong with that request. Please try again.