summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-05-16 17:37:28 -0500
committerKamil Trzcinski <ayufan@ayufan.eu>2016-05-16 17:37:28 -0500
commit154270a3d4f42f1751502112d0e9cd6b5983032b (patch)
treed402d6bd2e6005f6609689ea00f74fbe275dd016 /spec
parenta40d915c62a02a79c94cb513361310459a118b62 (diff)
downloadgitlab-ce-154270a3d4f42f1751502112d0e9cd6b5983032b.tar.gz
Test container related specs
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_spec.rb75
-rw-r--r--spec/requests/ci/api/runners_spec.rb1
2 files changed, 76 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f6e5b132643..6de75af08e4 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -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
diff --git a/spec/requests/ci/api/runners_spec.rb b/spec/requests/ci/api/runners_spec.rb
index 43f9fe89c8e..db8189ffb79 100644
--- a/spec/requests/ci/api/runners_spec.rb
+++ b/spec/requests/ci/api/runners_spec.rb
@@ -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