Commit d6628cd7 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'sh-fix-issue-217031' into 'master'

Fix errors when pushing with an expired license

Closes #217031

See merge request gitlab-org/gitlab!34458
parents dc7b40af 11c5d33f
---
title: Fix errors when pushing with an expired license
merge_request: 34458
author:
type: fixed
......@@ -5,8 +5,8 @@ module EE
module GitAccess
prepend GeoGitAccess
extend ::Gitlab::Utils::Override
include ActionView::Helpers::SanitizeHelper
include PathLocksHelper
include SubscribableBannerHelper
override :check
def check(cmd, changes)
......@@ -98,11 +98,15 @@ module EE
def check_if_license_blocks_changes!
if ::License.block_changes?
message = ::LicenseHelper.license_message(signed_in: true, is_admin: (user && user.admin?))
message = license_message(signed_in: true, is_admin: (user && user.admin?))
raise ::Gitlab::GitAccess::ForbiddenError, strip_tags(message)
end
end
def strip_tags(html)
Rails::Html::FullSanitizer.new.sanitize(html)
end
override :check_size_limit?
def check_size_limit?
strong_memoize(:check_size_limit) do
......
......@@ -36,9 +36,9 @@ module Gitlab
def expired_subject
if subscribable.block_changes?
if auto_renew?
_('Something went wrong with your automatic subscription renewal')
_('Something went wrong with your automatic subscription renewal.')
else
_('Your subscription has been downgraded')
_('Your subscription has been downgraded.')
end
else
_('Your subscription expired!')
......@@ -49,9 +49,9 @@ module Gitlab
remaining_days = pluralize(subscribable.remaining_days, 'day')
if auto_renew?
_('Your subscription will automatically renew in %{remaining_days}') % { remaining_days: remaining_days }
_('Your subscription will automatically renew in %{remaining_days}.') % { remaining_days: remaining_days }
else
_('Your subscription will expire in %{remaining_days}') % { remaining_days: remaining_days }
_('Your subscription will expire in %{remaining_days}.') % { remaining_days: remaining_days }
end
end
......
......@@ -67,7 +67,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
it 'has a nice subject' do
Timecop.freeze(today) do
expect(subject).to include('Your subscription has been downgraded')
expect(subject).to include('Your subscription has been downgraded.')
end
end
......@@ -187,7 +187,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
end
it 'has a nice subject' do
expect(subject).to include('Your subscription will automatically renew in 4 days')
expect(subject).to include('Your subscription will automatically renew in 4 days.')
end
it 'has an expiration blocking message' do
......
......@@ -600,6 +600,18 @@ RSpec.describe Gitlab::GitAccess do
end
end
context "when license blocks changes" do
before do
create_current_license(starts_at: 1.month.ago.to_date, block_changes_at: Date.current, notify_admins_at: Date.current)
user.update_attribute(:admin, true)
project.add_role(user, :developer)
end
it 'raises an error' do
expect { push_changes(changes[:any]) }.to raise_error(Gitlab::GitAccess::ForbiddenError, /Your subscription will expire/)
end
end
context "group-specific access control" do
let(:user) { create(:user) }
let(:group) { create(:group) }
......
......@@ -20845,7 +20845,7 @@ msgstr ""
msgid "Something went wrong while updating your list settings"
msgstr ""
msgid "Something went wrong with your automatic subscription renewal"
msgid "Something went wrong with your automatic subscription renewal."
msgstr ""
msgid "Something went wrong, unable to add %{project} to dashboard"
......@@ -26201,13 +26201,13 @@ msgstr ""
msgid "Your subscription expired!"
msgstr ""
msgid "Your subscription has been downgraded"
msgid "Your subscription has been downgraded."
msgstr ""
msgid "Your subscription will automatically renew in %{remaining_days}"
msgid "Your subscription will automatically renew in %{remaining_days}."
msgstr ""
msgid "Your subscription will expire in %{remaining_days}"
msgid "Your subscription will expire in %{remaining_days}."
msgstr ""
msgid "Zoom meeting added"
......
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