summaryrefslogtreecommitdiff
path: root/spec/requests/api/lint_spec.rb
diff options
context:
space:
mode:
authorKatarzyna Kobierska <kkobierska@gmail.com>2016-08-29 15:07:19 +0200
committerKatarzyna Kobierska <kkobierska@gmail.com>2016-09-07 12:10:49 +0200
commit2c8b830fdbf749e8bb7461d5c3ce4699b77ce3ca (patch)
tree10e0c44ca36349acf1378d3191267c9d1493b321 /spec/requests/api/lint_spec.rb
parentbbba62fa51419b14be4f39873afdd45b5b248764 (diff)
downloadgitlab-ce-2c8b830fdbf749e8bb7461d5c3ce4699b77ce3ca.tar.gz
Code refactoring
Diffstat (limited to 'spec/requests/api/lint_spec.rb')
-rw-r--r--spec/requests/api/lint_spec.rb31
1 files changed, 16 insertions, 15 deletions
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb
index 8bad57819c8..5f8c2829dfa 100644
--- a/spec/requests/api/lint_spec.rb
+++ b/spec/requests/api/lint_spec.rb
@@ -1,44 +1,45 @@
require 'spec_helper'
-describe API::API do
+describe API::Lint, api: true do
include ApiHelpers
- let(:yaml_content) do
- File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
- end
+ describe 'POST /ci/lint' do
+ let(:yaml_content) do
+ File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ end
- describe 'POST /lint' do
context 'with valid .gitlab-ci.yaml content' do
- it 'validates the content' do
- post api('/lint'), { content: yaml_content }
+ it 'passes validation' do
+ post api('/ci/lint'), { content: yaml_content }
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid')
+ expect(json_response['error']).to eq('')
end
end
context 'with an invalid .gitlab_ci.yml' do
- it 'validates the content and shows an error message' do
- post api('/lint'), { content: 'invalid content' }
+ it 'responds with errors about invalid syntax' do
+ post api('/ci/lint'), { content: 'invalid content' }
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
- expect(json_response['error']).to eq(['Invalid configuration format'])
+ expect(json_response['error']).to eq('Invalid configuration format')
end
- it "validates the content and shows a configuration error" do
- post api('/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' }
+ it "responds with errors about invalid configuration" do
+ post api('/ci/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' }
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
- expect(json_response['error']).to eq(['jobs config should contain at least one visible job'])
+ expect(json_response['error']).to eq('jobs config should contain at least one visible job')
end
end
context 'without the content parameter' do
- it 'shows an error message' do
- post api('/lint')
+ it 'responds with validation error about missing content' do
+ post api('/ci/lint')
expect(response).to have_http_status(400)
expect(json_response['error']).to eq('content is missing')