mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 12:23:33 +00:00
fix(#168): ensure trmnlp_id is unset during plugin duplication to prevent unique constraint violation
Some checks failed
tests / ci (push) Has been cancelled
Some checks failed
tests / ci (push) Has been cancelled
This commit is contained in:
parent
a095268c30
commit
ffd1cf0d7e
2 changed files with 21 additions and 1 deletions
|
|
@ -821,6 +821,26 @@ test('plugin duplicate copies all attributes except id and uuid', function (): v
|
|||
->and($duplicate->render_markup_view)->toBeNull();
|
||||
});
|
||||
|
||||
test('plugin duplicate sets trmnlp_id to null to avoid unique constraint violation', function (): void {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$original = Plugin::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'name' => 'Plugin with trmnlp_id',
|
||||
'trmnlp_id' => 'test-trmnlp-id-123',
|
||||
]);
|
||||
|
||||
$duplicate = $original->duplicate();
|
||||
|
||||
// Refresh to ensure casts are applied
|
||||
$original->refresh();
|
||||
$duplicate->refresh();
|
||||
|
||||
expect($duplicate->trmnlp_id)->toBeNull()
|
||||
->and($original->trmnlp_id)->toBe('test-trmnlp-id-123')
|
||||
->and($duplicate->name)->toBe('Plugin with trmnlp_id (Copy)');
|
||||
});
|
||||
|
||||
test('plugin duplicate copies render_markup_view file content to render_markup', function (): void {
|
||||
$user = User::factory()->create();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue