Add specs for gitlab ci service validity.
This commit is contained in:
parent
302c52551a
commit
c7daa5f17f
|
@ -26,6 +26,33 @@ describe GitlabCiService do
|
||||||
it { is_expected.to have_one(:service_hook) }
|
it { is_expected.to have_one(:service_hook) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'validations' do
|
||||||
|
context 'active' do
|
||||||
|
before { allow(subject).to receive(:activated?).and_return(true) }
|
||||||
|
|
||||||
|
it { is_expected.to validate_presence_of(:token) }
|
||||||
|
it { is_expected.to validate_presence_of(:project_url) }
|
||||||
|
it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
|
||||||
|
it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
|
||||||
|
it { is_expected.not_to allow_value('token with spaces').for(:token) }
|
||||||
|
it { is_expected.not_to allow_value('token/with%spaces').for(:token) }
|
||||||
|
it { is_expected.not_to allow_value('this is not url').for(:project_url) }
|
||||||
|
it { is_expected.not_to allow_value('http//noturl').for(:project_url) }
|
||||||
|
it { is_expected.not_to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'inactive' do
|
||||||
|
before { allow(subject).to receive(:activated?).and_return(false) }
|
||||||
|
|
||||||
|
it { is_expected.not_to validate_presence_of(:token) }
|
||||||
|
it { is_expected.not_to validate_presence_of(:project_url) }
|
||||||
|
it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
|
||||||
|
it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
|
||||||
|
it { is_expected.to allow_value('token with spaces').for(:token) }
|
||||||
|
it { is_expected.to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'commits methods' do
|
describe 'commits methods' do
|
||||||
before do
|
before do
|
||||||
@service = GitlabCiService.new
|
@service = GitlabCiService.new
|
||||||
|
|
|
@ -17,6 +17,18 @@ describe API::API, api: true do
|
||||||
|
|
||||||
expect(response.status).to eq(400)
|
expect(response.status).to eq(400)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return if the format of token is invalid" do
|
||||||
|
put api("/projects/#{project.id}/services/gitlab-ci", user), token: 'token-with dashes and spaces%', project_url: "http://ci.example.com/projects/1", active: true
|
||||||
|
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return if the format of token is invalid" do
|
||||||
|
put api("/projects/#{project.id}/services/gitlab-ci", user), token: 'token-with dashes and spaces%', project_url: "ftp://ci.example/projects/1", active: true
|
||||||
|
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "DELETE /projects/:id/services/gitlab-ci" do
|
describe "DELETE /projects/:id/services/gitlab-ci" do
|
||||||
|
|
Loading…
Reference in New Issue