Commit 58126159 authored by Rubén Dávila's avatar Rubén Dávila

Make push rule to reject unsigned commits EEP only

parent a1c5e146
......@@ -47,6 +47,7 @@ class License < ActiveRecord::Base
object_storage
service_desk
variable_environment_scope
reject_unsigned_commits
].freeze
EEU_FEATURES = EEP_FEATURES
......@@ -115,6 +116,7 @@ class License < ActiveRecord::Base
multiple_ldap_servers
object_storage
repository_size_limit
reject_unsigned_commits
].freeze
validate :valid_license
......
......@@ -22,6 +22,7 @@ class PushRule < ActiveRecord::Base
end
def commit_signature_allowed?(commit)
return true unless License.feature_available?(:reject_unsigned_commits)
return true unless reject_unsigned_commits
commit.has_signature?
......
......@@ -11,4 +11,4 @@
.alert.alert-danger
- @push_rule.errors.full_messages.each do |msg|
%p= msg
= render "shared/push_rules_form", f: f
= render "shared/push_rules/form", f: f
......@@ -15,4 +15,4 @@
= form_for [@project.namespace.becomes(Namespace), @project, @push_rule] do |f|
= form_errors(@push_rule)
= render "shared/push_rules_form", f: f
= render "shared/push_rules/form", f: f
.form-group
= f.check_box :reject_unsigned_commits, class: "pull-left", disabled: !can_change_reject_unsigned_commits?(f.object)
.prepend-left-20
= f.label :reject_unsigned_commits, class: "label-light append-bottom-0" do
Reject unsigned commits
%p.light.append-bottom-0
= reject_unsigned_commits_description(f.object)
= render 'shared/push_rules/reject_unsigned_commits_setting', form: f, push_rule: f.object
.form-group
= f.check_box :deny_delete_tag, class: "pull-left"
......
- return unless License.feature_available?(:reject_unsigned_commits)
- form = local_assigns.fetch(:form)
- push_rule = local_assigns.fetch(:push_rule)
.form-group
= form.check_box :reject_unsigned_commits, class: "pull-left", disabled: !can_change_reject_unsigned_commits?(push_rule)
.prepend-left-20
= form.label :reject_unsigned_commits, class: "label-light append-bottom-0" do
Reject unsigned commits
%p.light.append-bottom-0
= reject_unsigned_commits_description(push_rule)
require 'spec_helper'
describe "Admin::PushRules" do
let(:current_user) { create(:admin) }
before do
sign_in(current_user)
end
context 'when reject_unsigned_commits is unlicensed' do
before do
stub_licensed_features(reject_unsigned_commits: false)
end
it 'does not render the setting checkbox' do
visit admin_push_rule_path
expect(page).not_to have_content('Reject unsigned commits')
end
end
context 'when reject_unsigned_commits is licensed' do
before do
stub_licensed_features(reject_unsigned_commits: true)
end
it 'renders the setting checkbox' do
visit admin_push_rule_path
expect(page).to have_content('Reject unsigned commits')
end
end
end
......@@ -52,6 +52,17 @@ describe PushRule do
let(:signed_commit) { double(has_signature?: true) }
let(:unsigned_commit) { double(has_signature?: false) }
context 'when feature is not licensed and it is enabled' do
before do
stub_licensed_features(reject_unsigned_commits: false)
global_push_rule.update_attribute(:reject_unsigned_commits, true)
end
it 'accepts unsigned commits' do
expect(push_rule.commit_signature_allowed?(unsigned_commit)).to eq(true)
end
end
context 'when enabled at a global level' do
before do
global_push_rule.update_attribute(:reject_unsigned_commits, true)
......
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