Commit 6e151b78 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '326023-create-fflag-reject-unsigned-commits' into 'master'

Step 1 - Create Feature Flag for reject_unsigned_commits_by_gitlab [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58453
parents b42ca8d3 115beab7
......@@ -208,7 +208,7 @@ export const canPushCodeStatus = (state, getters) => {
PUSH_RULE_REJECT_UNSIGNED_COMMITS
];
if (rejectUnsignedCommits) {
if (window.gon?.features?.rejectUnsignedCommitsByGitlab && rejectUnsignedCommits) {
return {
isAllowed: false,
message: MSG_CANNOT_PUSH_UNSIGNED,
......
......@@ -10,6 +10,7 @@ class IdeController < ApplicationController
before_action do
push_frontend_feature_flag(:build_service_proxy)
push_frontend_feature_flag(:schema_linting)
push_frontend_feature_flag(:reject_unsigned_commits_by_gitlab, default_enabled: :yaml)
define_index_vars
end
......
---
name: reject_unsigned_commits_by_gitlab
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58453
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/326775
milestone: '13.11'
type: development
group: group::editor
default_enabled: true
......@@ -3,6 +3,7 @@
require 'spec_helper'
RSpec.describe 'EE user opens IDE', :js do
using RSpec::Parameterized::TableSyntax
include WebIdeSpecHelpers
let_it_be(:unsigned_commits_warning) { 'This project does not accept unsigned commits.' }
......@@ -16,25 +17,39 @@ RSpec.describe 'EE user opens IDE', :js do
sign_in(user)
end
context 'default' do
before do
shared_examples 'no warning' do
it 'does not show warning' do
ide_visit(project)
end
it 'does not show warning' do
expect(page).not_to have_text(unsigned_commits_warning)
end
end
shared_examples 'has warning' do
it 'shows warning' do
ide_visit(project)
expect(page).to have_text(unsigned_commits_warning)
end
end
context 'no push rules' do
it_behaves_like 'no warning'
end
context 'when has reject_unsigned_commit push rule' do
before do
create(:push_rule, project: project, reject_unsigned_commits: true)
end
ide_visit(project)
it_behaves_like 'has warning'
context 'and feature flag off' do
before do
stub_feature_flags(reject_unsigned_commits_by_gitlab: false)
end
it 'shows warning' do
expect(page).to have_text(unsigned_commits_warning)
it_behaves_like 'no warning'
end
end
end
......@@ -24,12 +24,22 @@ const TEST_FORK_PATH = '/test/fork/path';
describe('IDE store getters', () => {
let localState;
let localStore;
let origGon;
beforeEach(() => {
origGon = window.gon;
// Feature flag is defaulted to on in prod
window.gon = { features: { rejectUnsignedCommitsByGitlab: true } };
localStore = createStore();
localState = localStore.state;
});
afterEach(() => {
window.gon = origGon;
});
describe('activeFile', () => {
it('returns the current active file', () => {
localState.openFiles.push(file());
......@@ -500,9 +510,25 @@ describe('IDE store getters', () => {
},
},
],
[
'when can push code, but cannot push unsigned commits, with reject_unsigned_commits_by_gitlab feature off',
{
input: {
pushCode: true,
rejectUnsignedCommits: true,
features: { rejectUnsignedCommitsByGitlab: false },
},
output: {
isAllowed: true,
message: '',
messageShort: '',
},
},
],
])('%s', (testName, { input, output }) => {
const { forkInfo, rejectUnsignedCommits, pushCode } = input;
const { forkInfo, rejectUnsignedCommits, pushCode, features = {} } = input;
Object.assign(window.gon.features, features);
localState.links = { forkInfo };
localState.projects[TEST_PROJECT_ID] = {
pushRules: {
......
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