Skip to content

Commit

Permalink
Merge pull request #82 from art-institute-of-chicago/feature/rename-d…
Browse files Browse the repository at this point in the history
…igpubs-sections

Rename Digital Publication "Sections" to "Articles" [API-409]
  • Loading branch information
nikhiltri authored Jun 6, 2024
2 parents ed657cf + 75ee476 commit c0a6a98
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 64 deletions.
6 changes: 3 additions & 3 deletions app/Console/Commands/Import/ImportWebFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use App\Models\Web\PressRelease;
use App\Models\Web\EducatorResource;
use App\Models\Web\DigitalCatalog;
use App\Models\Web\DigitalPublicationSection;
use App\Models\Web\DigitalPublicationArticle;
use App\Models\Web\PrintedCatalog;
use App\Models\Web\StaticPage;

Expand Down Expand Up @@ -68,7 +68,7 @@ protected function reset($endpoint = null)
PressRelease::class => 'press_releases',
EducatorResource::class => 'educator_resources',
DigitalCatalog::class => 'digital_catalogs',
DigitalPublicationSection::class => 'digital_publication_sections',
DigitalPublicationArticle::class => 'digital_publication_articles',
PrintedCatalog::class => 'printed_catalogs',
StaticPage::class => 'static_pages',
];
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function importEndpoints()
$this->importFromWeb('pressreleases');
$this->importFromWeb('educatorresources');
$this->importFromWeb('digitalpublications');
$this->importFromWeb('digitalpublicationsections');
$this->importFromWeb('digitalpublicationarticles');
$this->importFromWeb('printedpublications');

$this->importFromWeb('staticpages');
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ protected function schedule(Schedule $schedule): void
->withoutOverlapping(self::FOR_ONE_YEAR)
->sendOutputTo(storage_path('logs/import-web-full-digitalpublications-last-run.log'));

$schedule->command('import:web-full', ['digitalpublicationsections', '--yes'])
$schedule->command('import:web-full', ['digitalpublicationarticles', '--yes'])
->dailyAt('23:51')
->withoutOverlapping(self::FOR_ONE_YEAR)
->sendOutputTo(storage_path('logs/import-web-full-digitalpublicationsections-last-run.log'));
->sendOutputTo(storage_path('logs/import-web-full-digitalpublicationarticles-last-run.log'));

$schedule->command('import:web-full', ['printedpublications', '--yes'])
->dailyAt('23:54')
Expand Down
4 changes: 2 additions & 2 deletions app/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Models\Shop\Product;
use App\Models\Web\Article;
use App\Models\Web\DigitalCatalog;
use App\Models\Web\DigitalPublicationSection;
use App\Models\Web\DigitalPublicationArticle;
use App\Models\Web\EducatorResource;
use App\Models\Web\Event;
use App\Models\Web\EventOccurrence;
Expand Down Expand Up @@ -126,7 +126,7 @@ public static function addRestrictContentScopes($isDump = false)
{
Article::addGlobalScope(new PublishedScope());
DigitalCatalog::addGlobalScope(new PublishedScope());
DigitalPublicationSection::addGlobalScope(new PublishedScope());
DigitalPublicationArticle::addGlobalScope(new PublishedScope());
EducatorResource::addGlobalScope(new PublishedScope());
GenericPage::addGlobalScope(new PublishedScope());
PressRelease::addGlobalScope(new PublishedScope());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
/**
* A digital catalog on the website
*/
class DigitalPublicationSection extends WebModel
class DigitalPublicationArticle extends WebModel
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Transformers\Inbound\WebTransformer;

class DigitalPublicationSection extends WebTransformer
class DigitalPublicationArticle extends WebTransformer
{
use HasBlocks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@

use App\Transformers\Outbound\AbstractTransformer as BaseTransformer;

class DigitalPublicationSection extends BaseTransformer
class DigitalPublicationArticle extends BaseTransformer
{
protected function getFields()
{
return [
'web_url' => [
'doc' => 'The URL to this section on our website',
'doc' => 'The URL to this article on our website',
'type' => 'string',
'elasticsearch' => 'keyword',
],
'copy' => [
'doc' => 'The text of the section',
'doc' => 'The text of the article',
'type' => 'string',
'elasticsearch' => [
'default' => true,
],
],
'author_display' => [
'doc' => 'A display-friendly text of the authors of this section',
'doc' => 'A display-friendly text of the authors of this article',
'type' => 'string',
'elasticsearch' => 'text',
],
'digital_publication_id' => [
'doc' => 'Unique identifier of the digital publication this section belongs to',
'doc' => 'Unique identifier of the digital publication this article belongs to',
'type' => 'number',
'elasticsearch' => 'integer',
],
];

return array_merge(
$sharedFields,
$this->getPageFields()
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions config/resources/inbound.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@
'model' => \App\Models\Web\PrintedCatalog::class,
'transformer' => \App\Transformers\Inbound\Web\Page::class,
],
'digitalpublicationsections' => [
'model' => \App\Models\Web\DigitalPublicationSection::class,
'transformer' => \App\Transformers\Inbound\Web\DigitalPublicationSection::class,
'digitalpublicationarticles' => [
'model' => \App\Models\Web\DigitalPublicationArticle::class,
'transformer' => \App\Transformers\Inbound\Web\DigitalPublicationArticle::class,
],
],

Expand Down
6 changes: 3 additions & 3 deletions config/resources/outbound.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@
'is_searchable' => true,
],
[
'endpoint' => 'digital-publication-sections',
'model' => \App\Models\Web\DigitalPublicationSection::class,
'transformer' => \App\Transformers\Outbound\Web\DigitalPublicationSection::class,
'endpoint' => 'digital-publication-articles',
'model' => \App\Models\Web\DigitalPublicationArticle::class,
'transformer' => \App\Transformers\Outbound\Web\DigitalPublicationArticle::class,
'is_searchable' => true,
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use Illuminate\Database\Eloquent\Factories\Factory;

class DigitalPublicationSectionFactory extends Factory
class DigitalPublicationArticleFactory extends Factory
{
protected $model = \App\Models\Web\DigitalPublicationSection::class;
protected $model = \App\Models\Web\DigitalPublicationArticle::class;

public function definition(): array
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::rename('digital_publication_sections', 'digital_publication_articles');
}

public function down(): void
{
Schema::rename('digital_publication_articles', 'digital_publication_sections');
}
};
12 changes: 12 additions & 0 deletions tests/Basic/DigitalPublicationArticleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Tests\Basic;

use App\Models\Web\DigitalPublicationArticle;

class DigitalPublicationArticleTest extends BasicTestCase
{
protected $model = DigitalPublicationArticle::class;

protected $route = 'digital-publication-articles';
}
12 changes: 0 additions & 12 deletions tests/Basic/DigitalPublicationSectionTest.php

This file was deleted.

25 changes: 25 additions & 0 deletions tests/Unit/DigitalPublicationArticleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\Web\DigitalPublicationArticle;

class DigitalPublicationArticleTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function it_inserts_long_text_in_the_copy_field(): void
{
$digitalPublictionArticle = $this->make(DigitalPublicationArticle::class, ['copy' => fake()->text(66000)]); // Longer than a `text` field
$digitalPublictionArticleKey = $digitalPublictionArticle->getAttributeValue($digitalPublictionArticle->getKeyName());

$response = $this->getJson('api/v1/digital-publication-articles/' . $digitalPublictionArticleKey);
$response->assertSuccessful();

$resource = $response->json()['data'];
$this->assertGreaterThan(65535, strlen($resource['copy']));
}
}
25 changes: 0 additions & 25 deletions tests/Unit/DigitalPublicationSectionTest.php

This file was deleted.

0 comments on commit c0a6a98

Please sign in to comment.