This project is archived and is in readonly mode.
[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
-
Christos Zisopoulos June 15th, 2009 @ 11:49 PM
The latest patch in #2738 includes changes from this patch, so feel free to close this ticket.
-
CancelProfileIsBroken June 16th, 2009 @ 12:16 AM
- State changed from new to resolved
Merged into #2738
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>
People watching this ticket
Attachments
Referenced by
- 2738 [PATCH] Fix zero length stylesheet cache files bug in case of missing CSS files As I had to rework a large chunk of the asset_tag_helper ...