summaryrefslogtreecommitdiff
path: root/spec/models/environment_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r--spec/models/environment_spec.rb28
1 files changed, 19 insertions, 9 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 18a172b72d7..53561586d61 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
subject(:environment) { create(:environment, project: project) }
it { is_expected.to be_kind_of(ReactiveCaching) }
+ it { is_expected.to nullify_if_blank(:external_url) }
it { is_expected.to belong_to(:project).required }
it { is_expected.to have_many(:deployments) }
@@ -214,6 +215,24 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
end
end
+ describe '.auto_deletable' do
+ subject { described_class.auto_deletable(limit) }
+
+ let(:limit) { 100 }
+
+ context 'when environment is auto-deletable' do
+ let!(:environment) { create(:environment, :auto_deletable) }
+
+ it { is_expected.to eq([environment]) }
+ end
+
+ context 'when environment is not auto-deletable' do
+ let!(:environment) { create(:environment) }
+
+ it { is_expected.to be_empty }
+ end
+ end
+
describe '.stop_actions' do
subject { environments.stop_actions }
@@ -412,15 +431,6 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
end
end
- describe '#nullify_external_url' do
- it 'replaces a blank url with nil' do
- env = build(:environment, external_url: "")
-
- expect(env.save).to be true
- expect(env.external_url).to be_nil
- end
- end
-
describe '#includes_commit?' do
let(:project) { create(:project, :repository) }