diff options
Diffstat (limited to 'spec/models/project_ci_cd_setting_spec.rb')
-rw-r--r-- | spec/models/project_ci_cd_setting_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/project_ci_cd_setting_spec.rb b/spec/models/project_ci_cd_setting_spec.rb index 4aa62028169..80f75f45e43 100644 --- a/spec/models/project_ci_cd_setting_spec.rb +++ b/spec/models/project_ci_cd_setting_spec.rb @@ -21,4 +21,26 @@ describe ProjectCiCdSetting do 2.times { described_class.available? } end end + + describe 'validations' do + it { is_expected.to validate_numericality_of(:default_git_depth).only_integer.is_greater_than_or_equal_to(0).is_less_than_or_equal_to(1000).allow_nil } + end + + describe '#default_git_depth' do + let(:default_value) { described_class::DEFAULT_GIT_DEPTH } + + it 'sets default value for new records' do + project = create(:project) + + expect(project.ci_cd_settings.default_git_depth).to eq(default_value) + end + + it 'does not set default value if present' do + project = build(:project) + project.build_ci_cd_settings(default_git_depth: 42) + project.save! + + expect(project.reload.ci_cd_settings.default_git_depth).to eq(42) + end + end end |