Skip to content

Commit

Permalink
Merge pull request #93 from ijpatricio/feat/bust-cache-custom-assets
Browse files Browse the repository at this point in the history
Feat/bust cache custom assets
  • Loading branch information
Saleem Hadad authored Feb 16, 2019
2 parents b8fadaa + f77d7d5 commit 31382ad
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
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=");

}



}

0 comments on commit 31382ad

Please sign in to comment.