Skip to content

Commit

Permalink
Merge branch 'release/6.0.20'
Browse files Browse the repository at this point in the history
* release/6.0.20:
  compiled assets
  refactoring more tests
  Apply fixes from StyleCI (#931)
  refactoring tests
  Apply fixes from StyleCI (#929)
  added selects to generalized index queries
  compile assets
  removes cross-env dependency
  • Loading branch information
austintoddj committed Feb 3, 2021
2 parents be725c9 + bbdf37c commit 496a56f
Show file tree
Hide file tree
Showing 15 changed files with 865 additions and 16,929 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"chart.js": "^2.9.4",
"cross-env": "^7.0.3",
"filepond": "^4.25.1",
"filepond-plugin-file-validate-size": "^2.2.1",
"filepond-plugin-file-validate-type": "^1.2.5",
Expand Down
10,666 changes: 3 additions & 10,663 deletions public/css/app.css

Large diffs are not rendered by default.

5,316 changes: 3 additions & 5,313 deletions public/js/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/

/*!
* FilePondPluginImagePreview 4.6.4
* FilePondPluginImagePreview 4.6.5
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
Expand Down Expand Up @@ -128,8 +128,8 @@
*/

/*!
* vuex v3.6.0
* (c) 2020 Evan You
* vuex v3.6.2
* (c) 2021 Evan You
* @license MIT
*/

Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=ed1f451bc0f344db4fe9",
"/css/app.css": "/css/app.css?id=264092bcb8f58a16e702"
"/js/app.js": "/js/app.js?id=520b5900e4af085892ba",
"/css/app.css": "/css/app.css?id=a49a08395034a6be9488"
}
2 changes: 1 addition & 1 deletion src/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class SearchController extends Controller
public function showPosts(): JsonResponse
{
$posts = Post::query()
->select('id', 'title')
->when(request()->user('canvas')->isContributor, function (Builder $query) {
return $query->where('user_id', request()->user('canvas')->id);
}, function (Builder $query) {
return $query;
})
->select('id', 'title')
->latest()
->get();

Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function index(): JsonResponse
{
return response()->json(
Tag::query()
->select('id', 'name', 'created_at')
->latest()
->withCount('posts')
->paginate(), 200
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/TopicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function index(): JsonResponse
{
return response()->json(
Topic::query()
->select('id', 'name', 'created_at')
->latest()
->withCount('posts')
->paginate(), 200
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function index(): JsonResponse
{
return response()->json(
User::query()
->select('id', 'name', 'email', 'avatar', 'role')
->latest()
->withCount('posts')
->paginate(), 200
Expand Down
128 changes: 55 additions & 73 deletions tests/Http/Controllers/TagControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Canvas\Models\Post;
use Canvas\Models\Tag;
use Canvas\Models\User;
use Canvas\Models\View;
use Canvas\Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Pagination\LengthAwarePaginator;
use Ramsey\Uuid\Uuid;

/**
Expand All @@ -20,55 +20,42 @@ class TagControllerTest extends TestCase
{
use RefreshDatabase;

public function testAnAdminCanFetchAllTags(): void
public function testListAllTags(): void
{
$tag = factory(Tag::class)->create([
'user_id' => factory(User::class)->create([
'role' => User::ADMIN,
]),
]);
factory(Tag::class, 2)->create();

factory(Tag::class, 4)->create();
$response = $this->actingAs($this->admin, 'canvas')
->getJson('canvas/api/tags')
->assertSuccessful();

$this->actingAs($this->admin, 'canvas')
->getJson('canvas/api/tags')
->assertSuccessful()
->assertJsonFragment([
'id' => $tag->id,
'name' => $tag->name,
'user_id' => $tag->user->id,
'slug' => $tag->slug,
'posts_count' => (string) $tag->posts->count(),
'total' => 5,
]);
$this->assertInstanceOf(Tag::class, $response->getOriginalContent()->first());

$this->assertInstanceOf(LengthAwarePaginator::class, $response->getOriginalContent());

$this->assertCount(2, $response->getOriginalContent());
}

public function testNewPostData(): void
public function testCreateDataForTag(): void
{
$this->actingAs($this->admin, 'canvas')
->getJson('canvas/api/tags/create')
->assertSuccessful()
->assertJsonStructure([
'id',
]);
$response = $this->actingAs($this->admin, 'canvas')
->getJson('canvas/api/tags/create')
->assertSuccessful();

$this->assertInstanceOf(Tag::class, $response->getOriginalContent());
}

public function testExistingPostData(): void
public function testExistingTagData(): void
{
$tag = factory(Tag::class)->create();

$this->actingAs($this->admin, 'canvas')
->getJson("canvas/api/tags/{$tag->id}")
->assertSuccessful()
->assertJsonFragment([
'id' => $tag->id,
'name' => $tag->name,
'user_id' => $tag->user->id,
'slug' => $tag->slug,
]);
$response = $this->actingAs($this->admin, 'canvas')
->getJson("canvas/api/tags/{$tag->id}")
->assertSuccessful();

$this->assertTrue($tag->is($response->getOriginalContent()));
}

public function testPostsCanBeFetchedForATag(): void
public function testListPostsForTag(): void
{
$tag = factory(Tag::class)->create();
$post = factory(Post::class)->create();
Expand All @@ -79,14 +66,15 @@ public function testPostsCanBeFetchedForATag(): void

$tag->posts()->sync([$post->id]);

$this->actingAs($this->admin, 'canvas')
->getJson("canvas/api/tags/{$tag->id}/posts")
->assertSuccessful()
->assertJsonFragment([
'tag_id' => $tag->id,
'post_id' => $post->id,
'views_count' => (string) $post->views->count(),
]);
$response = $this->actingAs($this->admin, 'canvas')
->getJson("canvas/api/tags/{$tag->id}/posts")
->assertSuccessful();

$this->assertInstanceOf(Post::class, $response->getOriginalContent()->first());

$this->assertInstanceOf(LengthAwarePaginator::class, $response->getOriginalContent());

$this->assertCount(1, $response->getOriginalContent());
}

public function testTagNotFound(): void
Expand All @@ -104,18 +92,16 @@ public function testStoreNewTag(): void
'slug' => 'a-new-tag',
];

$this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$data['id']}", $data)
->assertSuccessful()
->assertJsonFragment([
'id' => $data['id'],
'name' => $data['name'],
'slug' => $data['slug'],
'user_id' => $this->admin->id,
]);
$response = $this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$data['id']}", $data)
->assertSuccessful();

$this->assertInstanceOf(Tag::class, $response->getOriginalContent()->first());

$this->assertSame($data['id'], $response->getOriginalContent()->id);
}

public function testADeletedTagCanBeRefreshed(): void
public function testDeletedTagsCanBeRefreshed(): void
{
$deletedTag = factory(Tag::class)->create([
'id' => Uuid::uuid4()->toString(),
Expand All @@ -131,15 +117,13 @@ public function testADeletedTagCanBeRefreshed(): void
'slug' => $deletedTag->slug,
];

$this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$data['id']}", $data)
->assertSuccessful()
->assertJsonFragment([
'id' => $deletedTag->id,
'name' => $deletedTag->name,
'slug' => $deletedTag->slug,
'user_id' => $deletedTag->user_id,
]);
$response = $this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$data['id']}", $data)
->assertSuccessful();

$this->assertInstanceOf(Tag::class, $response->getOriginalContent()->first());

$this->assertSame($deletedTag['id'], $response->getOriginalContent()->id);
}

public function testUpdateExistingTag(): void
Expand All @@ -151,15 +135,13 @@ public function testUpdateExistingTag(): void
'slug' => 'an-updated-tag',
];

$this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$tag->id}", $data)
->assertSuccessful()
->assertJsonFragment([
'id' => $tag->id,
'name' => $data['name'],
'slug' => $data['slug'],
'user_id' => $tag->user->id,
]);
$response = $this->actingAs($this->admin, 'canvas')
->postJson("canvas/api/tags/{$tag->id}", $data)
->assertSuccessful();

$this->assertInstanceOf(Tag::class, $response->getOriginalContent()->first());

$this->assertSame($data['slug'], $response->getOriginalContent()->slug);
}

public function testInvalidSlugsAreValidated(): void
Expand Down
Loading

0 comments on commit 496a56f

Please sign in to comment.