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:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-07-03 12:17:07 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-07-04 11:35:25 +0300
commit99dea5fa13286346f8c7066d803eb04f4e989663 (patch)
tree53f87b3caca11b825dee9de433815f2fd69174b0 /spec/models/project_spec.rb
parent55e2df6c804202a39d0165289988062a693087aa (diff)
Makes production environment the default environment for a project
Diffstat (limited to 'spec/models/project_spec.rb')
-rw-r--r--spec/models/project_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index a2f8fac2f38..312164558fb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2292,6 +2292,28 @@ describe Project do
end
end
+ describe '#default_environment' do
+ let(:project) { create(:project) }
+
+ it 'returns production environment when it exists' do
+ production = create(:environment, name: "production", project: project)
+ create(:environment, name: 'staging', project: project)
+
+ expect(project.default_environment).to eq(production)
+ end
+
+ it 'returns first environment when no production environment exists' do
+ create(:environment, name: 'staging', project: project)
+ create(:environment, name: 'foo', project: project)
+
+ expect(project.default_environment).to eq(project.environments.first)
+ end
+
+ it 'returns nil when no available environment exists' do
+ expect(project.default_environment).to be_nil
+ end
+ end
+
describe '#secret_variables_for' do
let(:project) { create(:project) }