Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 0.6.1 (exported from SVN)

  • Loading branch information...
commit 95065bf8b30ef5ac5cab8f8cd2407ba7dad71de0 1 parent 362ae0f
@chrisparrish chrisparrish authored
View
4 HISTORY
@@ -1,3 +1,7 @@
+v.06.1 Bug fix: Text Assets were rendering with no Status header. Apparently
+ LiteSpeed does not like this. Now yields 200 code.
+
+
v0.6 Change extension code to use "sns" instead of "styles_n_scripts" -- this
will impact users as they need to move the extension from:
/vendor/extensions/styles_n_scripts
View
4 lib/site_controller_mixins.rb
@@ -58,10 +58,10 @@ def show_uncached_text_asset(filename, asset_type, cache_url)
mime_type = Sns::Config["#{asset_type}_mime_type"]
unless @text_asset.nil?
+ response.body = @text_asset.render
+ response.headers['Status'] = ActionController::Base::DEFAULT_RENDER_STATUS_CODE
response.headers['Content-Type'] = mime_type
response.headers['Last-Modified'] = @text_asset.effectively_updated_at.httpdate
- response.body = @text_asset.render
- # for text_assets, we cache no matter what (no 'status' setting for them)
text_asset_cache.cache_response(cache_url, response) if request.get?
@performed_render = true
end
View
14 ...ollers/site_controller_extensions_spec.rb → ...ontrollers/site_controller_mixins_spec.rb
@@ -18,7 +18,7 @@
Sns::Config.restore_defaults
# don't bork results with stale cache items
-# controller.text_asset_cache.clear
+ controller.text_asset_cache.clear
end
@@ -81,9 +81,7 @@
it "should render the content for existing #{current_asset[:name].pluralize}" do
get :show_page,
:url => current_asset[:default_directory].split("/") << "main"
-# For SOME reason, the response.header does not include a 'status' key so it is
-# not possible to check for success.
-# response.should be_success
+ response.should be_success
response.body.should == "Main #{current_asset[:name]} content"
end
@@ -92,9 +90,7 @@
request.host = "dev.site.com"
get :show_page,
:url => current_asset[:default_directory].split("/") << "main"
-# For SOME reason, the response.header does not include a 'status' key so it is
-# not possible to check for success.
-# response.should be_success
+ response.should be_success
response.body.should == "Main #{current_asset[:name]} content"
end
@@ -170,9 +166,7 @@
send("create_#{current_asset[:name]}", 'abc.123')
get :show_page,
:url => current_asset[:default_directory].split("/") << 'abc.123'
-# For SOME reason, the response.header does not include a 'status' key so it is
-# not possible to check for success.
-# response.should be_success
+ response.should be_success
response.body.should == "#{current_asset[:name]} content for abc.123"
end
View
12 spec/models/text_asset_response_cache_spec.rb
@@ -74,7 +74,7 @@ def initialize(body = '', headers = {})
end
-# These two specs are stolen directly from the response_cache_spec. Mostly these
+# These three specs are stolen directly from the response_cache_spec. Mostly these
# are redundant tests but I at least wanted to ensure that it actually caches
['test/me', '/test/me', 'test/me/', '/test/me/', 'test//me'].each do |url|
it "should cache response for url: #{url.inspect}" do
@@ -90,6 +90,16 @@ def initialize(body = '', headers = {})
end
end
+ it 'should send 304 response if cached Last-Modified date is older than If-Modified-Since date' do
+ last_modified = Time.now.httpdate
+ result = @cache.cache_response('test', response('content', 'Last-Modified' => last_modified))
+ request = ActionController::TestRequest.new
+ request.env = { 'HTTP_IF_MODIFIED_SINCE' => last_modified }
+ second_call = @cache.update_response('test', response, request)
+ second_call.headers['Status'].should match(/^304/)
+ second_call.body.should == ''
+ result.should be_kind_of(TestResponse)
+ end
it 'cache response with extension' do
@cache.cache_response("styles.css", response('content'))
Please sign in to comment.
Something went wrong with that request. Please try again.