summaryrefslogtreecommitdiff
path: root/spec/models/project_ci_cd_setting_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/project_ci_cd_setting_spec.rb')
-rw-r--r--spec/models/project_ci_cd_setting_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/models/project_ci_cd_setting_spec.rb b/spec/models/project_ci_cd_setting_spec.rb
index 698465e854a..406485d8cc8 100644
--- a/spec/models/project_ci_cd_setting_spec.rb
+++ b/spec/models/project_ci_cd_setting_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe ProjectCiCdSetting do
+ using RSpec::Parameterized::TableSyntax
+
describe 'validations' do
it 'validates default_git_depth is between 0 and 1000 or nil' do
expect(subject).to validate_numericality_of(:default_git_depth)
@@ -36,4 +38,39 @@ RSpec.describe ProjectCiCdSetting do
expect(project.reload.ci_cd_settings.default_git_depth).to eq(0)
end
end
+
+ describe '#keep_latest_artifacts_available?' do
+ let(:attrs) { { keep_latest_artifact: project_enabled } }
+ let(:project_settings) { described_class.new(attrs) }
+
+ subject { project_settings.keep_latest_artifacts_available? }
+
+ context 'without application setting record' do
+ where(:project_enabled, :result_keep_latest_artifact) do
+ false | false
+ true | true
+ end
+
+ with_them do
+ it { expect(subject).to eq(result_keep_latest_artifact) }
+ end
+ end
+
+ context 'with application setting record' do
+ where(:instance_enabled, :project_enabled, :result_keep_latest_artifact) do
+ false | false | false
+ false | true | false
+ true | false | false
+ true | true | true
+ end
+
+ before do
+ Gitlab::CurrentSettings.current_application_settings.update!(keep_latest_artifact: instance_enabled)
+ end
+
+ with_them do
+ it { expect(subject).to eq(result_keep_latest_artifact) }
+ end
+ end
+ end
end