-
Notifications
You must be signed in to change notification settings - Fork 9
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 #682 from alphagov/ignore-asset-path
Don't redirect assets paths to CKAN
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'rails_helper' | ||
require 'securerandom' | ||
|
||
RSpec.describe 'CKAN redirection', type: :request do | ||
let(:path) { nil } | ||
|
||
shared_examples "does redirect to CKAN" do | ||
it "does redirect to CKAN" do | ||
get path | ||
|
||
expect(response).to have_http_status(:moved_permanently) | ||
expect(response).to redirect_to("http://testdomain#{path}") | ||
end | ||
end | ||
|
||
shared_examples "doesn't redirect to CKAN" do | ||
it "doesn't redirect to CKAN" do | ||
get path | ||
|
||
expect(response).to_not have_http_status(:moved_permanently) | ||
end | ||
end | ||
|
||
context "with a known path" do | ||
let(:path) { "/dataset/#{SecureRandom.uuid}" } | ||
include_examples "doesn't redirect to CKAN" | ||
end | ||
|
||
context "with an assets path" do | ||
let(:path) { "/find-assets/application-#{SecureRandom.uuid}.js" } | ||
include_examples "doesn't redirect to CKAN" | ||
end | ||
|
||
context "with an unknown path" do | ||
let(:path) { "/an/unknown/path" } | ||
include_examples "does redirect to CKAN" | ||
end | ||
|
||
context "with an unknown path that includes 'find-assets'" do | ||
let(:path) { "/an/unknown/path/find-assets/application" } | ||
include_examples "does redirect to CKAN" | ||
end | ||
end |