Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Fix metaPath for root assets #9287

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to this PR. It's a new Pint thing but since it's one line I'll just let it slide. Avoids a whole PR just for one character. 🤫

}
}

Expand Down
Loading