Commit 5384d9a 1 parent 4fc5380 commit 5384d9a Copy full SHA for 5384d9a
File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
require "sprockets/manifest"
4
+ require "active_support/core_ext/module/attribute_accessors"
4
5
5
6
module NonStupidDigestAssets
6
7
mattr_accessor :whitelist
@@ -18,7 +19,7 @@ def assets(assets)
18
19
def whitelisted_assets ( assets )
19
20
assets . select do |logical_path , _digest_path |
20
21
whitelist . any? do |item |
21
- item == logical_path
22
+ item =~ logical_path
22
23
end
23
24
end
24
25
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "non_stupid_digest_assets"
5
+
6
+ RSpec . describe NonStupidDigestAssets do
7
+ describe ".assets" do
8
+ context "when the whitelist is empty" do
9
+ it "returns the assets" do
10
+ NonStupidDigestAssets . whitelist = [ ]
11
+ assets = { "foo.js" => "foo-123.js" }
12
+ expect ( NonStupidDigestAssets . assets ( assets ) ) . to eq ( assets )
13
+ end
14
+ end
15
+
16
+ context "when the whitelist is not empty" do
17
+ it "returns the assets that match the whitelist" do
18
+ NonStupidDigestAssets . whitelist = [ /foo/ ]
19
+ assets = { "foo.js" => "foo-123.js" , "bar.js" => "bar-123.js" }
20
+ expect ( NonStupidDigestAssets . assets ( assets ) ) . to eq ( "foo.js" => "foo-123.js" )
21
+ end
22
+ end
23
+ end
24
+ end
You can’t perform that action at this time.
0 commit comments