Skip to content

Commit

Permalink
cache busting that actually works
Browse files Browse the repository at this point in the history
  • Loading branch information
joshski committed Feb 2, 2011
1 parent 616dc5d commit 6715f6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/lackie/cache_buster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Lackie
class CacheBuster
def self.unique_string
@@unique_number ||= 0
(@@unique_number += 1).to_s
"#{@@unique_number += 1}#{Time.now.to_i}"
end
end
end
7 changes: 6 additions & 1 deletion spec/lackie/cache_buster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@

module Lackie
describe CacheBuster do
it "returns unique strings" do
it "produces unique strings" do
(1..99).map { |i| CacheBuster.unique_string }.uniq.size.should == 99
end

it "produces strings that include the current time" do
Time.should_receive(:now).and_return("332211")
CacheBuster.unique_string.should =~ /332211/
end
end
end

0 comments on commit 6715f6f

Please sign in to comment.