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

Make environment version affect asset digest #404

Merged
merged 1 commit into from
Oct 17, 2016
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md

## Next Release

- Changing the version now busts the digest of all assets [#404]

## 4.0.0.beta3

- Source Map fixes [#255] [#367]
Expand Down
2 changes: 1 addition & 1 deletion lib/sprockets/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def load_from_unloaded(unloaded)
source = result.delete(:data)
metadata = result
metadata[:charset] = source.encoding.name.downcase unless metadata.key?(:charset)
metadata[:digest] = digest(source)
metadata[:digest] = digest(self.version + source)
metadata[:length] = source.bytesize
else
dependencies << build_file_digest_uri(unloaded.filename)
Expand Down
4 changes: 2 additions & 2 deletions test/test_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,10 @@ def setup
assert_equal 2, asset.metadata[:selector_count]
end

test "changing version doesn't affect the assets digest" do
test "changing version changes the digest of the asset" do
old_asset_digest = @env["gallery.js"].hexdigest
@env.version = 'v2'
assert old_asset_digest == @env["gallery.js"].hexdigest
assert old_asset_digest != @env["gallery.js"].hexdigest
end

test "bundled asset is stale if its mtime is updated or deleted" do
Expand Down