Skip to content

Commit 3e22b7c

Browse files
rafaelfrancaRafael Mendonça França
authored andcommitted
Merge pull request #127 from matthewd/helper_version
Version the gem's helpers; if they change, the cache must go Conflicts: sprockets-rails.gemspec
1 parent 3fbbfba commit 3e22b7c

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

lib/sprockets/rails.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'sprockets/rails/version'
12
if defined? Rails::Railtie
23
require 'sprockets/railtie'
34
end

lib/sprockets/rails/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Sprockets
2+
module Rails
3+
VERSION = "2.1.1"
4+
end
5+
end

lib/sprockets/railtie.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ def configure(&block)
6969

7070
# Configuration options that should invalidate
7171
# the Sprockets cache when changed.
72-
version_fragments = [
72+
app.assets.version = [
73+
app.assets.version,
7374
config.assets.version,
7475
config.action_controller.relative_url_root,
75-
config.action_controller.asset_host
76+
config.action_controller.asset_host,
77+
Sprockets::Rails::VERSION,
7678
].compact.join('-')
7779

78-
if version_fragments.present?
79-
app.assets.version += "-#{version_fragments}"
80-
end
81-
8280
# Copy config.assets.paths to Sprockets
8381
config.assets.paths.each do |path|
8482
app.assets.append_path path

sprockets-rails.gemspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
$:.unshift File.expand_path("../lib", __FILE__)
2+
require "sprockets/rails/version"
3+
14
Gem::Specification.new do |s|
25
s.name = "sprockets-rails"
3-
s.version = "2.1.1"
6+
s.version = Sprockets::Rails::VERSION
47

58
s.homepage = "https://github.com/rails/sprockets-rails"
69
s.summary = "Sprockets Rails integration"

test/test_railtie.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_defaults
5050
assert_kind_of Sprockets::Environment, env
5151

5252
assert_equal ROOT, env.root
53-
assert_equal "test", env.version
53+
assert_equal "test--#{Sprockets::Rails::VERSION}", env.version
5454
assert env.cache
5555
assert_equal [], env.paths
5656
assert_nil env.js_compressor
@@ -108,7 +108,7 @@ def test_version
108108
app.initialize!
109109

110110
assert env = app.assets
111-
assert_equal "test-v2", env.version
111+
assert_equal "test-v2-#{Sprockets::Rails::VERSION}", env.version
112112
end
113113

114114
def test_version_fragments
@@ -120,7 +120,7 @@ def test_version_fragments
120120
app.initialize!
121121

122122
assert env = app.assets
123-
assert_equal "test-v2-some-path-http://some-cdn.com", env.version
123+
assert_equal "test-v2-some-path-http://some-cdn.com-#{Sprockets::Rails::VERSION}", env.version
124124
end
125125

126126
def test_configure

0 commit comments

Comments
 (0)