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
8
8
argument :section
9
9
10
10
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 } "
12
23
end
13
24
end
14
25
end
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def config
29
29
c . uploader = :active_storage
30
30
c . site_publishable = false
31
31
c . preview_host = nil
32
- c . asset_host = Rails . application . config . action_controller . asset_host
32
+ c . asset_host = Rails . application . config . asset_host
33
33
c . ui_locale = nil
34
34
c . back_action = nil
35
35
c . services = { }
Original file line number Diff line number Diff line change 13
13
it 'returns the url to the screenshot of the section' do
14
14
expect ( subject ) . to eq '/theme/jumbotron.png?42'
15
15
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
16
26
end
You can’t perform that action at this time.
0 commit comments