Test container related specs

This commit is contained in:
Kamil Trzcinski 2016-05-16 17:37:28 -05:00
parent a40d915c62
commit 154270a3d4
2 changed files with 76 additions and 0 deletions

View File

@ -772,4 +772,79 @@ describe Project, models: true do
expect(project.protected_branch?('foo')).to eq(false)
end
end
describe '#container_registry_repository' do
let(:project) { create(:empty_project) }
subject { project.container_registry_repository }
it { is_expected.to_not be_nil }
end
describe '#container_registry_repository_url' do
let(:project) { create(:empty_project) }
subject { project.container_registry_repository_url }
before { allow(Gitlab.config.registry).to receive_messages(registry_settings) }
context 'for enabled registry' do
let(:registry_settings) do
{
enabled: true,
host_port: 'example.com',
}
end
it { is_expected.to_not be_nil }
end
context 'for disabled registry' do
let(:registry_settings) do
{
enabled: false
}
end
it { is_expected.to be_nil }
end
end
describe '#has_container_registry_tags?' do
let(:project) { create(:empty_project) }
subject { project.has_container_registry_tags? }
before { allow(Gitlab.config.registry).to receive_messages(registry_settings) }
context 'for enabled registry' do
let(:registry_settings) do
{
enabled: true
}
end
context 'with tags' do
before { stub_container_registry('test', 'test2') }
it { is_expected.to be_truthy }
end
context 'when no tags' do
before { stub_container_registry }
it { is_expected.to be_falsey }
end
end
context 'for disabled registry' do
let(:registry_settings) do
{
enabled: false
}
end
it { is_expected.to be_falsey }
end
end
end

View File

@ -7,6 +7,7 @@ describe Ci::API::API do
let(:registration_token) { 'abcdefg123456' }
before do
stub_gitlab_calls
stub_application_setting(runners_registration_token: registration_token)
end