This project is archived and is in readonly mode.

#2739 ✓resolved
Christos Zisopoulos

[PATCH] Fix (and strengthen) a couple of cache related stylesheet_link_tag test cases

Reported by Christos Zisopoulos | May 29th, 2009 @ 04:49 PM | in 2.x

The following code which is part of test_caching_stylesheet_link_tag_when_caching_on and test_caching_stylesheet_link_tag_when_caching_on_with_proc_asset_host does nothing more than check that the mtime of all.css is the same as the mtime of all.css because the directory wildcard used actually includes all.css

expected = 
  Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/*.css"].map { |p| File.mtime(p) }.max
assert_equal expected, 
  File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))

The wildcard should be changed to exclude all.css thus

expected = 
  Dir["#{ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR}/[^all]*.css"].map {|p| File.mtime(p) }.max
assert_equal expected, 
  File.mtime(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))

I've also added a bit more to the test case to ensure that the size of all.css is the size of all the stylesheets to be joined plus the two new lines per file minus two, as added by the .join("\n\n")

bytes_added_by_join = "\n\n".size * files_to_be_joined.size - "\n\n".size
expected_size = files_to_be_joined.sum { |p| File.size(p) } + bytes_added_by_join
assert_equal expected_size, File.size(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css'))

This second improvement is really only necessary for the test case added by my related patch #2738 but benefits the above two test cases as well.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages