Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/bust cache custom assets #93

Merged
merged 2 commits into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/views/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{{-- Custom CSS --}}
@if(!empty(config('larecipe.ui.additional_css')))
@foreach(config('larecipe.ui.additional_css') as $css)
<link rel="stylesheet" type="text/css" href="{{ asset($css) }}">
<link rel="stylesheet" type="text/css" href="{{ asset($css) . '?id=' . \Illuminate\Support\Str::random(8) }}">
@endforeach
@endif
</head>
Expand All @@ -67,7 +67,7 @@
{{-- Custom JS --}}
@if(!empty(config('larecipe.ui.additional_js')))
@foreach(config('larecipe.ui.additional_js') as $js)
<script type="text/javascript" src="{{ asset($js) }}"></script>
<script type="text/javascript" src="{{ asset($js) . '?id=' . \Illuminate\Support\Str::random(8) }}"></script>
@endforeach
@endif

Expand Down
36 changes: 36 additions & 0 deletions tests/Feature/BustCustomAssetsCacheTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace BinaryTorch\LaRecipe\Tests\Feature;

use Illuminate\Support\Facades\Config;
use BinaryTorch\LaRecipe\Tests\TestCase;

class BustCustomAssetsCacheTest extends TestCase
{
/** @test */
public function custom_css_and_js_display_random_string_on_query_param()
{
// set the docs path and landing
Config::set('larecipe.docs.path', 'tests/views/docs');
Config::set('larecipe.docs.landing', 'foo');

// set auth to false
Config::set('larecipe.settings.auth', false);

$customCssFile = 'veryUniqueCssCustomFile.css';
$customJsFile = 'veryUniqueJsCustomFile.js';

Config::set('larecipe.ui.additional_css', [ "/js/{$customCssFile}" ]);
Config::set('larecipe.ui.additional_js', [ "/js/{$customJsFile}" ]);

// guest can view foo page
$this->get('/docs/1.0')
->assertStatus(200)
->assertSee("/js/{$customCssFile}?id=")
->assertSee("/js/{$customJsFile}?id=");

}



}