Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-08-03 08:17:22 +0300
committerShinya Maeda <shinya@gitlab.com>2018-08-03 08:17:22 +0300
commit1f53cf7cf0cb53b5d69ab141fa9020356e62027e (patch)
treefac87bd3fcf2900116bbc2777eb6f347f50922f6 /spec/models
parentd867081df185b873667d9eec1184ac92efc8973e (diff)
parent5f664759b57ef1c0fcfb7e95dfbff6c080a7a72f (diff)
Merge branch 'master-ce' into artifact-format-v2-with-parser
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb24
-rw-r--r--spec/models/clusters/applications/jupyter_spec.rb24
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb22
-rw-r--r--spec/models/clusters/applications/runner_spec.rb24
-rw-r--r--spec/models/deploy_token_spec.rb8
-rw-r--r--spec/models/merge_request_diff_spec.rb7
6 files changed, 106 insertions, 3 deletions
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index bb5b2ef3a47..d378248d5d6 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -23,6 +23,20 @@ describe Clusters::Applications::Ingress do
it { is_expected.to contain_exactly(cluster) }
end
+ describe '#make_installing!' do
+ before do
+ application.make_installing!
+ end
+
+ context 'application install previously errored with older version' do
+ let(:application) { create(:clusters_applications_ingress, :scheduled, version: '0.22.0') }
+
+ it 'updates the application version' do
+ expect(application.reload.version).to eq('0.23.0')
+ end
+ end
+ end
+
describe '#make_installed!' do
before do
application.make_installed!
@@ -73,9 +87,17 @@ describe Clusters::Applications::Ingress do
it 'should be initialized with ingress arguments' do
expect(subject.name).to eq('ingress')
expect(subject.chart).to eq('stable/nginx-ingress')
- expect(subject.version).to be_nil
+ expect(subject.version).to eq('0.23.0')
expect(subject.values).to eq(ingress.values)
end
+
+ context 'application failed to install previously' do
+ let(:ingress) { create(:clusters_applications_ingress, :errored, version: 'nginx') }
+
+ it 'should be initialized with the locked version' do
+ expect(subject.version).to eq('0.23.0')
+ end
+ end
end
describe '#values' do
diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb
index 65750141e65..e0d57ac65f7 100644
--- a/spec/models/clusters/applications/jupyter_spec.rb
+++ b/spec/models/clusters/applications/jupyter_spec.rb
@@ -25,6 +25,20 @@ describe Clusters::Applications::Jupyter do
end
end
+ describe '#make_installing!' do
+ before do
+ application.make_installing!
+ end
+
+ context 'application install previously errored with older version' do
+ let(:application) { create(:clusters_applications_jupyter, :scheduled, version: 'v0.5') }
+
+ it 'updates the application version' do
+ expect(application.reload.version).to eq('v0.6')
+ end
+ end
+ end
+
describe '#install_command' do
let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: ingress.cluster) }
@@ -36,10 +50,18 @@ describe Clusters::Applications::Jupyter do
it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('jupyter')
expect(subject.chart).to eq('jupyter/jupyterhub')
- expect(subject.version).to be_nil
+ expect(subject.version).to eq('v0.6')
expect(subject.repository).to eq('https://jupyterhub.github.io/helm-chart/')
expect(subject.values).to eq(jupyter.values)
end
+
+ context 'application failed to install previously' do
+ let(:jupyter) { create(:clusters_applications_jupyter, :errored, version: '0.0.1') }
+
+ it 'should be initialized with the locked version' do
+ expect(subject.version).to eq('v0.6')
+ end
+ end
end
describe '#values' do
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index e4b61552033..3812c65b3b6 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -16,6 +16,20 @@ describe Clusters::Applications::Prometheus do
it { is_expected.to contain_exactly(cluster) }
end
+ describe '#make_installing!' do
+ before do
+ application.make_installing!
+ end
+
+ context 'application install previously errored with older version' do
+ let(:application) { create(:clusters_applications_prometheus, :scheduled, version: '6.7.2') }
+
+ it 'updates the application version' do
+ expect(application.reload.version).to eq('6.7.3')
+ end
+ end
+ end
+
describe 'transition to installed' do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, projects: [project]) }
@@ -155,6 +169,14 @@ describe Clusters::Applications::Prometheus do
expect(command.version).to eq('6.7.3')
expect(command.values).to eq(prometheus.values)
end
+
+ context 'application failed to install previously' do
+ let(:prometheus) { create(:clusters_applications_prometheus, :errored, version: '2.0.0') }
+
+ it 'should be initialized with the locked version' do
+ expect(subject.version).to eq('6.7.3')
+ end
+ end
end
describe '#values' do
diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb
index b12500d0acd..526300755b5 100644
--- a/spec/models/clusters/applications/runner_spec.rb
+++ b/spec/models/clusters/applications/runner_spec.rb
@@ -8,6 +8,20 @@ describe Clusters::Applications::Runner do
it { is_expected.to belong_to(:runner) }
+ describe '#make_installing!' do
+ before do
+ application.make_installing!
+ end
+
+ context 'application install previously errored with older version' do
+ let(:application) { create(:clusters_applications_runner, :scheduled, version: '0.1.30') }
+
+ it 'updates the application version' do
+ expect(application.reload.version).to eq('0.1.31')
+ end
+ end
+ end
+
describe '.installed' do
subject { described_class.installed }
@@ -31,10 +45,18 @@ describe Clusters::Applications::Runner do
it 'should be initialized with 4 arguments' do
expect(subject.name).to eq('runner')
expect(subject.chart).to eq('runner/gitlab-runner')
- expect(subject.version).to be_nil
+ expect(subject.version).to eq('0.1.31')
expect(subject.repository).to eq('https://charts.gitlab.io')
expect(subject.values).to eq(gitlab_runner.values)
end
+
+ context 'application failed to install previously' do
+ let(:gitlab_runner) { create(:clusters_applications_runner, :errored, runner: ci_runner, version: '0.1.13') }
+
+ it 'should be initialized with the locked version' do
+ expect(subject.version).to eq('0.1.31')
+ end
+ end
end
describe '#values' do
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index cd84a684fec..3435f93c999 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -74,6 +74,14 @@ describe DeployToken do
expect(deploy_token.active?).to be_falsy
end
end
+
+ context "when it hasn't been revoked and has no expiry" do
+ let(:deploy_token) { create(:deploy_token, expires_at: nil) }
+
+ it 'should return true' do
+ expect(deploy_token.active?).to be_truthy
+ end
+ end
end
describe '#username' do
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index 0aee78ac12d..90cce826b6c 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -127,6 +127,13 @@ describe MergeRequestDiff do
expect(diffs.map(&:new_path)).to contain_exactly('files/ruby/popen.rb')
end
+ it 'only serializes diff files found by query' do
+ expect(diff_with_commits.merge_request_diff_files.count).to be > 10
+ expect_any_instance_of(MergeRequestDiffFile).to receive(:to_hash).once
+
+ diffs
+ end
+
it 'uses the diffs from the DB' do
expect(diff_with_commits).to receive(:load_diffs)