rely on template_version first for the timestamp of assets

did committed Sep 23, 2015
commit 31634658d52dc4e5fdb9c39137405084026956cd
Showing 3 changed files with 11 additions and 2 deletions
locomotive/steam/entities/site.rb b/lib/locomotive/steam/entities/site.rb +2 -1
@@ @@ -7,7 +7,8 @@ module Locomotive::Steam
def initialize(attributes = {})
super({
prefix_default_locale: false,
- updated_at: nil
+ updated_at: nil,
+ template_version: nil
}.merge(attributes))
end
locomotive/steam/services/asset_host_service.rb b/lib/locomotive/steam/services/asset_host_service.rb +1 -1
@@ @@ -14,7 +14,7 @@ module Locomotive
def compute(source, timestamp = nil)
return source if source.nil?
- timestamp ||= site.try(:updated_at).to_i
+ timestamp ||= site.try(:template_version).to_i || site.try(:updated_at).to_i
return add_timestamp_suffix(source, timestamp) if source =~ Steam::IsHTTP
spec/unit/services/asset_host_service_spec.rb +8 -0
@@ @@ -29,6 +29,14 @@ describe Locomotive::Steam::AssetHostService do
end
+ context 'the timestamp coming from the site' do
+
+ let(:timestamp) { nil }
+ let(:site) { instance_double('ModifiedSite', template_version: DateTime.parse('2007/06/29 00:00:00'), updated_at: DateTime.parse('2009/09/10 00:00:00')) }
+ it { is_expected.to eq '/sites/42/assets/1/banner.png?1183075200' }
+
+ end
+
end
describe 'the source is already a full url' do