Skip to content

Commit

Permalink
Fix paths not being expanded in filters.
Browse files Browse the repository at this point in the history
Expand paths before creating asset targets. This ensures that paths have
been expanded when filters get configured from the asset target.

Refs #21
  • Loading branch information
markstory committed Mar 13, 2016
1 parent 3e3e99a commit 7c05a78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function target($name)

$files = [];
$scanner = $this->scanner($paths);
$paths = $scanner->paths();

foreach ($this->config->files($name) as $file) {
if (preg_match('#^https?://#', $file)) {
$files[] = new Remote($file);
Expand Down
35 changes: 14 additions & 21 deletions tests/TestCase/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public function testAssetCollection()
$asset = $collection->get('libs.js');
$this->assertCount(2, $asset->files(), 'Not enough files');
$paths = [
APP . 'js',
APP . 'js/other_path',
APP . 'js/',
APP . 'js/other_path/',
];
$this->assertEquals($paths, $asset->paths(), 'Paths are incorrect');
$this->assertEquals(['Sprockets'], $asset->filterNames(), 'Filters are incorrect');
Expand Down Expand Up @@ -181,33 +181,26 @@ public function testAssetCollectionGlob()
$this->assertTrue($collection->contains('all_classes.js'));

$asset = $collection->get('all_classes.js');
$files = $asset->files();

$this->assertCount(6, $files, 'Not enough files');
$this->assertEquals(
APP . 'js/classes/base_class.js',
$files[0]->path()
[APP . 'js/', APP . 'js/classes/', APP . 'js/secondary/'],
$asset->paths(),
'Should have expanded paths'
);
$this->assertEquals(

$files = $asset->files();
$this->assertCount(6, $files, 'Not enough files');
$expectedPaths = [
APP . 'js/classes/base_class.js',
APP . 'js/classes/base_class_two.js',
$files[1]->path()
);
$this->assertEquals(
APP . 'js/classes/double_inclusion.js',
$files[2]->path()
);
$this->assertEquals(
APP . 'js/classes/nested_class.js',
$files[3]->path()
);
$this->assertEquals(
APP . 'js/classes/slideshow.js',
$files[4]->path()
);
$this->assertEquals(
APP . 'js/classes/template.js',
$files[5]->path()
);
];
foreach ($expectedPaths as $i => $expected) {
$this->assertEquals($expected, $files[$i]->path());
}
}

public function testWriter()
Expand Down

0 comments on commit 7c05a78

Please sign in to comment.