diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 12:09:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 12:09:13 +0000 |
commit | 1363ca12f1f07c634647cf55c4c16b7401098673 (patch) | |
tree | d932caf09c8148322edb51ae954ed159ff7d00f8 /spec/helpers | |
parent | 6763d2787670bc03a36a8eb601703e88fc70dece (diff) | |
download | gitlab-ce-1363ca12f1f07c634647cf55c4c16b7401098673.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index dec7d6b2df3..2631c219222 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -204,7 +204,6 @@ describe BlobHelper do end describe '#show_suggest_pipeline_creation_celebration?' do - let(:blob) { fake_blob(path: Gitlab::FileDetector::PATTERNS[:gitlab_ci]) } let(:current_user) { create(:user) } before do @@ -212,52 +211,68 @@ describe BlobHelper do assign(:blob, blob) assign(:commit, double('Commit', sha: 'whatever')) helper.request.cookies["suggest_gitlab_ci_yml_commit_#{project.id}"] = 'true' - allow(blob).to receive(:auxiliary_viewer).and_return(double('viewer', valid?: true)) allow(helper).to receive(:current_user).and_return(current_user) end - context 'experiment enabled' do - before do - allow(helper).to receive(:experiment_enabled?).and_return(true) - end - - it 'is true' do - expect(helper.show_suggest_pipeline_creation_celebration?).to be_truthy - end + context 'when file is a pipeline config file' do + let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) } + let(:blob) { fake_blob(path: Gitlab::FileDetector::PATTERNS[:gitlab_ci], data: data) } - context 'file is invalid format' do + context 'experiment enabled' do before do - allow(blob).to receive(:auxiliary_viewer).and_return(double('viewer', valid?: false)) + allow(helper).to receive(:experiment_enabled?).and_return(true) end - it 'is false' do - expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + it 'is true' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_truthy end - end - context 'path is not a ci file' do - before do - allow(blob).to receive(:path).and_return('something_bad') + context 'file is invalid format' do + let(:data) { 'foo' } + + it 'is false' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + end end - it 'is false' do - expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + context 'does not use the default ci config' do + before do + project.ci_config_path = 'something_bad' + end + + it 'is false' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + end + end + + context 'does not have the needed cookie' do + before do + helper.request.cookies.delete "suggest_gitlab_ci_yml_commit_#{project.id}" + end + + it 'is false' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + end end end - context 'does not use the default ci config' do + context 'experiment disabled' do before do - project.ci_config_path = 'something_bad' + allow(helper).to receive(:experiment_enabled?).and_return(false) end it 'is false' do expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey end end + end - context 'does not have the needed cookie' do + context 'when file is not a pipeline config file' do + let(:blob) { fake_blob(path: 'LICENSE') } + + context 'experiment enabled' do before do - helper.request.cookies.delete "suggest_gitlab_ci_yml_commit_#{project.id}" + allow(helper).to receive(:experiment_enabled?).and_return(true) end it 'is false' do @@ -265,16 +280,6 @@ describe BlobHelper do end end end - - context 'experiment disabled' do - before do - allow(helper).to receive(:experiment_enabled?).and_return(false) - end - - it 'is false' do - expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey - end - end end end |