Skip to content

Commit

Permalink
[4.x] Fix metaPath for root assets (#9287)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Jan 9, 2024
1 parent b4b531f commit 081b6a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function metaPath()
{
$path = dirname($this->path()).'/.meta/'.$this->basename().'.yaml';

return ltrim($path, '/');
return (string) Str::of($path)->replaceFirst('./', '')->ltrim('/');
}

protected function metaExists()
Expand Down
10 changes: 10 additions & 0 deletions tests/Assets/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,16 @@ public function it_properly_merges_new_unsaved_data_to_meta()
$this->assertEquals($expectedAfterMerge, $asset->meta());
}

/** @test */
public function it_gets_meta_path()
{
$asset = (new Asset)->container($this->container)->path('test.txt');
$this->assertEquals('.meta/test.txt.yaml', $asset->metaPath());

$asset = (new Asset)->container($this->container)->path('foo/test.txt');
$this->assertEquals('foo/.meta/test.txt.yaml', $asset->metaPath());
}

/** @test */
public function it_generates_meta_on_demand_if_it_doesnt_exist()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function resolveApplicationConfiguration($app)
];

foreach ($configs as $config) {
$app['config']->set("statamic.$config", require(__DIR__."/../config/{$config}.php"));
$app['config']->set("statamic.$config", require (__DIR__."/../config/{$config}.php"));
}
}

Expand Down

0 comments on commit 081b6a4

Please sign in to comment.