diff options
Diffstat (limited to 'spec/helpers/blob_helper_spec.rb')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 3ba9f39d21a..06f86e7716a 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -481,4 +481,59 @@ RSpec.describe BlobHelper do end end end + + describe '#editing_ci_config?' do + let(:project) { build(:project) } + + subject { helper.editing_ci_config? } + + before do + assign(:project, project) + assign(:path, path) + end + + context 'when path is nil' do + let(:path) { nil } + + it { is_expected.to be_falsey } + end + + context 'when path is not a ci file' do + let(:path) { 'some-file.txt' } + + it { is_expected.to be_falsey } + end + + context 'when path ends is gitlab-ci.yml' do + let(:path) { '.gitlab-ci.yml' } + + it { is_expected.to be_truthy } + end + + context 'when path ends with gitlab-ci.yml' do + let(:path) { 'template.gitlab-ci.yml' } + + it { is_expected.to be_truthy } + end + + context 'with custom ci paths' do + let(:path) { 'path/to/ci.yaml' } + + before do + project.ci_config_path = 'path/to/ci.yaml' + end + + it { is_expected.to be_truthy } + end + + context 'with custom ci config and path' do + let(:path) { 'path/to/template.gitlab-ci.yml' } + + before do + project.ci_config_path = 'ci/path/.gitlab-ci.yml@another-group/another-project' + end + + it { is_expected.to be_truthy } + end + end end |