Skip to content

Commit

Permalink
Merge pull request #267 from art-institute-of-chicago/fix/gallery-lat…
Browse files Browse the repository at this point in the history
…-longs

Get gallery lat-long info from API model [MA-156]
  • Loading branch information
nikhiltri authored Mar 5, 2024
2 parents 6c8831b + fa96413 commit 6c68b43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/Models/Transformers/GalleryTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function transform(TwillModelContract $gallery)
$gallery->id => [
'title' => $gallery->title,
'nid' => (string) $gallery->id, // Legacy from Drupal
'location' => $gallery->latlon,
'latitude' => $gallery->latitude,
'longitude' => $gallery->longitude,
'location' => $gallery->getApiModel()->latlon ?? $gallery->latlon,
'latitude' => $gallery->getApiModel()->latitude ?? $gallery->latitude,
'longitude' => $gallery->getApiModel()->longitude ?? $gallery->longitude,
'gallery_id' => (string) $gallery->id,
'tgn_id' => null,// Legacy from Drupal
'closed' => $gallery->is_closed,
'number' => $gallery->number,
'floor' => $gallery->floor,
'closed' => $gallery->getApiModel()->is_closed ?? $gallery->is_closed,
'number' => $gallery->getApiModel()->number ?? $gallery->number,
'floor' => $gallery->getApiModel()->floor ?? $gallery->floor,
'source_updated_at' => $gallery->source_updated_at,
'updated_at' => $gallery->updated_at,
]
Expand Down
11 changes: 11 additions & 0 deletions tests/Feature/GallerySerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
namespace Tests\Feature;

use App\Models\Gallery;
use App\Models\Api\Gallery as ApiGallery;
use App\Repositories\Serializers\GallerySerializer;
use Tests\TestCase;
use Tests\MockApi;

class GallerySerializerTest extends TestCase
{
use MockApi;

public function test_serialize(): void
{
$mockGalleryResponses = ApiGallery::factory()
->count(3)
->make()
->map(fn ($gallery) => $this->mockApiModelReponse($gallery));
$responses = collect($mockGalleryResponses)->toArray();
$this->addMockApiResponses($responses);

$serializer = new GallerySerializer();
$galleries = Gallery::factory()->count(3)->make();
$serialized = $serializer->serialize($galleries);
Expand Down

0 comments on commit 6c68b43

Please sign in to comment.