blob: 4a18fd0b6b306bae63625984980fd5dd0659ac79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require 'spec_helper'
describe Ci::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 /ci/lint' do
context "with valid .gitlab-ci.yaml content" do
context "authorized user" do
it "validate content" do
post ci_api('/lint'), { private_token: user.private_token, content: yaml_content }
expect(response).to have_http_status(201)
expect(json_response).to be_an Hash
expect(json_response['status']).to eq('syntax is correct')
end
end
context "unauthorized user" do
it "does not validate content" do
post ci_api('/lint'), { content: yaml_content }
expect(response).to have_http_status(401)
end
end
end
context "with invalid .gitlab_ci.yml content" do
it "validate content" do
post ci_api('/lint'), { private_token: user.private_token, content: 'invalid content' }
expect(response).to have_http_status(500)
expect(json_response['status']).to eq('syntax is incorrect')
end
end
context "no content" do
it "shows error message" do
post ci_api('/lint'), { private_token: user.private_token }
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('Please provide content of .gitlab-ci.yml')
end
end
end
end
|