summaryrefslogtreecommitdiff
path: root/spec/requests/api/commit_statuses_spec.rb
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-04-11 06:29:07 +0000
committerJames Lopez <james@gitlab.com>2019-04-11 06:29:07 +0000
commitd119d3d1b25aac661e6251addf87b280bd37f0c5 (patch)
treeaeaf0d9503326ec7f51968e8d1de48d83ce90503 /spec/requests/api/commit_statuses_spec.rb
parent79bf4bdaad438dc0f82771b102f3c07225a428da (diff)
downloadgitlab-ce-d119d3d1b25aac661e6251addf87b280bd37f0c5.tar.gz
Align UrlValidator to validate_url gem implementation.
Renamed UrlValidator to AddressableUrlValidator to avoid 'url:' naming collision with ActiveModel::Validations::UrlValidator in 'validates' statement. Make use of the options attribute of the parent class ActiveModel::EachValidator. Add more options: allow_nil, allow_blank, message. Renamed 'protocols' option to 'schemes' to match the option naming from UrlValidator.
Diffstat (limited to 'spec/requests/api/commit_statuses_spec.rb')
-rw-r--r--spec/requests/api/commit_statuses_spec.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 9388343c392..b5e45f99109 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -306,7 +306,22 @@ describe API::CommitStatuses do
it 'responds with bad request status and validation errors' do
expect(response).to have_gitlab_http_status(400)
expect(json_response['message']['target_url'])
- .to include 'is blocked: Only allowed protocols are http, https'
+ .to include 'is blocked: Only allowed schemes are http, https'
+ end
+ end
+
+ context 'when target URL is an unsupported scheme' do
+ before do
+ post api(post_url, developer), params: {
+ state: 'pending',
+ target_url: 'git://example.com'
+ }
+ end
+
+ it 'responds with bad request status and validation errors' do
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response['message']['target_url'])
+ .to include 'is blocked: Only allowed schemes are http, https'
end
end
end