Commit 9e99c6c0 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'vs/add-additional-clause-for-cc-validation-alert' into 'master'

Show CC validation alert if the corresponding user setting is true

See merge request gitlab-org/gitlab!62735
parents c5ca56dd 5cce750e
......@@ -12,7 +12,7 @@
.js-pipeline-container{ data: { controller_action: "#{controller.action_name}" } }
#js-pipeline-header-vue.pipeline-header-container{ data: { full_path: @project.full_path, pipeline_iid: @pipeline.iid, pipeline_id: @pipeline.id, pipelines_path: project_pipelines_path(@project) } }
- if @pipeline.failed? && @pipeline.user_not_verified?
- if Gitlab.com? && show_cc_validation_alert?(@pipeline)
#js-cc-validation-required-alert
- if @pipeline.commit.present?
......
# frozen_string_literal: true
module EE
module Ci
module PipelinesHelper
def show_cc_validation_alert?(pipeline)
return false if pipeline.user.blank? || current_user != pipeline.user
pipeline.user_not_verified? && !pipeline.user.has_required_credit_card_to_run_pipelines?(pipeline.project)
end
end
end
end
......@@ -171,7 +171,8 @@ RSpec.describe 'Pipeline', :js do
ref: 'master',
status: 'failed',
failure_reason: 'user_not_verified',
sha: project.commit.id
sha: project.commit.id,
user: user
)
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe EE::Ci::PipelinesHelper do
describe '#show_cc_validation_alert?' do
using RSpec::Parameterized::TableSyntax
subject(:show_cc_validation_alert?) { helper.show_cc_validation_alert?(pipeline) }
let(:current_user) { instance_double(User) }
let(:project) { instance_double(Project) }
let(:pipeline) { instance_double(Ci::Pipeline, user_not_verified?: user_not_verified?, project: project, user: current_user) }
where(:user_not_verified?, :has_required_cc?, :result) do
true | false | true
false | true | false
true | true | false
false | false | false
end
with_them do
before do
allow(::Gitlab).to receive(:com?).and_return(true)
allow(helper).to receive(:current_user).and_return(current_user)
allow(current_user).to receive(:has_required_credit_card_to_run_pipelines?)
.with(project)
.and_return(has_required_cc?)
end
it { is_expected.to eq(result) }
end
context 'without current user' do
let(:pipeline) { instance_double(Ci::Pipeline, user: nil) }
before do
allow(helper).to receive(:current_user).and_return(nil)
end
it { is_expected.to be_falsy }
end
end
end
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