BEGIN { $ENV{MOJO_ASSETPACK_NO_CACHE} = 1 }
use t::Helper;
use Mojo::Util 'spurt';

my $file;

{
  my $t = t::Helper->t({minify => 0});
  my @files;

  $file = File::Spec->catfile($t->app->static->paths->[0], 'css', 'no-cache.css');

  $t->app->asset('no-cache.css' => '/css/no-cache.css', '/css/b.css');

  spurt('body { color: #424242; }', $file);
  $t->get_ok('/test1');
  push @files, $t->tx->res->dom->at('link')->{href};
  $t->get_ok($files[-1])->status_is(200)->content_like(qr{\#424242});

  spurt('body { color: #606060; }', $file);
  $t->get_ok('/test1');
  push @files, $t->tx->res->dom->at('link')->{href};
  $t->get_ok($files[-1])->status_is(200)->content_like(qr{\#606060});
}

{
  my $t = t::Helper->t({minify => 1});
  my @files;

  $t->app->asset('no-cache.css' => '/css/no-cache.css', '/css/b.css');

  spurt('body { color: #242424; }', $file);
  $t->get_ok('/test1');
  push @files, $t->tx->res->dom->at('link')->{href};
  $t->get_ok($files[-1])->status_is(200)->content_like(qr{\#242424});

  spurt('body { color: #616161; }', $file);
  $t->get_ok('/test1');
  push @files, $t->tx->res->dom->at('link')->{href};
  $t->get_ok($files[-1])->status_is(200)->content_like(qr{\#616161});
}

END { unlink $file }

done_testing;

__DATA__
@@ test1.html.ep
%= asset 'no-cache.css'
