Skip to content
Browse files

Adding tests and fixing issues where applications in sub directories …

…would not get assets correctly linked.
  • Loading branch information...
1 parent b046393 commit 5ecea66c7893dc089eee6f60454d0025ff6124b3 @markstory markstory committed
Showing with 22 additions and 2 deletions.
  1. +18 −1 tests/cases/helpers/asset_compress.test.php
  2. +4 −1 views/helpers/asset_compress.php
View
19 tests/cases/helpers/asset_compress.test.php
@@ -12,7 +12,24 @@ class AssetCompressHelperTestCase extends CakeTestCase {
function startTest() {
$this->Helper = new AssetCompressHelper();
$this->Helper->Html = new HtmlHelper();
- $this->Helper->Javascript = new JavascriptHelper();
+ Router::reload();
+ }
+
+/**
+ * test that assets only have one base path attached
+ *
+ * @return void
+ */
+ function testIncludeAssets() {
+ Router::setRequestInfo(array(
+ array('controller' => 'posts', 'action' => 'index', 'plugin' => null),
+ array('base' => '/some/dir', 'webroot' => '/some/dir/', 'here' => '/some/dir/posts')
+ ));
+ $this->Helper->Html->webroot = '/some/dir/';
+
+ $this->Helper->script('one.js');
+ $result = $this->Helper->includeAssets();
+ $this->assertPattern('#"/some/dir/asset_compress#', $result, 'double dir set %s');
}
/**
* end a test
View
5 views/helpers/asset_compress.php
@@ -143,7 +143,10 @@ private function _generateFiles($type, $urlKey, $extension, $inline) {
$fileString = 'file[]=' . implode('&file[]=', $files);
$destination .= $extension;
- $url = Router::url(array_merge($this->options[$urlKey], array($destination, '?' => $fileString)));
+ $url = Router::url(array_merge(
+ $this->options[$urlKey],
+ array($destination, '?' => $fileString, 'base' => false)
+ ));
list($base, $query) = explode('?', $url);
if (file_exists(WWW_ROOT . $base)) {

0 comments on commit 5ecea66

Please sign in to comment.
Something went wrong with that request. Please try again.