File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,18 @@ class FetchSectionScreenshotUrl
88 argument :section
99
1010 def call
11- fetch_section_screenshot_path . call ( section : section ) + "?#{ section . screenshot_timestamp } "
11+ screenshot_path = fetch_section_screenshot_path . call ( section : section ) + query_string
12+ asset_host ? URI . join ( asset_host , screenshot_path ) . to_s : screenshot_path
13+ end
14+
15+ private
16+
17+ def asset_host
18+ Rails . application . config . asset_host
19+ end
20+
21+ def query_string
22+ "?#{ section . screenshot_timestamp } "
1223 end
1324 end
1425end
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ def config
3030 c . uploader = :active_storage
3131 c . site_publishable = false
3232 c . preview_host = nil
33- c . asset_host = Rails . application . config . action_controller . asset_host
33+ c . asset_host = Rails . application . config . asset_host
3434 c . ui_locale = nil
3535 c . back_action = nil
3636 c . services = { }
Original file line number Diff line number Diff line change 1313 it 'returns the url to the screenshot of the section' do
1414 expect ( subject ) . to eq '/theme/jumbotron.png?42'
1515 end
16+
17+ context 'when there is a Rails asset host set' do
18+ before do
19+ allow ( Rails . application . config ) . to receive ( :asset_host ) . and_return ( 'https://assets.maglev.local' )
20+ end
21+
22+ it 'uses the Rails asset host to build the url' do
23+ expect ( subject ) . to eq 'https://assets.maglev.local/theme/jumbotron.png?42'
24+ end
25+ end
1626end
You can’t perform that action at this time.
0 commit comments