diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-08-24 12:42:48 +0300 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-09-07 13:10:49 +0300 |
commit | ca1f5ede8456b0c433699fc73931ad39b5571f97 (patch) | |
tree | 56d259f58ca04cd1efd37bd7ec5b60adeb83cb65 /spec/requests/api/lint_spec.rb | |
parent | 257c2acde7a0be63d955df63ca29488236e5654f (diff) |
Move lint to api from ci/api
Diffstat (limited to 'spec/requests/api/lint_spec.rb')
-rw-r--r-- | spec/requests/api/lint_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb new file mode 100644 index 00000000000..9de9c90a4aa --- /dev/null +++ b/spec/requests/api/lint_spec.rb @@ -0,0 +1,41 @@ +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 + end + end + + context 'with invalid .gitlab_ci.yml content' do + it 'validate content' do + post api('/lint'), { content: 'invalid content' } + + expect(response).to have_http_status(200) + expect(json_response['status']).to eq('invalid') + end + end + + context 'no content parameters' do + it 'shows error message' do + post api('/lint') + + expect(response).to have_http_status(400) + end + end + end +end |