diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-24 15:36:14 +0300 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-07 13:10:49 +0300 |
commit | de2e8d4a559bd99479f46e527d8e78f67ad37de6 (patch) | |
tree | 528095ad607e325e5427a88969fac05ba067ee4c /spec/requests/api | |
parent | ca1f5ede8456b0c433699fc73931ad39b5571f97 (diff) |
Add tests for yaml content with errors
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/lint_spec.rb | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index 9de9c90a4aa..78a9b415405 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -3,30 +3,36 @@ require 'spec_helper' describe API::API do include ApiHelpers - let(:user) { create(:user) } 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 - context 'authorized user' do - it 'validate content' do - post api('/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') - end + it 'validates content' do + post api('/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') end end - context 'with invalid .gitlab_ci.yml content' do - it 'validate content' do + context 'with invalid .gitlab_ci.yml' do + it 'validates content and shows correct errors' do post api('/lint'), { content: 'invalid content' } expect(response).to have_http_status(200) expect(json_response['status']).to eq('invalid') + expect(json_response['errors']).to eq(['Invalid configuration format']) + end + + it "validates content and shows configuration error" do + post api('/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['errors']).to eq(['jobs config should contain at least one visible job']) end end |