Skip to content

Commit

Permalink
Version 0.6.1 (exported from SVN)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisparrish committed Oct 18, 2008
1 parent 362ae0f commit 95065bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
4 changes: 4 additions & 0 deletions 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
Expand Down
4 changes: 2 additions & 2 deletions lib/site_controller_mixins.rb
Expand Up @@ -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
Expand Down
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion spec/models/text_asset_response_cache_spec.rb
Expand Up @@ -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
Expand All @@ -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'))
Expand Down

0 comments on commit 95065bf

Please sign in to comment.