Skip to content

Commit fe64f9a

Browse files
committed
Exclude non-regular users from license seat limit
1 parent e311861 commit fe64f9a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

extensions/ee/app/services/ee/users/validate_user_limit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module ValidateUserLimit
88
def validate_user_limit!(t)
99
license = License.current
1010
return if license.nil? || !license.restricted?(:user_count)
11-
return if User.count <= license.restrictions[:user_count]
11+
return if User.regular.count <= license.restrictions[:user_count]
1212

1313
t.rollback_and_return! ServiceResponse.error(
1414
message: 'No free user seats in license',

extensions/ee/spec/services/ee/users/create_service_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,14 @@
2626
it { expect { service_response }.not_to change { User.count } }
2727
it { expect(service_response.payload[:error_code]).to eq(:no_free_license_seats) }
2828
end
29+
30+
context 'when non-regular users exist' do
31+
before do
32+
current_user
33+
create(:user, :ghost)
34+
create(:license, restrictions: { user_count: 2 })
35+
end
36+
37+
it { is_expected.to be_success }
38+
end
2939
end

0 commit comments

Comments
 (0)