Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure duration_in_seconds has an integer value

  • Loading branch information...
commit 46d85e40f31e47aea6f48a1f3455d5b90d0a0c49 1 parent 951760b
@pvdb pvdb authored
View
2  lib/rack/contrib/static_cache.rb
@@ -87,7 +87,7 @@ def duration_in_words
end
def duration_in_seconds
- 60 * 60 * 24 * 365 * @cache_duration
+ (60 * 60 * 24 * 365 * @cache_duration).to_i
end
end
end
View
13 test/spec_rack_static_cache.rb
@@ -59,6 +59,14 @@ def call(env)
res.headers['Expires'].should =~ Regexp.new("#{next_next_year}")
end
+ it "should round max-age if duration is part of a year" do
+ one_week_duration_app_request
+ res = @request.get("/statics/test")
+ res.should.be.ok
+ res.body.should =~ /rubyrack/
+ res.headers['Cache-Control'].should == "max-age=606461, public"
+ end
+
it "should return 404s if requested with version number but versioning is disabled" do
configured_app_request
res = @request.get("/statics/test-0.0.1")
@@ -79,6 +87,11 @@ def default_app_request
request
end
+ def one_week_duration_app_request
+ @options = {:urls => ["/statics"], :root => @root, :duration => 1.fdiv(52)}
+ request
+ end
+
def configured_app_request
@options = {:urls => ["/statics", "/documents*"], :root => @root, :versioning => false, :duration => 2}
request
Please sign in to comment.
Something went wrong with that request. Please try again.