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:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 10:53:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 10:53:40 +0300
commitcfc792b9ca064990e6540cb742e80529ea669a81 (patch)
tree147cd4256319990cebbc02fe8e4fbbbe06f5720a /spec/models/environment_spec.rb
parent93c6764dacd4c605027ef1cd367d3aebe420b223 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r--spec/models/environment_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 826e5b41a5c..0537220fcd2 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -441,6 +441,16 @@ describe Environment, :use_clean_rails_memory_store_caching do
end
end
+ describe '#reset_auto_stop' do
+ subject { environment.reset_auto_stop }
+
+ let(:environment) { create(:environment, :auto_stopped) }
+
+ it 'nullifies the auto_stop_at' do
+ expect { subject }.to change(environment, :auto_stop_at).from(Time).to(nil)
+ end
+ end
+
describe '#actions_for' do
let(:deployment) { create(:deployment, :success, environment: environment) }
let(:pipeline) { deployment.deployable.pipeline }
@@ -1088,6 +1098,52 @@ describe Environment, :use_clean_rails_memory_store_caching do
end
end
+ describe '#auto_stop_in' do
+ subject { environment.auto_stop_in }
+
+ context 'when environment will be expired' do
+ let(:environment) { build(:environment, :will_auto_stop) }
+
+ it 'returns when it will expire' do
+ Timecop.freeze { is_expected.to eq(1.day.to_i) }
+ end
+ end
+
+ context 'when environment is not expired' do
+ let(:environment) { build(:environment) }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#auto_stop_in=' do
+ subject { environment.auto_stop_in = value }
+
+ let(:environment) { build(:environment) }
+
+ where(:value, :expected_result) do
+ '2 days' | 2.days.to_i
+ '1 week' | 1.week.to_i
+ '2h20min' | 2.hours.to_i + 20.minutes.to_i
+ 'abcdef' | ChronicDuration::DurationParseError
+ '' | nil
+ nil | nil
+ end
+ with_them do
+ it 'sets correct auto_stop_in' do
+ Timecop.freeze do
+ if expected_result.is_a?(Integer) || expected_result.nil?
+ subject
+
+ expect(environment.auto_stop_in).to eq(expected_result)
+ else
+ expect { subject }.to raise_error(expected_result)
+ end
+ end
+ end
+ end
+ end
+
describe '.find_or_create_by_name' do
it 'finds an existing environment if it exists' do
env = create(:environment)