diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 21:09:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-24 21:09:08 +0000 |
commit | 7671216b60e2796a050358ff808b4a0c2de3d22f (patch) | |
tree | 605dfc1339a3cd7dc7353ac6d725191086a9acca /spec/helpers | |
parent | c2367afbf57ebc65d5b78a743b5d6a91f0aece9f (diff) | |
download | gitlab-ce-7671216b60e2796a050358ff808b4a0c2de3d22f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index a9f4b03eba5..dec7d6b2df3 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -27,7 +27,7 @@ describe BlobHelper do end describe "#edit_blob_link" do - let(:namespace) { create(:namespace, name: 'gitlab' )} + let(:namespace) { create(:namespace, name: 'gitlab') } let(:project) { create(:project, :repository, namespace: namespace) } before do @@ -202,6 +202,90 @@ describe BlobHelper do end end 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 + assign(:project, project) + 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 'file is invalid format' do + before do + allow(blob).to receive(:auxiliary_viewer).and_return(double('viewer', valid?: false)) + end + + it 'is false' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + end + end + + context 'path is not a ci file' do + before do + allow(blob).to receive(:path).and_return('something_bad') + end + + it 'is false' do + expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey + end + end + + 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 '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 + + describe 'suggest_pipeline_commit_cookie_name' do + let(:project) { create(:project) } + + it 'uses project id to make up the cookie name' do + assign(:project, project) + + expect(helper.suggest_pipeline_commit_cookie_name).to eq "suggest_gitlab_ci_yml_commit_#{project.id}" + end end describe '#ide_edit_path' do |