Skip to content
Snippets Groups Projects
Commit f55f760b authored by Nicolas Dular's avatar Nicolas Dular
Browse files

Add freeUserCapEnforced field to Group type

This adds the field `freeUserCapEnforced` to the Group type in GraphQl
which indicates if the group has limited free users when on a free
plan.

Changelog: added
EE: true
parent 02fb7ed0
No related branches found
No related tags found
1 merge request!90739Add freeUserCapEnforced field to Group type
......@@ -11712,6 +11712,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupdescriptionhtml"></a>`descriptionHtml` | [`String`](#string) | The GitLab Flavored Markdown rendering of `description`. |
| <a id="groupdora"></a>`dora` | [`Dora`](#dora) | Group's DORA metrics. |
| <a id="groupemailsdisabled"></a>`emailsDisabled` | [`Boolean`](#boolean) | Indicates if a group has email notifications disabled. |
| <a id="groupenforcefreeusercap"></a>`enforceFreeUserCap` | [`Boolean`](#boolean) | Indicates whether the group has limited users for a free plan. |
| <a id="groupepicboards"></a>`epicBoards` | [`EpicBoardConnection`](#epicboardconnection) | Find epic boards. (see [Connections](#connections)) |
| <a id="groupepicsenabled"></a>`epicsEnabled` | [`Boolean`](#boolean) | Indicates if Epics are enabled for namespace. |
| <a id="groupexternalauditeventdestinations"></a>`externalAuditEventDestinations` | [`ExternalAuditEventDestinationConnection`](#externalauditeventdestinationconnection) | External locations that receive audit events belonging to the group. (see [Connections](#connections)) |
......@@ -122,6 +122,13 @@ module GroupType
description: 'Cluster agents associated with projects in the group and its subgroups.',
resolver: ::Resolvers::Clusters::AgentsResolver
field :enforce_free_user_cap,
::GraphQL::Types::Boolean,
null: true,
authorize: :owner_access,
description: 'Indicates whether the group has limited users for a free plan.',
method: :enforce_free_user_cap?
def billable_members_count(requested_hosted_plan: nil)
object.billable_members_count(requested_hosted_plan)
end
......
......@@ -461,7 +461,11 @@ def user_cap_available?
end
def apply_user_cap?
user_cap_available? || free_user_cap.enforce_cap?
user_cap_available? || enforce_free_user_cap?
end
def enforce_free_user_cap?
free_user_cap.enforce_cap?
end
def user_limit_reached?(use_cache: false)
......
......@@ -24,6 +24,7 @@
it { expect(described_class).to have_graphql_field(:merge_request_violations) }
it { expect(described_class).to have_graphql_field(:allow_stale_runner_pruning) }
it { expect(described_class).to have_graphql_field(:cluster_agents) }
it { expect(described_class).to have_graphql_field(:enforce_free_user_cap) }
describe 'vulnerabilities' do
let_it_be(:group) { create(:group) }
......
......@@ -1826,6 +1826,27 @@
end
end
describe '#enforce_free_user_cap?' do
let(:namespace) { build(:namespace) }
where(:enforce_free_cap, :result) do
false | false
true | true
end
subject { namespace.enforce_free_user_cap? }
with_them do
before do
expect_next_instance_of(Namespaces::FreeUserCap::Standard, namespace) do |instance|
expect(instance).to receive(:enforce_cap?).and_return(enforce_free_cap)
end
end
it { is_expected.to eq(result) }
end
end
describe '#capacity_left_for_user?' do
let(:namespace) { create(:group) }
let(:user) { create(:user) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment