Commit 482586a4 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '211514-flaky-failure-in-qa-specs-features-browser_ui-3_create-repository-add_file_template_spec-rb' into 'master'

Resolve "Flaky failure in qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb | Create File templates user adds LICENSE via file template Mozilla Public License 2.0"

Closes #211514

See merge request gitlab-org/gitlab!27439
parents 250c86ea b208da94
......@@ -344,8 +344,8 @@ module BlobHelper
def show_suggest_pipeline_creation_celebration?
experiment_enabled?(:suggest_pipeline) &&
@blob.auxiliary_viewer.valid?(project: @project, sha: @commit.sha, user: current_user) &&
@blob.path == Gitlab::FileDetector::PATTERNS[:gitlab_ci] &&
@blob.auxiliary_viewer.valid?(project: @project, sha: @commit.sha, user: current_user) &&
@project.uses_default_ci_config? &&
cookies[suggest_pipeline_commit_cookie_name].present?
end
......
......@@ -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,10 +211,13 @@ 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 '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 'experiment enabled' do
before do
allow(helper).to receive(:experiment_enabled?).and_return(true)
......@@ -226,18 +228,16 @@ describe BlobHelper do
end
context 'file is invalid format' do
before do
allow(blob).to receive(:auxiliary_viewer).and_return(double('viewer', valid?: false))
end
let(:data) { 'foo' }
it 'is false' do
expect(helper.show_suggest_pipeline_creation_celebration?).to be_falsey
end
end
context 'path is not a ci file' do
context 'does not use the default ci config' do
before do
allow(blob).to receive(:path).and_return('something_bad')
project.ci_config_path = 'something_bad'
end
it 'is false' do
......@@ -245,19 +245,20 @@ describe BlobHelper do
end
end
context 'does not use the default ci config' do
context 'does not have the needed cookie' do
before do
project.ci_config_path = 'something_bad'
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 have the needed cookie' do
context 'experiment disabled' do
before do
helper.request.cookies.delete "suggest_gitlab_ci_yml_commit_#{project.id}"
allow(helper).to receive(:experiment_enabled?).and_return(false)
end
it 'is false' do
......@@ -266,9 +267,12 @@ describe BlobHelper do
end
end
context 'experiment disabled' do
context 'when file is not a pipeline config file' do
let(:blob) { fake_blob(path: 'LICENSE') }
context 'experiment enabled' do
before do
allow(helper).to receive(:experiment_enabled?).and_return(false)
allow(helper).to receive(:experiment_enabled?).and_return(true)
end
it 'is false' do
......@@ -277,6 +281,7 @@ describe BlobHelper do
end
end
end
end
describe 'suggest_pipeline_commit_cookie_name' do
let(:project) { create(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment