-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3627 from alphagov/redirect-asset-requests-to-ass…
…et-host Redirect asset requests to asset host
- Loading branch information
Showing
6 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "test_helper" | ||
|
||
class PublicUploadsControllerTest < ActionController::TestCase | ||
setup do | ||
Plek.any_instance.stubs(:public_asset_host).returns('http://asset-host.com') | ||
end | ||
|
||
test "redirects asset requests that aren't made via the asset host" do | ||
request.host = 'not-asset-host.com' | ||
|
||
get :show, params: { path: 'asset', format: 'txt' } | ||
|
||
assert_redirected_to 'http://asset-host.com/government/uploads/asset.txt' | ||
end | ||
|
||
test 'does not redirect asset requests that are made via the asset host' do | ||
asset_filesystem_path = File.join(Whitehall.clean_uploads_root, 'asset.txt') | ||
FileUtils.touch(asset_filesystem_path) | ||
|
||
request.host = 'asset-host.com' | ||
|
||
get :show, params: { path: 'asset', format: 'txt' } | ||
|
||
assert_response 200 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters