Attribution: Übermittler aus users.agency_name statt Agentur-Firma
A3 des Umbaus Agentur-Attribution → User-Profil: Eager Loading der Detailseite/Vorschau lädt user:id,agency_name; die Legacy-Relation PressRelease::submittingAgency() (Pseudo-Firma type=agency via owner_user_id) entfällt. Tests decken Verteiler-Fall, Namensgleichheit und PM ohne Übermittler ab. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
a62a5eea6e
commit
85fddbfdf8
3 changed files with 71 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ class PressReleasePreviewController extends Controller
|
||||||
? PressRelease::withoutGlobalScopes()
|
? PressRelease::withoutGlobalScopes()
|
||||||
->with([
|
->with([
|
||||||
'company',
|
'company',
|
||||||
|
'user:id,agency_name',
|
||||||
'category.translations',
|
'category.translations',
|
||||||
'category.parent.translations',
|
'category.parent.translations',
|
||||||
'images' => fn ($query) => $query->orderByDesc('is_preview')->orderBy('sort_order'),
|
'images' => fn ($query) => $query->orderByDesc('is_preview')->orderBy('sort_order'),
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ class ReleaseDetailPageData
|
||||||
->where('slug', $slug)
|
->where('slug', $slug)
|
||||||
->with([
|
->with([
|
||||||
'company',
|
'company',
|
||||||
|
'user:id,agency_name',
|
||||||
'category.translations' => fn ($query) => $query->where('locale', $language),
|
'category.translations' => fn ($query) => $query->where('locale', $language),
|
||||||
'category.parent.translations' => fn ($query) => $query->where('locale', $language),
|
'category.parent.translations' => fn ($query) => $query->where('locale', $language),
|
||||||
'images' => fn ($query) => $query->orderByDesc('is_preview')->orderBy('sort_order'),
|
'images' => fn ($query) => $query->orderByDesc('is_preview')->orderBy('sort_order'),
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Enums\CompanyType;
|
||||||
use App\Enums\Portal;
|
use App\Enums\Portal;
|
||||||
use App\Enums\PressReleaseStatus;
|
use App\Enums\PressReleaseStatus;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\PressRelease;
|
use App\Models\PressRelease;
|
||||||
|
use App\Models\User;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -95,6 +97,73 @@ test('release detail shows prominent report links below the article', function (
|
||||||
->assertSee(route('legal-request.create', ['slug' => $release->slug, 'type' => 'dsgvo']), false);
|
->assertSee(route('legal-request.create', ['slug' => $release->slug, 'type' => 'dsgvo']), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('release detail attributes content submitted via a distribution agency', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
// Legacy-Konvention: PMs, die über einen Verteiler-Account eingeliefert
|
||||||
|
// wurden (z. B. connektar via API), tragen die Zeile „Original-Inhalt
|
||||||
|
// von {Firma} und übermittelt von {Übermittler}". Der Übermittler kommt
|
||||||
|
// aus dem Profilfeld agency_name des einliefernden Accounts.
|
||||||
|
[$category, $company] = detailCategoryAndCompany(Portal::Businessportal24);
|
||||||
|
|
||||||
|
$agencyUser = User::factory()->withAgency('connektar.de Presseverteiler')->create();
|
||||||
|
|
||||||
|
$release = PressRelease::factory()
|
||||||
|
->published()
|
||||||
|
->forPortal(Portal::Businessportal24)
|
||||||
|
->for($category)
|
||||||
|
->for($company)
|
||||||
|
->for($agencyUser, 'user')
|
||||||
|
->create(['slug' => 'api-eingelieferte-meldung', 'published_at' => now()->subDay()]);
|
||||||
|
|
||||||
|
$this->get('https://businessportal24.test/de/press-release/'.$release->slug)
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertSeeText('Original-Inhalt von Muster Energie GmbH und übermittelt von connektar.de Presseverteiler');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('release detail attribution collapses when agency and company share the same name', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
[$category] = detailCategoryAndCompany(Portal::Businessportal24);
|
||||||
|
|
||||||
|
$agencyUser = User::factory()->withAgency('PR-Werk GmbH')->create();
|
||||||
|
|
||||||
|
$sameNameCompany = Company::factory()->create([
|
||||||
|
'portal' => Portal::Businessportal24,
|
||||||
|
'type' => CompanyType::Company,
|
||||||
|
'name' => 'PR-Werk GmbH',
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$release = PressRelease::factory()
|
||||||
|
->published()
|
||||||
|
->forPortal(Portal::Businessportal24)
|
||||||
|
->for($category)
|
||||||
|
->for($sameNameCompany)
|
||||||
|
->for($agencyUser, 'user')
|
||||||
|
->create(['slug' => 'eigene-agentur-meldung', 'published_at' => now()->subDay()]);
|
||||||
|
|
||||||
|
$this->get('https://businessportal24.test/de/press-release/'.$release->slug)
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertSeeText('Inhalt übermittelt von PR-Werk GmbH')
|
||||||
|
->assertDontSeeText('Original-Inhalt von PR-Werk GmbH');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('release detail attributes the company itself without a distribution agency', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
[$category, $company] = detailCategoryAndCompany(Portal::Businessportal24);
|
||||||
|
|
||||||
|
$release = PressRelease::factory()
|
||||||
|
->published()
|
||||||
|
->forPortal(Portal::Businessportal24)
|
||||||
|
->for($category)
|
||||||
|
->for($company)
|
||||||
|
->create(['slug' => 'direkt-eingestellte-meldung', 'published_at' => now()->subDay()]);
|
||||||
|
|
||||||
|
$this->get('https://businessportal24.test/de/press-release/'.$release->slug)
|
||||||
|
->assertSuccessful()
|
||||||
|
->assertSeeText('Original-Inhalt von Muster Energie GmbH')
|
||||||
|
->assertDontSeeText('übermittelt von');
|
||||||
|
});
|
||||||
|
|
||||||
test('release detail counts a hit', function () {
|
test('release detail counts a hit', function () {
|
||||||
/** @var TestCase $this */
|
/** @var TestCase $this */
|
||||||
[$category, $company] = detailCategoryAndCompany(Portal::Businessportal24);
|
[$category, $company] = detailCategoryAndCompany(Portal::Businessportal24);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue