Skip to content

Commit

Permalink
Assets are distinct based on :path and :bundle
Browse files Browse the repository at this point in the history
Fixes #10
  • Loading branch information
magnars committed Dec 28, 2013
1 parent 699b8c5 commit 9642aaf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/optimus/strategies.clj
Expand Up @@ -19,11 +19,11 @@
asset-1)

(defn- guard-against-duplicate-assets [assets]
(let [path->assets (group-by :path assets)]
(let [pb->assets (group-by (juxt :path :bundle) assets)]
(->> assets
(map :path)
(map (juxt :path :bundle))
(distinct)
(map path->assets)
(map pb->assets)
(map #(reduce collapse-equal-assets %)))))

(defn serve-live-assets [app get-assets optimize options]
Expand Down
10 changes: 10 additions & 0 deletions test/optimus/strategies_test.clj
Expand Up @@ -88,6 +88,16 @@
(let [app (serve-frozen-assets return-request get-assets dont-optimize {})]
(app {}) => {:optimus-assets [{:path "/code.js" :contents "abc"}]}))

(fact
"Assets are allowed to be duplicated if they belong to different bundles."

(defn get-assets [] [{:path "/code.js" :contents "abc" :bundle "app1.js"}
{:path "/code.js" :contents "abc" :bundle "app2.js"}])

(let [app (serve-live-assets return-request get-assets dont-optimize {})]
(app {}) => {:optimus-assets [{:path "/code.js" :contents "abc" :bundle "app1.js"}
{:path "/code.js" :contents "abc" :bundle "app2.js"}]}))

(fact
"Duplicate assets that are not equal are not tolerated."

Expand Down

0 comments on commit 9642aaf

Please sign in to comment.