gitlab-org--gitlab-foss/spec/requests/ci/api/lint_spec.rb

42 lines
1 KiB
Ruby
Raw Normal View History

2016-08-18 02:50:01 -04:00
require 'spec_helper'
describe Ci::API::API do
include ApiHelpers
2016-08-23 06:12:21 -04:00
let(:user) { create(:user) }
let(:yaml_content) do
2016-08-18 02:50:01 -04:00
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
2016-08-23 06:12:21 -04:00
describe 'POST /ci/lint' do
2016-08-24 04:16:58 -04:00
context 'with valid .gitlab-ci.yaml content' do
context 'authorized user' do
it 'validate content' do
2016-08-23 06:12:21 -04:00
post ci_api('/lint'), { content: yaml_content }
2016-08-18 02:50:01 -04:00
2016-08-24 04:16:58 -04:00
expect(response).to have_http_status(200)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('valid')
2016-08-18 02:50:01 -04:00
end
end
end
2016-08-23 06:12:21 -04:00
2016-08-24 04:16:58 -04:00
context 'with invalid .gitlab_ci.yml content' do
it 'validate content' do
post ci_api('/lint'), { content: 'invalid content' }
2016-08-23 06:12:21 -04:00
2016-08-24 04:16:58 -04:00
expect(response).to have_http_status(200)
expect(json_response['status']).to eq('invalid')
2016-08-23 06:12:21 -04:00
end
end
2016-08-24 04:16:58 -04:00
context 'no content parameters' do
it 'shows error message' do
post ci_api('/lint')
2016-08-23 06:12:21 -04:00
expect(response).to have_http_status(400)
end
end
2016-08-18 02:50:01 -04:00
end
end