Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#2739

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 [PATCH] Fix zero length stylesheet cache files bug in case of missing CSS files but benefits the above two test cases as well.

Reported by Christos Zisopoulos · May 29th, 2009 @ 04:49 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none